let cx, ix = euclid_div x chunk_size
and cy, iy = euclid_div y chunk_size in
match CoordMap.find_opt (cx, cy) board with
- | Some cs -> cs.(ix).(iy)
+ | Some cs -> cs.(iy).(ix)
| None -> d
let set x y c (d, cells) =
(function
| Some cs ->
let cs = Array.map Array.copy cs in
- cs.(ix).(iy) <- c;
+ cs.(iy).(ix) <- c;
Some cs
| None ->
Some
- (Array.init chunk_size (fun x ->
- Array.init chunk_size (fun y -> if x = ix && y = iy then c else d))))
+ (Array.init chunk_size (fun y ->
+ Array.init chunk_size (fun x -> if x = ix && y = iy then c else d))))
cells )
let iter_range minx maxx miny maxy f (d, board) =
for cy = mincy to maxcy do
let get =
match CoordMap.find_opt (cx, cy) board with
- | Some chunk -> fun x y -> chunk.(x).(y)
+ | Some chunk -> fun x y -> chunk.(y).(x)
| None -> fun _ _ -> d
in
for x = if cx = mincx then minix else 0 to if cx = maxcx then maxix else chunk_size - 1 do
(fun b (cx, cy) ->
let getcc dx dy =
match CoordMap.find_opt (cx + dx, cy + dy) board with
- | Some chunk -> fun x y -> chunk.(x).(y)
+ | Some chunk -> fun x y -> chunk.(y).(x)
| None -> fun _ _ -> d
in
let getll = getcc (-1) (-1)
| () -> getgg (x - chunk_size) (y - chunk_size))
in
CoordMap.add (cx, cy)
- (Array.init chunk_size (fun x ->
- Array.init chunk_size (fun y ->
+ (Array.init chunk_size (fun y ->
+ Array.init chunk_size (fun x ->
M.transition (M.map (fun (dx, dy) -> get (x + dx) (y + dy)) M.neighbours))))
b)
CoordMap.empty ccoords