Esempio n. 1
0
        public void Test_CreateCt()
        {
            int oppCount = 2;
            var pockets  = PocketHelper.GetAllPockets();
            //var pockets = new HePocketKind[] { HePocketKind._AA, HePocketKind._76s, HePocketKind._72o };
            var pocketDist = PocketHelper.GetProbabDistr(pockets);

            double[,] ptPeMax = MultiplayerPocketProbability.ComputePreferenceMatrixPeMax(pockets);


            string     xmlAt = Props.Global.Expand("${bds.DataDir}ai.pkr.holdem.learn/nlpf-1.xml");
            ActionTree at    = XmlToActionTree.Convert(xmlAt);

            string[] actionLabels = CreateActionLabels(at, 0);
            Dictionary <string, int> actionLabelToId = new Dictionary <string, int>();

            for (int i = 0; i < actionLabels.Length; ++i)
            {
                actionLabelToId.Add(actionLabels[i], i);
            }

            double[]   oppDist = MultiplayerPocketProbability.Compute(oppCount, pocketDist, ptPeMax);
            ChanceTree ct      = PreflopStrategy.CreateCt(pockets, oppDist);


            //GameDefinition gd = XmlSerializerExt.Deserialize<GameDefinition>(Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/${0}", "kuhn.gamedef.xml"));
            //at = CreateActionTreeByGameDef.Create(gd);
            //ct = CreateChanceTreeByGameDef.Create(gd);

            VisChanceTree.Show(ct, Path.Combine(_outDir, "ct.gv"));
            VisActionTree.Show(at, Path.Combine(_outDir, "at.gv"));

            StrategyTree[] st = SolveAndVerifyVerifySolution(at, ct, 0.001, false);

            double[,] fs = FlattenStrategy(st[0], 0, pockets.Length, actionLabelToId);

            Console.WriteLine("Result for opponent count: {0}", oppCount);
            Console.Write("{0,4}", oppCount);
            foreach (string al in actionLabels)
            {
                Console.Write("{0,20}", al);
            }
            Console.WriteLine();
            int raiseCount = 0;

            for (int c = 0; c < pockets.Length; ++c)
            {
                Console.Write("{0,4}", HePocket.KindToString(pockets[c]));
                for (int j = 0; j < actionLabels.Length; ++j)
                {
                    Console.Write("{0,20}", Math.Round(fs[c, j] * 100, 0));
                }
                if (fs[c, actionLabels.Length - 1] > 0.9)
                {
                    raiseCount += HePocket.KindToRange(pockets[c]).Length;
                }
                Console.WriteLine();
            }
            Console.WriteLine("Raise count: {0}", raiseCount);
        }
        public void Test_CallKK()
        {
            string outDir = Path.Combine(_outDir, "call-KK");

            Directory.CreateDirectory(outDir);
            HePocketKind[] sbPockets = new HePocketKind[] { HePocketKind._AA, HePocketKind._KK, HePocketKind._AKs };
            HePocketKind[] bbPockets = new HePocketKind[] { HePocketKind._AA, HePocketKind._KK, HePocketKind._QQ, HePocketKind._AKs };

            string     xmlAt = Props.Global.Expand("${bds.DataDir}ai.pkr.holdem.learn/bigcards-pf-1.xml");
            ActionTree at    = XmlToActionTree.Convert(xmlAt);

            VisActionTree.Show(at, Path.Combine(outDir, "at.gv"));

            BigCardsPreflop bc = new BigCardsPreflop();

            bc.Solve(at, sbPockets, bbPockets);

            Console.WriteLine("Game values: {0}, {1}", bc.GameValues[0], bc.GameValues[1]);
            VisChanceTree.Show(bc.Ct, Path.Combine(outDir, "ct.gv"));
            VisStrategyTree.Show(bc.Strategies[0], Path.Combine(outDir, "st-0.gv"));
            VisStrategyTree.Show(bc.Strategies[1], Path.Combine(outDir, "st-1.gv"));
        }