public void Test_Session() { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); instance = this; SessionSuiteRunner = new SessionSuiteRunner(); SessionSuiteRunner.Configuration = XmlSerializerExt.Deserialize <SessionSuiteCfg>( Path.Combine(testResourcesPath, "SessionSuiteRunner_Test_Sessions.xml")); SessionSuiteRunner.Run(); Assert.AreEqual(2, _players.Count); Assert.IsNotNull(_gameRules1); Assert.AreEqual(1, _gameRules1.OnCreateCount); Assert.IsNotNull(_gameRules2); Assert.AreEqual(1, _gameRules2.OnCreateCount); for (int p = 0; p < _players.Count; ++p) { Assert.AreEqual(1, _players[p].OnServerConnectCount); Assert.AreEqual(1, _players[p].OnServerDisconnectCount); Assert.AreEqual(2, _players[p].OnSessionBeginCount); Assert.AreEqual(2, _players[p].OnSessionEndCount); Assert.AreEqual(5, _players[p].OnGameBeginCount); Assert.AreEqual(10, _players[p].OnActionRequiredCount); Assert.AreEqual(5, _players[p].OnGameEndCount); } }
public void Test_DeserializeHandWrittenWithSchema() { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); SessionSuiteCfg ssc = XmlSerializerExt.Deserialize <SessionSuiteCfg>( Path.Combine(testResourcesPath, "SessionSuiteCfg_Test.xml")); Assert.IsNotNull(ssc); Assert.AreEqual("Test Suite", ssc.Name); Assert.AreEqual(2, ssc.LocalPlayers.Length); Assert.AreEqual("RaiserBot1", ssc.LocalPlayers[0].Name); Assert.AreEqual("players.dll", ssc.LocalPlayers[0].Assembly.RawValue); Assert.AreEqual("players.RaiserBot", ssc.LocalPlayers[0].Type.RawValue); Assert.AreEqual(1, ssc.LocalPlayers[0].CreationParameters.Count); Assert.AreEqual("Some creation configuration", ssc.LocalPlayers[0].CreationParameters.Get("p1")); Assert.AreEqual(2, ssc.Sessions.Length); // Session 0 Assert.AreEqual("Ring Game", ssc.Sessions[0].Name); Assert.AreEqual(SessionKind.RingGame, ssc.Sessions[0].Kind); Assert.AreEqual(1000, ssc.Sessions[0].GamesCount); Assert.AreEqual(36, ssc.Sessions[0].RngSeed); Assert.AreEqual(2, ssc.Sessions[0].Players.Length); Assert.AreEqual("RaiserBot1", ssc.Sessions[0].Players[0].Name); Assert.AreEqual(2, ssc.Sessions[0].Players[0].SessionParameters.Count); Assert.AreEqual("v1", ssc.Sessions[0].Players[0].SessionParameters.Get("p1")); Assert.AreEqual("v2", ssc.Sessions[0].Players[0].SessionParameters.Get("p2")); Assert.AreEqual("GameDef1", ssc.Sessions[0].GameDefinition.Name); // Session 1 Assert.AreEqual(0, ssc.Sessions[1].RngSeed); Assert.AreEqual("GameDef2", ssc.Sessions[1].GameDefinition.Name); }
public void Test_CopyConstructor() { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); GameDefinition gd1; XmlSerializerExt.Deserialize(out gd1, Path.Combine(testResourcesPath, "gamedef-test.xml")); GameDefinition gd2 = new GameDefinition(gd1); Assert.AreEqual(gd1.Name, gd2.Name); Assert.AreEqual(gd1.RoundsCount, gd2.RoundsCount); Assert.AreEqual(gd1.MinPlayers, gd2.MinPlayers); Assert.AreEqual(gd1.MaxPlayers, gd2.MaxPlayers); Assert.AreEqual(gd1.BetStructure, gd2.BetStructure); Assert.AreEqual(gd1.BlindStructure, gd2.BlindStructure); Assert.AreEqual(gd1.PrivateCardsCount, gd2.PrivateCardsCount); Assert.AreEqual(gd1.PublicCardsCount, gd2.PublicCardsCount); Assert.AreEqual(gd1.SharedCardsCount, gd2.SharedCardsCount); Assert.AreEqual(gd1.BetsCountLimits, gd2.BetsCountLimits); Assert.AreEqual(gd1.FirstActor, gd2.FirstActor); Assert.AreEqual(gd1.FirstActorHeadsUp, gd2.FirstActorHeadsUp); Assert.AreEqual(gd1.LimitKind, gd2.LimitKind); Assert.AreEqual(gd1.DeckDescrFile, gd2.DeckDescrFile); Assert.AreEqual(gd1.DeckDescr, gd2.DeckDescr); Assert.AreEqual(gd1.GameRulesAssemblyFile, gd2.GameRulesAssemblyFile); Assert.AreEqual(gd1.GameRulesType, gd2.GameRulesType); Assert.AreEqual(gd1.GameRulesCreationParams, gd2.GameRulesCreationParams); Assert.AreEqual(gd1.GameRules, gd2.GameRules); }
public void Test_GetHandSizes() { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>(Path.Combine(testResourcesPath, "gamedef-test.xml")); int[] handSizes = gd.GetHandSizes(); Assert.AreEqual(new int [] { 2, 5, 6, 7 }, handSizes); }
public void Test_Convert() { GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>( Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/leduc-he.gamedef.xml")); string testDir = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); ChanceTree ct1 = CreateChanceTreeByGameDef.Create(gd); // DumpChanceTree.ToTxt(ct1, Console.Out); MemoryStream ms = new MemoryStream(); using (TextWriter tw = new StreamWriter(ms)) { DumpChanceTree.ToTxt(ct1, tw); } byte[] buf = ms.ToArray(); ms = new MemoryStream(buf); ChanceTree ct2; using (TextReader tr = new StreamReader(ms)) { ct2 = DumpChanceTree.FromTxt(tr); } Assert.AreEqual(ct1.Version, ct2.Version); Assert.AreEqual(ct1.NodesCount, ct2.NodesCount); int roundsCount = ct1.CalculateRoundsCount(); double[] potShare1 = new double[ct1.PlayersCount]; double[] potShare2 = new double[ct1.PlayersCount]; for (Int64 n = 0; n < ct2.NodesCount; ++n) { Assert.AreEqual(ct1.GetDepth(n), ct2.GetDepth(n)); Assert.AreEqual(ct1.Nodes[n].Position, ct2.Nodes[n].Position); Assert.AreEqual(ct1.Nodes[n].Card, ct2.Nodes[n].Card); Assert.AreEqual(ct1.Nodes[n].Probab, ct2.Nodes[n].Probab); if (ct1.GetDepth(n) == ct1.PlayersCount * roundsCount) { UInt16 [] activePlayerMasks = ActivePlayers.Get(ct1.PlayersCount, 2, ct1.PlayersCount); foreach (UInt16 ap in activePlayerMasks) { ct1.Nodes[n].GetPotShare(ap, potShare1); ct2.Nodes[n].GetPotShare(ap, potShare2); Assert.AreEqual(potShare1, potShare2); } } } }
public void Test_Compare() { GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>( Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/kuhn.gamedef.xml")); string testDir = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); string strFile = Path.Combine(testDir, "eq-KunhPoker-0-s.xml"); StrategyTree st0 = XmlToStrategyTree.Convert(strFile, gd.DeckDescr); StrategyTree st1 = XmlToStrategyTree.Convert(strFile, gd.DeckDescr); CompareStrategyTrees comparer = new CompareStrategyTrees { IsVerbose = true }; comparer.Compare(st0, st1); for (int p = 0; p < 2; ++p) { Assert.AreEqual(0, comparer.SumProbabDiff[p]); Assert.AreEqual(0, comparer.MaxProbabDiff[p]); Assert.AreEqual(0, comparer.AverageProbabDiff[p]); Assert.AreEqual(13, comparer.PlayerNodesCount[p]); } // Now change a probability Assert.IsTrue(st0.Nodes[4].Probab <= 0.9); Assert.IsTrue(st0.Nodes[9].Probab >= 0.1); st0.Nodes[4].Probab += 0.1; st0.Nodes[9].Probab -= 0.1; comparer.Compare(st0, st1); Assert.AreEqual(0.2, comparer.SumProbabDiff[0], 1e-8); Assert.AreEqual(0.1, comparer.MaxProbabDiff[0], 1e-8); Assert.AreEqual(0.2 / 13, comparer.AverageProbabDiff[0], 1e-8); Assert.AreEqual(13, comparer.PlayerNodesCount[0]); Assert.AreEqual(0, comparer.SumProbabDiff[1]); Assert.AreEqual(0, comparer.MaxProbabDiff[1]); Assert.AreEqual(0, comparer.AverageProbabDiff[1]); Assert.AreEqual(13, comparer.PlayerNodesCount[1]); }
public void Test_Convert() { GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>( Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/kuhn.gamedef.xml")); string testDir = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); string xmlFile = Path.Combine(testDir, "eq-KunhPoker-0-s.xml"); StrategyTree st1 = XmlToStrategyTree.Convert(xmlFile, gd.DeckDescr); //StrategyTreeDump.ToTxt(st1, Console.Out); MemoryStream ms = new MemoryStream(); using (TextWriter tw = new StreamWriter(ms)) { DumpStrategyTree.ToTxt(st1, tw); } byte[] buf = ms.ToArray(); ms = new MemoryStream(buf); StrategyTree st2; using (TextReader tr = new StreamReader(ms)) { st2 = DumpStrategyTree.FromTxt(tr); } Assert.AreEqual(st1.Version, st2.Version); Assert.AreEqual(st1.NodesCount, st2.NodesCount); for (Int64 n = 0; n < st2.NodesCount; ++n) { Assert.AreEqual(st1.GetDepth(n), st2.GetDepth(n)); Assert.AreEqual(st1.Nodes[n].Position, st2.Nodes[n].Position); Assert.AreEqual(st1.Nodes[n].IsDealerAction, st2.Nodes[n].IsDealerAction); if (st1.Nodes[n].IsDealerAction) { Assert.AreEqual(st1.Nodes[n].Card, st2.Nodes[n].Card); } else { Assert.AreEqual(st1.Nodes[n].Amount, st2.Nodes[n].Amount); Assert.AreEqual(st1.Nodes[n].Probab, st2.Nodes[n].Probab); } } }
public void Test_Game() { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); instance = this; SessionSuiteRunner = new SessionSuiteRunner(); SessionSuiteRunner.Configuration = XmlSerializerExt.Deserialize <SessionSuiteCfg>( Path.Combine(testResourcesPath, "SessionSuiteRunner_Test_2Players.Sessions.xml")); SessionSuiteRunner.Run(); int totalCardsCount = CalculateTotalCardsCount(); for (int p = 0; p < 2; ++p) { Assert.AreEqual(1, _players[p].OnGameBeginCount); Assert.AreEqual(1, _players[p].OnGameEndCount); } // Guest player did not play. Assert.AreEqual(0, _players[2].OnGameBeginCount); Assert.AreEqual(0, _players[2].OnGameEndCount); }
public void Test_Kuhn() { GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>( Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/kuhn.gamedef.xml")); string testDir = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); string xmlFile = Path.Combine(testDir, "eq-KunhPoker-0-s.xml"); StrategyTree st = XmlToStrategyTree.Convert(xmlFile, gd.DeckDescr); // Do some random checks Assert.AreEqual(false, st.Nodes[4].IsDealerAction); Assert.AreEqual(0, st.Nodes[4].Position); Assert.AreEqual(0.666666666666667, st.Nodes[4].Probab); Assert.AreEqual(false, st.Nodes[6].IsDealerAction); Assert.AreEqual(1, st.Nodes[6].Position); Assert.AreEqual(1, st.Nodes[6].Amount); Assert.AreEqual(true, st.Nodes[12].IsDealerAction); Assert.AreEqual(0, st.Nodes[12].Position); Assert.AreEqual(1, st.Nodes[12].Card); }
// Naming convention: // Log file : baseName.log // Zipped log file: baseName.zip // Session suite : baseName-ss.xml void Replay(string baseName) { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); string tempDir = Path.GetTempPath(); string configZip = Path.Combine(testResourcesPath, baseName + ".zip"); FastZip fz = new FastZip(); fz.ExtractZip(configZip, tempDir, FastZip.Overwrite.Always, null, "", "", true); string origLogPath = Path.Combine(tempDir, baseName + ".log"); string ssConfigFile = Path.Combine(testResourcesPath, baseName + "-ss.xml"); _ssRunner = new SessionSuiteRunner(); _ssRunner.Configuration = XmlSerializerExt.Deserialize <SessionSuiteCfg>(ssConfigFile); _ssRunner.IsLoggingEnabled = true; _ssRunner.LogDir = tempDir; // Replace XML path to the log being replayed with the actual path from the temp directory. _ssRunner.Configuration.Sessions[0].ReplayFrom = origLogPath; for (int p = 0; p < _ssRunner.Configuration.LocalPlayers.Length; ++p) { _ssRunner.Configuration.LocalPlayers[p].CreationParameters.Set("ReplayFrom", origLogPath); } _ssRunner.Run(); string hint; bool comparisonResult = GameLogComparer.Compare(_ssRunner.Configuration.Sessions[0].ReplayFrom.Get(Props.Global), _ssRunner.CurrentLogFile, out hint, int.MaxValue); Console.WriteLine("Original log:" + _ssRunner.Configuration.Sessions[0].ReplayFrom); Console.WriteLine("Replayed log:" + _ssRunner.CurrentLogFile); Console.WriteLine(hint); Assert.IsTrue(comparisonResult); }
void Plot3d(double [] c0, double [] s0, double [] p, double [] c1, double [] s1, bool areIntersecting, string testName) { double[] p1 = new double[3]; double p_2 = p[2] == 0 ? 0.01 : p[2]; p1[0] = -p[0] / p_2; p1[1] = -p[1] / p_2; p1[2] = -p[3] / p_2; string path = UTHelper.MakeAndGetTestOutputDir(Assembly.GetExecutingAssembly(), "geometry/CutAABB"); path = Path.Combine(path, testName + ".plt"); CultureInfo cultureInfoBackup = Thread.CurrentThread.CurrentCulture; // To format doubles, etc.. Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; int samples = p[2] == 0 ? 131 : 31; using (TextWriter tw = new StreamWriter(path)) { tw.WriteLine("# Header begin (same for all files) ----------------------------"); tw.WriteLine(""); tw.WriteLine(""); tw.WriteLine("set samples {0}, {0}", samples, samples); tw.WriteLine("set isosamples {0}, {0}", samples, samples); tw.WriteLine(""); tw.WriteLine("set xlabel \"x0\" "); tw.WriteLine("set xlabel offset character -3, -2, 0 font \"\" textcolor lt -1 norotate"); tw.WriteLine("set xrange [ -2.0 : 5.0 ] noreverse nowriteback"); tw.WriteLine(""); tw.WriteLine("set ylabel \"x1\" "); tw.WriteLine("set ylabel offset character 3, -2, 0 font \"\" textcolor lt -1 rotate by 90"); tw.WriteLine("set yrange [ -2.0000 : 5.0000 ] noreverse nowriteback"); tw.WriteLine(""); tw.WriteLine(""); tw.WriteLine("set zlabel \"x2\" "); tw.WriteLine("set zlabel offset character -5, 0, 0 font \"\" textcolor lt -1 norotate"); tw.WriteLine("set zrange [ -2.0000 : 5.0000 ] noreverse nowriteback"); tw.WriteLine(""); tw.WriteLine(""); tw.WriteLine("set xyplane at 0"); tw.WriteLine(""); tw.WriteLine("set dummy x0, x1"); tw.WriteLine(""); tw.WriteLine("# To draw a cross in a center"); tw.WriteLine("cdelta = 0.01"); tw.WriteLine(""); tw.WriteLine("# ----------------- AABB P0 --------------------"); tw.WriteLine(""); tw.WriteLine("s0_0 = {0}", s0[0]); tw.WriteLine("s0_1 = {0}", s0[1]); tw.WriteLine("s0_2 = {0}", s0[2]); tw.WriteLine(""); tw.WriteLine("c0_0 = {0}", c0[0]); tw.WriteLine("c0_1 = {0}", c0[1]); tw.WriteLine("c0_2 = {0}", c0[2]); tw.WriteLine(""); tw.WriteLine("set label \"c0_0\" at c0_0 + 2*cdelta, c0_1 + 2*cdelta, c0_2 + 2*cdelta"); tw.WriteLine(""); tw.WriteLine("# Center "); tw.WriteLine("set style line 1 linewidth 2"); tw.WriteLine("set style arrow 1 nohead linestyle 1 linecolor rgb \"red\""); tw.WriteLine("set arrow from c0_0-cdelta, c0_1, c0_2 to c0_0+cdelta, c0_1, c0_2 arrowstyle 1"); tw.WriteLine("set arrow from c0_0, c0_1-cdelta, c0_2 to c0_0, c0_1+cdelta, c0_2 arrowstyle 1"); tw.WriteLine("set arrow from c0_0, c0_1, c0_2-cdelta to c0_0, c0_1, c0_2+cdelta arrowstyle 1"); tw.WriteLine(""); tw.WriteLine(""); tw.WriteLine("# AABB"); tw.WriteLine("set style line 2 linetype -1 linewidth 4"); tw.WriteLine("set style arrow 2 nohead linestyle 2 linecolor rgb \"red\""); tw.WriteLine(""); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1-s0_1, c0_2-s0_2 to c0_0+s0_0, c0_1-s0_1, c0_2-s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1-s0_1, c0_2-s0_2 to c0_0-s0_0, c0_1-s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1-s0_1, c0_2+s0_2 to c0_0+s0_0, c0_1-s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0+s0_0, c0_1-s0_1, c0_2-s0_2 to c0_0+s0_0, c0_1-s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1+s0_1, c0_2-s0_2 to c0_0+s0_0, c0_1+s0_1, c0_2-s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1+s0_1, c0_2-s0_2 to c0_0-s0_0, c0_1+s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1+s0_1, c0_2+s0_2 to c0_0+s0_0, c0_1+s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0+s0_0, c0_1+s0_1, c0_2-s0_2 to c0_0+s0_0, c0_1+s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1-s0_1, c0_2-s0_2 to c0_0-s0_0, c0_1+s0_1, c0_2-s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0+s0_0, c0_1-s0_1, c0_2-s0_2 to c0_0+s0_0, c0_1+s0_1, c0_2-s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0-s0_0, c0_1-s0_1, c0_2+s0_2 to c0_0-s0_0, c0_1+s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine( "set arrow from c0_0+s0_0, c0_1-s0_1, c0_2+s0_2 to c0_0+s0_0, c0_1+s0_1, c0_2+s0_2 arrowstyle 2"); tw.WriteLine(""); if (areIntersecting) { tw.WriteLine("# ----------------- AABB P1 --------------------"); tw.WriteLine(""); tw.WriteLine("s1_0 = {0}", s1[0]); tw.WriteLine("s1_1 = {0}", s1[1]); tw.WriteLine("s1_2 = {0}", s1[2]); tw.WriteLine(""); tw.WriteLine("c1_0 = {0}", c1[0]); tw.WriteLine("c1_1 = {0}", c1[1]); tw.WriteLine("c1_2 = {0}", c1[2]); tw.WriteLine(""); tw.WriteLine("set label \"c1_0\" at c1_0 + 2*cdelta, c1_1 + 2*cdelta, c1_2 + 2*cdelta"); tw.WriteLine(""); tw.WriteLine("# Center "); tw.WriteLine("set style line 3 linetype -1 linewidth 1"); tw.WriteLine("set style arrow 3 nohead linestyle 3 linecolor rgb \"blue\""); tw.WriteLine("set arrow from c1_0-cdelta, c1_1, c1_2 to c1_0+cdelta, c1_1, c1_2 arrowstyle 3"); tw.WriteLine("set arrow from c1_0, c1_1-cdelta, c1_2 to c1_0, c1_1+cdelta, c1_2 arrowstyle 3"); tw.WriteLine("set arrow from c1_0, c1_1, c1_2-cdelta to c1_0, c1_1, c1_2+cdelta arrowstyle 3"); tw.WriteLine(""); tw.WriteLine(""); tw.WriteLine("# AABB"); tw.WriteLine("set style line 4 linetype -1 linewidth 2"); tw.WriteLine("set style arrow 4 nohead linestyle 4 linecolor rgb \"blue\""); tw.WriteLine(""); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1-s1_1, c1_2-s1_2 to c1_0+s1_0, c1_1-s1_1, c1_2-s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1-s1_1, c1_2-s1_2 to c1_0-s1_0, c1_1-s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1-s1_1, c1_2+s1_2 to c1_0+s1_0, c1_1-s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0+s1_0, c1_1-s1_1, c1_2-s1_2 to c1_0+s1_0, c1_1-s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1+s1_1, c1_2-s1_2 to c1_0+s1_0, c1_1+s1_1, c1_2-s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1+s1_1, c1_2-s1_2 to c1_0-s1_0, c1_1+s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1+s1_1, c1_2+s1_2 to c1_0+s1_0, c1_1+s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0+s1_0, c1_1+s1_1, c1_2-s1_2 to c1_0+s1_0, c1_1+s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1-s1_1, c1_2-s1_2 to c1_0-s1_0, c1_1+s1_1, c1_2-s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0+s1_0, c1_1-s1_1, c1_2-s1_2 to c1_0+s1_0, c1_1+s1_1, c1_2-s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0-s1_0, c1_1-s1_1, c1_2+s1_2 to c1_0-s1_0, c1_1+s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine( "set arrow from c1_0+s1_0, c1_1-s1_1, c1_2+s1_2 to c1_0+s1_0, c1_1+s1_1, c1_2+s1_2 arrowstyle 4"); tw.WriteLine(""); } tw.WriteLine("# ----------------- Vector p(x) < 0 ----------------- "); tw.WriteLine("set style line 5 linetype -1 linewidth 2"); tw.WriteLine("set style arrow 5 linestyle 5 linecolor rgb \"green\""); tw.WriteLine(""); tw.WriteLine( "set arrow from c0_0, c0_1, c0_2 to c0_0-{0}, c0_1-{1}, c0_2-{2} arrowstyle 5", p[0], p[1], p[2]); tw.WriteLine(""); tw.WriteLine("# ----------------- Plane --------------------"); tw.WriteLine(""); tw.WriteLine("cut(x0, x1) = {0}*x0 + {1}*x1 + {2}", p1[0], p1[1], p1[2]); tw.WriteLine(""); tw.WriteLine("splot cut(x0, x1) with lines 2"); tw.WriteLine(""); } Thread.CurrentThread.CurrentCulture = cultureInfoBackup; }
public void Test_XmlSerialization() { SessionSuiteCfg ssc1 = new SessionSuiteCfg(); string testResDir = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); ssc1.Name = "Suite1"; ssc1.LocalPlayers = new LocalPlayerCfg[2] { new LocalPlayerCfg { Assembly = "Players.dll", Type = "SuperBot", Name = "SuperBot1", CreationParameters = new string[] { "Param1", "1" } }, new LocalPlayerCfg { Assembly = "Players.dll", Type = "PuperBot", Name = "PuperBot1", CreationParameters = new Dictionary <string, string> { { "Param1", "2" } } } }; ssc1.Sessions = new SessionCfg[2] { new SessionCfg("Ring Game", SessionKind.RingGame, testResDir + "SessionSuiteCfg_Test.Gamedef1.xml"), new SessionCfg("Ring Game With Seat Permutation", SessionKind.RingGameWithSeatPermutations, testResDir + "SessionSuiteCfg_Test.Gamedef1.xml") }; ssc1.Sessions[0].GamesCount = 1000; ssc1.Sessions[0].Players = new PlayerSessionCfg[] { new PlayerSessionCfg { Name = "SuperBot1", SessionParameters = new Dictionary <string, string> { { "p1", "v1" } } }, new PlayerSessionCfg { Name = "PuperBot1", SessionParameters = new Dictionary <string, string> { { "p1", "v1" } } } }; ssc1.Sessions[1].GamesCount = 100; ssc1.Sessions[1].Players = new PlayerSessionCfg[] { new PlayerSessionCfg { Name = "SuperBot1", SessionParameters = new Dictionary <string, string> { { "p1", "v1" } } }, new PlayerSessionCfg { Name = "PuperBot1", SessionParameters = new Dictionary <string, string> { { "p1", "v1" } } } }; StringBuilder sb = new StringBuilder(); using (TextWriter tw = new StringWriter(sb)) { ssc1.XmlSerialize(tw); } Console.WriteLine(sb.ToString()); SessionSuiteCfg rc2; using (TextReader textReader = new StringReader(sb.ToString())) { XmlSerializerExt.Deserialize(out rc2, textReader); } Assert.IsNotNull(rc2); }