Traverse all possible directions from the cells
for ( int i = 0 ; i < dirs . GetLength ( 0 ) ; ) { int [ ] dir = GetRow ( dirs , i ++ ) ; int x = p . first + dir [ 0 ] ; int y = p . second + dir [ 1 ] ;