let wall_neighbours cave x y =
List.fold_right
(fun x rest -> match x with
| WALL -> 1 + rest
| _ -> rest)
[ get cave (x-1) (y-1); get cave x (y-1); get cave (x+1) (y-1);
get cave (x-1) y; get cave x y; get cave (x+1) y;
get cave (x-1) (y+1); get cave x (y+1); get cave (x+1) (y+1) ]
0