June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -11,14 +11,9 @@ let () =
|
|||
let nx = int_of_string Sys.argv.(1) in
|
||||
let ny = int_of_string Sys.argv.(2) in
|
||||
|
||||
let rec random_order = function
|
||||
| [] -> []
|
||||
| [a] -> [a]
|
||||
| x -> let i = Random.int (List.length x) in
|
||||
let rec del i = function
|
||||
| [] -> failwith "del"
|
||||
| h::t -> if i = 0 then t else h :: del (i-1) t in
|
||||
(List.nth x i) :: random_order (del i x) in
|
||||
let shuffle lst =
|
||||
let nl = List.map (fun c -> (Random.bits (), c)) lst in
|
||||
List.map snd (List.sort compare nl) in
|
||||
|
||||
let get_neighbours (x,y) =
|
||||
let lim n k = (0 <= k) && (k < n) in
|
||||
|
|
@ -29,7 +24,7 @@ let () =
|
|||
mark cell;
|
||||
let check k =
|
||||
if not (marked k) then (join cell k; visit k) in
|
||||
List.iter check (random_order (get_neighbours cell)) in
|
||||
List.iter check (shuffle (get_neighbours cell)) in
|
||||
|
||||
let print_maze () =
|
||||
begin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue