// Test Methods public void CreateCommandCenter(bool InitialLoggingState) { CC = new CommandCenter[1]; CC[0] = new CommandCenter(IDT, "" + CommandCenterCount, InitialLoggingState, this); CommandCenterCount++; SubCC(CC[0]); }
private void LogClusterDecision(CommandCenter c, CommandCArgs e) { if (Enabled && Started) { StrW.WriteLine(e.GetStringData()); } }
public void SingleCommandCenterSetup(bool InitialLoggingState) { CC = new CommandCenter[1]; CC[0] = new CommandCenter(IDT, "" + CommandCenterCount, InitialLoggingState, this); CommandCenterCount++; SubCC(CC[0]); int temp = (int)IDT.getItem(3, 0, 0); int[][] CommandSig = TestSimulator.GetCommandSignature(); IDT.setIntArgs(CommandSig); RandomInput = new Randomizer((int)IDT.getItem(3, 0, 0)); CC[0].GetArrays(); CC[0].SetBounds(TestSimulator.ReturnRecommendedRange()); CC[0].CreateClustersFromTemplate1(); int[][] DataSig = new int[1][]; DataSig[0] = TestSimulator.GetDataSignature(); IDT.setIntArgs(DataSig); CC[0].GetArrays(); CC[0].MakeNodeClusterGetArrays(); if (RecalculateFlag) { CalculateCombinations(temp, DataSig); } CC[0].GenerateNodes(UntrimmedCombinations); CC[0].SetPlayMode(PlayMode); CC[0].SetPlayerMode(PlayerMode); GC.Collect(); GC.WaitForPendingFinalizers(); UILog(this, CC.ToString()); }
public void SetupSingleCommandCenter(bool InitialLoggingState) { CC = new CommandCenter[1]; CC[0] = new CommandCenter(IDT, "" + CommandCenterCount, InitialLoggingState, this); CommandCenterCount++; SubCC(CC[0]); int temp = (int)IDT.getItem(3, 0, 0); int[][] CommandSig = (int[][])InvokeDictionaryMethod(1, new object[0]); IDT.setIntArgs(CommandSig); CC[0].GetArrays(); CC[0].CreateClustersFromTemplate1(); int[][] DataSig = new int[1][]; DataSig[0] = (int[])InvokeDictionaryMethod(2, new object[0]); IDT.setIntArgs(DataSig); CC[0].GetArrays(); CC[0].MakeNodeClusterGetArrays(); CC[0].SetBounds((int[])InvokeDictionaryMethod(12, new object[0])); if (RecalculateFlag) { CalculateCombinations(temp, DataSig); } CC[0].GenerateNodes(UntrimmedCombinations); GC.Collect(); GC.WaitForPendingFinalizers(); UILog(this, CC.ToString()); }
private void LogCommand(CommandCenter c, CommandCArgs e) { if (Enabled) { } if (Started) { } }
private void LogNodeDecision(CommandCenter c, CommandCArgs e) { if (Enabled) { } if (Started) { } }
public void CreateFullCommandCenter(bool InitialLoggingState) { CC = new CommandCenter[1]; CC[0] = new CommandCenter(IDT, "" + CommandCenterCount, InitialLoggingState, this); CommandCenterCount++; SubCC(CC[0]); CC[0].GetArrays(); CC[0].CreateClustersFromTemplate1(); }
private void LogStart(CommandCenter c, CommandCArgs e) { if (Enabled) { RoundMoves = ""; Started = true; StrW = new StreamWriter(path, true); StrW.WriteLine(Environment.NewLine + "Game Start"); } }
private void LogPlayer(CommandCenter c, CommandCArgs e) { if (Enabled) { if (Started) { StrW.WriteLine("Player: " + e.GetIntArrayData()[0]); } } }
private void QueueToggle(CommandCenter c, EventArgs e) { if (Started) { toggleQueue = !toggleQueue; } else { Enabled = !Enabled; } }
private void LogGeneral(CommandCenter c, CommandCArgs e) { if (Enabled) { StreamWriter SW = new StreamWriter(path, true); SW.Write(CC.ToString() + Environment.NewLine); SW.Flush(); SW.Close(); } }
// Simulation Tester Methods public void InternalSimulatorSetup(bool LoggingState, InternalSimulator TestSimulator) { IDT.setStringArgs(TestSimulator.GetCommandNames()); CC = new CommandCenter[TestSimulator.GetPlayerCount()]; //int ThreadCount = Environment.ProcessorCount * 2; //int currentProcessor = 0; Thread[] GenerationThreads = new Thread[CC.Length + 1]; int CombinationLevel = (int)IDT.getItem(3, 0, 0); for (int i = 0; i < CC.Length; i++) { CC[i] = new CommandCenter(IDT, "" + CommandCenterCount, LoggingState, this); CommandCenterCount++; SubCC(CC[i]); } BaseL = new CommandCenter(IDT, "" + BaseLineCCCount, "Baseline", LoggingState, this); BaseLineCCCount++; SubCC(BaseL); int[][] CommandSig = TestSimulator.GetCommandSignature(); IDT.setIntArgs(CommandSig); RandomInput = new Randomizer((int)IDT.getItem(3, 0, 0)); for (int i = 0; i < CC.Length; i++) { CC[i].GetArrays(); CC[i].SetBounds(TestSimulator.ReturnRecommendedRange()); CC[i].CreateClustersFromTemplate1(); } BaseL.GetArrays(); BaseL.SetBounds(TestSimulator.ReturnRecommendedRange()); BaseL.CreateClustersFromTemplate1(); int[][] DataSig = new int[1][]; DataSig[0] = TestSimulator.GetDataSignature(); IDT.setIntArgs(DataSig); string[] Names = IDT.getStringArgs()[0]; for (int i = 0; i < CC.Length; i++) { CC[i].SetClusterNames(Names); } for (int i = -1; i < CC.Length; i++) { int temp = i; GenerationThreads[temp + 1] = new Thread(() => NodeCreation(temp, CombinationLevel, GenerationThreads[temp + 1])); GenerationThreads[temp + 1].Start(); } GC.Collect(); GC.WaitForPendingFinalizers(); UILog(this, CC.ToString()); }
private void LogString(CommandCenter c, CommandCArgs e) { if (Enabled) { try { StreamWriter STemp = new StreamWriter(path, true); STemp.WriteLine(e.GetStringData()); STemp.Flush(); STemp.Close(); } catch { } } }
// This is still in the works private void SaveCC_Click(object sender, EventArgs e) { Stream StreamWriter; SaveFileDialog Dialog1 = new SaveFileDialog(); Dialog1.Filter = "cc files (*.cc)|*.cc|All files (*.*)|*.*"; Dialog1.FilterIndex = 1; Dialog1.RestoreDirectory = true; if (Dialog1.ShowDialog() == DialogResult.OK) { if ((StreamWriter = Dialog1.OpenFile()) != null) { CommandCenter[] tempCC = CC.ReturnCC(); CommandCenter BaseL = CC.ReturnBaseL(); Byte[] Count = new Byte[1]; Count[0] = Convert.ToByte(tempCC.Length + 1); StreamWriter.Write(Count, 0, 1); Count = new Byte[1]; NodeCluster[] NC = tempCC[0].ReturnClusters(); Byte[] temp = BitConverter.GetBytes(NC.Length); Count[0] = Convert.ToByte(temp.Length); StreamWriter.Write(Count, 0, 1); StreamWriter.Write(temp, 0, (temp.Length)); temp = BitConverter.GetBytes(tempCC[0].ReturnUntrimmedCount()); Count[0] = Convert.ToByte(temp.Length); StreamWriter.Write(Count, 0, 1); StreamWriter.Write(temp, 0, temp.Length); temp = BitConverter.GetBytes(tempCC[0].ReturnTrimmedCount()); Count[0] = Convert.ToByte(temp.Length); StreamWriter.Write(Count, 0, 1); StreamWriter.Write(temp, 0, temp.Length); for (int i = 0; i < tempCC.Length + 1; i++) { if (i != tempCC.Length) { NC = tempCC[i].ReturnClusters(); for (int j = 0; j < NC.Length; j++) { } } else { } } StreamWriter.Close(); } } }
private void LogEnd(CommandCenter c, CommandCArgs e) { if (Enabled) { if (Started) { RoundMoves = ""; StrW.WriteLine("Game End" + Environment.NewLine); Started = false; SwapState(); StrW.Flush(); StrW.Close(); } } }
private void LogWeights(CommandCenter c, CommandCArgs e) { if (Enabled && !Started) { StreamWriter SW = new StreamWriter(path, true); string[][] TempWeights = e.GetString2DArrayData(); for (int i = 0; i < TempWeights.Length; i++) { for (int k = 0; k < TempWeights[i].Length; k++) { SW.WriteLine(TempWeights[i][k]); } } SW.Flush(); SW.Close(); } }
public void Subscribe(CommandCenter c) { c.GameStart += new CommandCenter.LogCommand(LogStart); c.GameMode += new CommandCenter.LogCommand(LogMode); c.Result += new CommandCenter.LogCommand(LogResult); c.RoundData += new CommandCenter.LogCommand(LogData); c.RoundNodeDecisions += new CommandCenter.LogCommand(LogNodeDecision); c.RoundClusterDecisions += new CommandCenter.LogCommand(LogClusterDecision); c.RoundChosenCommand += new CommandCenter.LogCommand(LogCommand); c.NodeWeights += new CommandCenter.LogCommand(LogWeights); c.NodeDataSources += new CommandCenter.LogCommand(LogDataSources); c.NodeOperators += new CommandCenter.LogCommand(LogOperators); c.EndGame += new CommandCenter.LogCommand(LogEnd); c.ToggleLog += new CommandCenter.LogCommand(QueueToggle); c.StringRepresentation += new CommandCenter.LogCommand(LogGeneral); c.BaseLineResults += new CommandCenter.LogCommand(LogString); c.Time += new CommandCenter.LogCommand(LogString); c.ChosenMove += new CommandCenter.LogCommand(LogMove); c.PlayerID += new CommandCenter.LogCommand(LogPlayer); }
private void LogMove(CommandCenter c, CommandCArgs e) { if (Enabled) { if (Started) { if (RoundMoves.Length != 0) { RoundMoves += ", "; } try { RoundMoves += e.GetIntArrayData()[1] + ": " + CommandNames[e.GetIntArrayData()[0]]; } catch (IndexOutOfRangeException) { StrW.WriteLine("Error: The Command Names array did not match with the decision numbers"); } } } }
public Logger(CommandCenter CC, string identifier, string Name, bool InitialLoggingState, string[] CommandNames) { this.CC = CC; Subscribe(CC); this.CommandNames = CommandNames; path += identifier + ".txt"; Enabled = InitialLoggingState; if (File.Exists(path)) { File.Delete(path); } StreamWriter SW = new StreamWriter(path); SW.Write(Name + Environment.NewLine); SW.Flush(); SW.Close(); }
private void LogMode(CommandCenter c, CommandCArgs e) { if (Enabled) { if (Started) { StrW.Write("Mode: "); int mode = c.GetPlayMode(); if (mode == 0) { StrW.WriteLine("Learning"); } else if (mode == 1) { StrW.WriteLine("Playing"); } else if (mode == 2) { StrW.WriteLine("User Input"); } } } }
private void LogResult(CommandCenter c, CommandCArgs e) { if (Enabled) { if (Started) { StrW.WriteLine(RoundMoves); int Res = e.GetIntArrayData()[0]; if (Res > 0) { StrW.WriteLine("Win: " + Res); } else if (Res < 0) { StrW.WriteLine("Loss: " + Res); } else { StrW.WriteLine("Tie: " + Res); } } } }
private void LogIt(CommandCenter m, string e) { OtherLogBox.AppendText(e); OtherLogBox.AppendText(Environment.NewLine); }
public void Subscribe(CommandCenter m) { m.UILog += new CommandCenter.LogUI(LogIt); m.SubNodeCluster += new CommandCenter.SubscribeItem(Subscribe); }
private void LogOperators(CommandCenter c, CommandCArgs e) { if (Enabled) { } }
private void LogDataSources(CommandCenter c, CommandCArgs e) { if (Enabled) { } }