예제 #1
0
 public bool IsAdjacentTo(Position position)
 {
     //TODO: figure out a more functional way of doing this (e.g. one-line predicate for x and y)
     return (position.x == x - 1 && position.y == y - 1)
         || (position.x == x - 1 && position.y == y)
         || (position.x == x - 1 && position.y == y + 1)
         || (position.x == x && position.y == y - 1)
         || (position.x == x && position.y == y + 1)
         || (position.x == x + 1 && position.y == y - 1)
         || (position.x == x + 1 && position.y == y)
         || (position.x == x + 1 && position.y == y + 1);
 }
예제 #2
0
 public Cell(Position position, State state)
 {
     Position = position;
     State = state;
 }
예제 #3
0
 public Cell GetCellAt(Position position)
 {
     return cells.SingleOrDefault(cell => cell.Position.Equals(position));
 }