This module should help you work with automatas on a grid.
surroundingNeighbors : ( Basics.Int, Basics.Int ) -> List { location : ( Basics.Int, Basics.Int ), direction : ( Basics.Int, Basics.Int ) }
Compute all 8 surrounding neighbors
touchingNeighbors : ( Basics.Int, Basics.Int ) -> List { location : ( Basics.Int, Basics.Int ), direction : ( Basics.Int, Basics.Int ) }
Compute the 4 direct neighbors
diagonalNeighbors : ( Basics.Int, Basics.Int ) -> List { location : ( Basics.Int, Basics.Int ), direction : ( Basics.Int, Basics.Int ) }
Compute the 4 diagonal neighbors