コード例 #1
0
        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);
        }
コード例 #2
0
 static bool canDown(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Up &&
 !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftBottom()));
コード例 #3
0
 static bool canUp(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Down &&
 !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftTop()));
コード例 #4
0
 static bool canRight(GameBoard gameBoard, BoardPoint head) => prevDirection != Direction.Left &&
 !badElements.Contains(gameBoard.GetElementAtOrWall(head.ShiftRight()));
コード例 #5
0
 static int incrementIfNotBadPoint(GameBoard gameBoard, BoardPoint point) => strongBadElements.Contains(gameBoard.GetElementAtOrWall(point)) ? 0 : 1;