Exemplo n.º 1
0
        void OnNodeEnd(ChanceTree tree, Context[] stack, int depth)
        {
            Context context = stack[depth];
            Int64   n       = context.NodeIdx;

            if (context.IsLeaf)
            {
                // Do for 2 players now
                UInt32[] ranks     = new UInt32[_gd.MinPlayers];
                double[] inpot     = new double[_gd.MinPlayers];
                double[] expResult = new double[_gd.MinPlayers];
                int[][]  hands     = new int[_gd.MinPlayers][];

                double inPotOfEachPlayer = 1.0 / _gd.MinPlayers;
                for (int p = 0; p < _gd.MinPlayers; ++p)
                {
                    inpot[p] = inPotOfEachPlayer;
                    hands[p] = context.Hands[p].ToArray();
                }

                _gd.GameRules.Showdown(_gd, hands, ranks);
                Showdown.CalcualteHi(inpot, ranks, expResult, 0);

                double [] potShare = new double[_gd.MinPlayers];
                tree.Nodes[n].GetPotShare(0x3, potShare);
                for (int p = 0; p < _gd.MinPlayers; ++p)
                {
                    double actualResult = potShare[p] - inPotOfEachPlayer;
                    Assert.AreEqual(expResult[p], actualResult);
                }
                _verifyLeaf(tree, context);
            }
        }
Exemplo n.º 2
0
        public void Test_CalculateHi_ManyPlayers()
        {
            double[] inpot, result;
            UInt32[] ranks;

            inpot  = new double[] { 3, 7, 1, 8, 6, 1, 4 };
            ranks  = new UInt32[] { 3, 2, 0, 4, 4, 0, 9 };
            result = new double[7];
            Showdown.CalcualteHi(inpot, ranks, result, 0);
            Assert.AreEqual(new double[] { -3, -7, -1, -2, -3, -1, 17 }, result);

            inpot  = new double[] { 3, 7, 1, 8, 6, 0, 1, 4 };
            ranks  = new UInt32[] { 3, 2, 0, 4, 4, 0, 0, 9 };
            result = new double[8];
            Showdown.CalcualteHi(inpot, ranks, result, 0);
            Assert.AreEqual(new double[] { -3, -7, -1, -2, -3, 0, -1, 17 }, result);
        }