public void AiMove() { if (SimulatorID == 1) { PrintCommand(CC.InternalAITurn(CurrentSim)); if (turn % 2 == 0) { turn++; } else { turn--; } if (CurrentSim.Finished()) { PrintResults(CurrentSim.GetUnweightedResult(1)); } Running = false; } else if (SimulatorID == 2) { UltTTT.PrintCommand(CC.InternalAITurn(CurrentSim)); if (CurrentSim.Finished()) { UltTTT.PrintResults(CurrentSim.GetUnweightedResult(1)); } } long[] Temp = CC.GetDecisionTime(0); for (int i = 0; i < Temp.Length; i++) { //OtherLogBox.AppendText("" + Temp[i] + Environment.NewLine); } }
public void EndRound(InternalSimulator TestSim, int Turn, int CCN) { if (PlayerMode == 4 || PlayerMode == 3) { if (CCN == -1) { BaseL.EndRound(TestSim.GetResult(Turn), TestSim.GetUnweightedResult(Turn)); } else { CC[CCN].EndRound(TestSim.GetResult(Turn), TestSim.GetUnweightedResult(Turn)); } } }
public void EndCC(InternalSimulator TestSim) { // Each CommandCenter's player number is 1 greater than it's ID. This is only for AI vs AI. for (int i = 0; i < CC.Length; i++) { CC[i].EndRound(TestSim.GetResult(i + 1), TestSim.GetUnweightedResult(i + 1)); } }
public void EndRound(InternalSimulator TestSim) { if (PlayerMode == 1) { for (int i = 0; i < CC.Length - 1; i++) { CC[i].EndRound(TestSim.GetResult(i + 2), TestSim.GetUnweightedResult(i + 2)); } } else if (PlayerMode == 2) { for (int i = 0; i < CC.Length; i++) { CC[i].EndRound(TestSim.GetResult(i + 1), TestSim.GetUnweightedResult(i + 1)); } } }
public void BaseLineTest(InternalSimulator TestSim) { BaseLineResults = new int[CC.Length][]; for (int i = 0; i < BaseLineResults.Length; i++) { BaseLineResults[i] = new int[3]; } int TurnCount = TestSim.GetPlayerCount(); int DecisionCount = RandomInput.ReturnDecisionCount(); int Player1 = 1; int[] BaseLPlayers = new int[0]; for (int j = 0; j < CC.Length; j++) { CC[j].SetDecisionMode(0); for (int i = 0; i < DecisionCount; i++) { for (int o = 0; o < 3; o++) { int AITurnCount = 0; StartRound(j, Player1); // Player 1 is CC StartRound(-1, 2); // Player 2 is Baseline StartRound(TestSim, 2); BaseLPlayers = new int[TurnCount - 1]; for (int q = 1; q <= TurnCount - 1; q++) { // The first index is 0, but the first player is 2 BaseLPlayers[q - 1] = q + 1; } while (TestSim.Turn() == 2 && !TestSim.Finished()) { TestSim.SetCommand(RandomInput.CreateDecisionFromInt(i)); CCLog(this, new CommandCArgs(new int[] { TestSim.ReturnChosenCommand(), 2 })); } BaseL.SetDecisionMode(o); int count = 0; while (!TestSim.Finished()) { SingleCCTurn(TestSim, j, Player1); AITurnCount++; for (int l = 0; l < BaseLPlayers.Length; l++) { int temp = BaseLPlayers[l]; SingleCCTurn(TestSim, -1, temp); } if (count >= DecisionCount) { break; } count++; } int Result = TestSim.GetUnweightedResult(Player1); if (Result == 1) { BaseLineResults[j][0]++; } else if (Result == 0) { BaseLineResults[j][1]++; } if (Result == -1) { BaseLineResults[j][2]++; } EndRound(TestSim, Player1, j); EndRound(TestSim, BaseLPlayers[0], -1); } } StartRound(j, Player1); // Player 1 is CC StartRound(-1, 2); // Player 2 is Baseline StartRound(TestSim, 1); int AITurnCount2 = 0; int count2 = 0; BaseL.SetDecisionMode(0); BaseLPlayers = new int[TurnCount - 1]; for (int q = 1; q <= TurnCount - 1; q++) { // The first index is 0, but the first player is 2 BaseLPlayers[q - 1] = q + 1; } int[] PlayedMoves1 = new int[9]; while (!TestSim.Finished()) { SingleCCTurn(TestSim, j, Player1); AITurnCount2++; if (TestSim.Finished()) { break; } for (int l = 0; l < BaseLPlayers.Length; l++) { int temp = BaseLPlayers[l]; SingleCCTurn(TestSim, -1, temp); } if (count2 >= DecisionCount) { break; } count2++; } int Result2 = TestSim.GetUnweightedResult(Player1); if (Result2 == 1) { BaseLineResults[j][0]++; } else if (Result2 == 0) { BaseLineResults[j][1]++; } if (Result2 == -1) { BaseLineResults[j][2]++; } EndRound(TestSim, Player1, j); EndRound(TestSim, BaseLPlayers[0], -1); } }