public void RandomizerTurn(InternalSimulator TestSim) { if (!TestSim.Finished()) { object[] temp = RandomInput.GetRandomDecision(); int temp2 = ((int)((object[])temp[0])[0]); TestSim.SetCommand(temp); int i = RandomInput.ReturnDecisionCount(); int j = 0; while (TestSim.ReturnChosenCommand() != temp2) { temp = RandomInput.GetRandomDecision(); temp2 = ((int)((object[])temp[0])[0]); TestSim.SetCommand(temp); j++; if (i == j) { break; } } } }
public void SingleCCTurn(InternalSimulator TestSim, int cc, int Player) { if (cc == -1) { while (TestSim.Turn() == Player && !TestSim.Finished()) { IDT.setObjectArgs(TestSim.GetData(Player)); IDT.SetState(true); BaseL.GetArrays(); BaseL.ForceNodeClustersToGetData(); BaseL.NodeCalculations(); TestSim.SetCommand(BaseL.GetAllDecisions()); IDT.SetState(false); currentCommandNumber = TestSim.ReturnChosenCommand(); CCLog(this, new CommandCArgs(new int[] { currentCommandNumber, Player })); } } else { while (TestSim.Turn() == Player && !TestSim.Finished()) { } IDT.setObjectArgs(TestSim.GetData(Player)); IDT.SetState(true); CC[cc].GetArrays(); CC[cc].ForceNodeClustersToGetData(); CC[cc].NodeCalculations(); TestSim.SetCommand(CC[cc].GetAllDecisions()); IDT.SetState(false); currentCommandNumber = TestSim.ReturnChosenCommand(); CCLog(this, new CommandCArgs(new int[] { currentCommandNumber, Player })); if (PlayMode == 0) { CC[cc].LogCluster(currentCommandNumber); } } }
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); } }
public int InternalAITurn(InternalSimulator TestSim) { if (CC != null) { if (!TestSim.Finished()) { if (PlayerMode == 1) { // The human is always player 1, the AI take up the remaining players int Move = 0; for (int i = 0; i < CC.Length; i++) { if (TestSim.Turn() == i + 2) { Move = i; } } while (TestSim.Turn() == Move + 2 && !TestSim.Finished()) { IDT.setObjectArgs(TestSim.GetData(Move + 2)); IDT.SetState(true); CC[Move].GetArrays(); CC[Move].ForceNodeClustersToGetData(); CC[Move].NodeCalculations(); //CC[Move].LegacyNodeCalculations(); TestSim.SetCommand(CC[Move].GetAllDecisions()); IDT.SetState(false); currentCommandNumber = TestSim.ReturnChosenCommand(); CCLog(this, new CommandCArgs(new int[] { currentCommandNumber, Move + 2 })); if (PlayMode == 0) { CC[Move].LogCluster(currentCommandNumber); } } } else if (PlayerMode == 2) { int Move = 0; for (int i = 0; i < CC.Length; i++) { if (TestSim.Turn() == i + 1) { Move = i; } } while (TestSim.Turn() == Move + 1 && !TestSim.Finished()) { IDT.setObjectArgs(TestSim.GetData(Move + 1)); IDT.SetState(true); CC[Move].GetArrays(); CC[Move].ForceNodeClustersToGetData(); CC[Move].NodeCalculations(); TestSim.SetCommand(CC[Move].GetAllDecisions()); IDT.SetState(false); currentCommandNumber = TestSim.ReturnChosenCommand(); CCLog(this, new CommandCArgs(new int[] { currentCommandNumber, Move + 1 })); if (PlayMode == 0) { CC[Move].LogCluster(currentCommandNumber); } } } else if (PlayerMode == 3) { int Move = 0; for (int i = 0; i < CC.Length; i++) { if (TestSim.Turn() == i + 2) { Move = i; } } while (TestSim.Turn() == Move + 2 && !TestSim.Finished()) { IDT.setObjectArgs(TestSim.GetData(Move + 2)); IDT.SetState(true); CC[Move].GetArrays(); CC[Move].ForceNodeClustersToGetData(); CC[Move].NodeCalculations(); TestSim.SetCommand(CC[Move].GetAllDecisions()); IDT.SetState(false); currentCommandNumber = TestSim.ReturnChosenCommand(); CCLog(this, new CommandCArgs(new int[] { currentCommandNumber, Move })); if (PlayMode == 0) { CC[Move].LogCluster(currentCommandNumber); } } } return(currentCommandNumber); } else { return(-1); } } else { return(-1); } }