Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 5
0
        private SnakeBoard HandleSimulateMove(SnakeBoard board, MovesToSimulate simMoves, string request)
        {
            string response = SendCommandReceiveMessage(request);

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

            currentBoard = new SnakeBoard(currentBoard, boardStruct);
        }