private static Direction GetDefaultDirection(GameBoard gameBoard, BoardPoint head) { if (head == null) { return(Direction.Right); } if (prevDirection != Direction.Left && !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftRight()))) { return(Direction.Right); } if (prevDirection != Direction.Down && !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftTop()))) { return(Direction.Up); } if (prevDirection != Direction.Up && !strongBadElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftBottom()))) { return(Direction.Down); } return(Direction.Left); }
static bool canDown(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Up && !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftBottom()));
static bool canUp(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Down && !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftTop()));
static bool canRight(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Left && !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftRight()));
static int incrementIfNotBadPoint(GameBoard gameBoard, BoardPoint point) => strongBadElements.Contains(gameBoard.GetElementAtOrWall(point)) ? 0 : 1;