/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
private SnakeBoard HandleSimulateMove(SnakeBoard board, MovesToSimulate simMoves, string request) { string response = SendCommandReceiveMessage(request); return(SnakeJsonHandler.ParseResponseSimulate(response)); }
protected override void ExtractState(JObject jState) { BoardStruct boardStruct = SnakeJsonHandler.ParseResponseState(jState); currentBoard = new SnakeBoard(currentBoard, boardStruct); }