public void Test_AnalyzeS()
        {
            GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>(
                Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/kuhn.gamedef.xml"));

            string[] strategyFiles = new string[] { "eq-KunhPoker-0-s.xml", "eq-KunhPoker-1-s.xml" };
            for (int pos = 0; pos < 2; ++pos)
            {
                string       strFile = Path.Combine(_testResDir, strategyFiles[pos]);
                StrategyTree st      = XmlToStrategyTree.Convert(strFile, gd.DeckDescr);
                VisStrategyTree.Show(st, Path.Combine(_outDir, string.Format("{0}-{1}.gv", gd.Name, pos)));
                AnalyzeStrategyTree an = new AnalyzeStrategyTree
                {
                    StrategyTree = st,
                    IsAbsolute   = true,
                    HeroPosition = pos,
                    IsVerbose    = true
                };
                an.Analyze();
                Assert.AreEqual(15, an.LeavesCount);
                if (pos == 0)
                {
                    Assert.AreEqual(12, an.MovesCount);
                    Assert.AreEqual(5, an.ZaspMovesCount);
                    Assert.AreEqual(3, an.ZaspLeavesCount);
                    Assert.AreEqual(1, an.Statistics.Count);
                    Assert.AreEqual(5, an.Statistics[0].NZaspMovesCount);
                    Assert.AreEqual(1 + 0.33333, an.Statistics[0].SumNZaspFold, 0.00001);
                    Assert.AreEqual(0.66667 + 1 + 0.66667, an.Statistics[0].SumNZaspCall, 0.00001);
                    Assert.AreEqual(0.33333 + 1, an.Statistics[0].SumNZaspRaise, 0.00001);
                }
                else
                {
                    Assert.AreEqual(12, an.MovesCount);
                    Assert.AreEqual(4, an.ZaspMovesCount);
                    Assert.AreEqual(3, an.ZaspLeavesCount);
                    Assert.AreEqual(1, an.Statistics.Count);
                    Assert.AreEqual(6, an.Statistics[0].NZaspMovesCount);
                    Assert.AreEqual(1 + 0.66667, an.Statistics[0].SumNZaspFold, 0.00001);
                    Assert.AreEqual(0.66667 + 1 + 0.33333 + 1, an.Statistics[0].SumNZaspCall, 0.00001);
                    Assert.AreEqual(0.33333 + 1, an.Statistics[0].SumNZaspRaise, 0.00001);
                }
            }
        }
Ejemplo n.º 2
0
        static int Main(string[] args)
        {
            if (!Parser.ParseArgumentsWithUsage(args, _cmdLine))
            {
                return(1);
            }

            if (_cmdLine.DebuggerLaunch)
            {
                Debugger.Launch();
            }

            StrategyTree st = StrategyTree.Read <StrategyTree>(_cmdLine.StrategyTree);

            if (_cmdLine.Verify)
            {
                string error = "";
                bool   isOk  = true;
                if (_cmdLine.IsAbsolute)
                {
                    Console.Write("Verifying absolute strategy ...");
                    isOk = VerifyAbsStrategy.Verify(st, _cmdLine.HeroPosition, 1e-7, out error);
                }
                else
                {
                    Console.Write("Verifying conditional strategy ...");
                    isOk = VerifyCondStrategy.Verify(st, _cmdLine.HeroPosition, 1e-7, out error);
                }
                if (isOk)
                {
                    Console.WriteLine(" OK");
                }
                else
                {
                    Console.WriteLine(" Verification failed: {0}", error);
                    return(1);
                }
            }

            AnalyzeStrategyTree.AnalyzeS(st, _cmdLine.IsAbsolute, _cmdLine.HeroPosition);

            return(0);
        }