Esempio n. 1
0
        /// <summary>
        /// Returns the possible moves for both the player and the enemy, based off directions only.
        /// </summary>
        public PossibleMoves GetPossibleMoves(SnakeBoard board)
        {
            string request  = SnakeJsonHandler.CreateCommandPossibleMoves(board);
            string response = SendCommandReceiveMessage(request);

            return(SnakeJsonHandler.ParseResponsePossibleMoves(response));
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the state of the board.
        /// </summary>
        public BoardState EvaluateBoard(SnakeBoard board)
        {
            string request  = SnakeJsonHandler.CreateCommandEvaluate(board);
            string response = SendCommandReceiveMessage(request);

            return(SnakeJsonHandler.ParseResponseEvaluate(response));
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a board where the moves have been applied.
        /// </summary>
        public SnakeBoard SimulateMoves(SnakeBoard board, string playerMove, string enemyMove)
        {
            MovesToSimulate simMoves = new MovesToSimulate()
            {
                playerMove = playerMove, enemyMove = enemyMove
            };
            string request = SnakeJsonHandler.CreateCommandSimulateBoth(board, simMoves);

            return(HandleSimulateMove(board, simMoves, request));
        }
Esempio n. 4
0
        /// <summary>
        /// Simulate a move where only the enemy moves.
        /// </summary>
        /// <param name="board">The board which the move is applied to.</param>
        /// <param name="move">The direction in which you want to simulate a move.</param>
        /// <returns>The board where the move has been applied.</returns>
        public SnakeBoard SimulateEnemyMove(SnakeBoard board, string move)
        {
            MovesToSimulate simMoves = new MovesToSimulate()
            {
                enemyMove = move
            };
            string request = SnakeJsonHandler.CreateCommandSimulateEnemy(board, simMoves);

            return(HandleSimulateMove(board, simMoves, request));
        }
Esempio n. 5
0
        private SnakeBoard HandleSimulateMove(SnakeBoard board, MovesToSimulate simMoves, string request)
        {
            string response = SendCommandReceiveMessage(request);

            return(SnakeJsonHandler.ParseResponseSimulate(response));
        }
Esempio n. 6
0
        protected override void ExtractState(JObject jState)
        {
            BoardStruct boardStruct = SnakeJsonHandler.ParseResponseState(jState);

            currentBoard = new SnakeBoard(currentBoard, boardStruct);
        }