public static JSONObject generateJMove(SimulatedMove move) { JSONObject jObj = compressBoard(move.board); //Debug.Log("SimMove response obj: \n" + jObj.Print(true)); //jObj.AddField(Constants.JProtocol.board, compressBoard(move.board)); //jObj.AddField(Constants.JProtocol.playerMove, move.playerMove); //jObj.AddField(Constants.JProtocol.enemyMove, move.enemyMove); return(jObj); }
public static SimulatedMove[] simulateAllEnemyMoves(Board board, string playerDir, List <string> enemyDirs) { SimulatedMove[] newBoards = new SimulatedMove[(Constants.AMOUNT_PLAYERS - 1) * Constants.POSSIBLE_MOVES]; for (int i = 0; i < newBoards.Length; i++) { newBoards[i] = simulateMove(board, new string[] { playerDir, enemyDirs[i] }); } return(newBoards); }
private APIMsgConclusion activateSimulateMove(JSONObject jObj, Func <Board, string, string, SimulatedMove> simMove) { JSONObject jBoard = jObj.GetField(Constants.JProtocol.board); Board startBoard = new Board(jBoard); BoardMoves moves = parseBoardMoves(jObj); SimulatedMove temp = simMove(startBoard, moves.playerMove, moves.enemyMove);//SnakeAPILogic.simulateMove(startBoard, moves.playerMove, moves.enemyMove, false); string encodedBoards = SnakeProtocolEncoder.compressSimulatedMove(temp); return(new APIMsgConclusion() { status = ResponseStatus.Success, msg = encodedBoards, target = MsgTarget.Player }); }
public static string compressSimulatedMove(SimulatedMove move) { return(generateJMove(move).Print()); }