Ejemplo n.º 1
0
        void PlayRingGameSessionWithSeatPermutations(int rngSeed)
        {
            List <PlayerData>  initialPlacement = new List <PlayerData>(_sessionPlayers);
            List <List <int> > permuts          = EnumAlgos.GetPermut(_sessionPlayers.Count);

            foreach (List <int> permut in permuts)
            {
                string permutText = "";
                for (int i = 0; i < permut.Count; ++i)
                {
                    _sessionPlayers[i] = initialPlacement[permut[i]];
                    permutText        += " " + permut[i].ToString();
                }
                if (IsLoggingEnabled)
                {
                    _gameLog.WriteLine(">SeatPermutation Positions=\'{0}\'", permutText.Substring(1));
                    _gameLog.Flush();
                }

                Props pm = new Props();
                pm.Set("pkr.ForgetAll", "true");

                foreach (PlayerData sessionPlayer in _sessionPlayers)
                {
                    sessionPlayer.iplayer.OnSessionEvent(pm);
                }

                PlaySimpleSession(rngSeed);
            }
        }
Ejemplo n.º 2
0
        public void Test_GetPermut()
        {
            int expCount = 1;

            for (int n = 1; n < 7; ++n)
            {
                expCount *= n;
                List <List <int> > permuts = EnumAlgos.GetPermut(n);
                VerifyPermut(permuts, n, expCount);
            }
        }
Ejemplo n.º 3
0
        public void SortSuitesCodeGenerator()
        {
            List <List <int> > perms = EnumAlgos.GetPermut(4);

            for (int i = 0; i < perms.Count; ++i)
            {
                Console.Write("{");
                for (int j = 0; j < 4; ++j)
                {
                    if (j != 0)
                    {
                        Console.Write(",");
                    }
                    Console.Write(" {0}", perms[i][j]);
                }
                Console.WriteLine("}}, // {0,2}", i);
            }
            Generate(perms, perms, "");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generates all possible hands containing given suites,
        /// normalizes and verifies them.
        /// </summary>
        private void TestPermutations(uint s3, uint s2, uint s1, uint s0)
        {
            uint[] arr = new uint[] { s0, s1, s2, s3 };
            Array.Sort(arr);
            CardSet            expected = FromSuits(arr[0], arr[1], arr[2], arr[3]);
            List <List <int> > perms    = EnumAlgos.GetPermut(4);

            for (int i = 0; i < perms.Count; ++i)
            {
                // Console.WriteLine("Permutation: {0}", i);
                NormSuit sn        = new NormSuit();
                CardSet  orig      = FromSuits(arr[perms[i][0]], arr[perms[i][1]], arr[perms[i][2]], arr[perms[i][3]]);
                CardSet  converted = sn.Convert(orig);
                Assert.AreEqual(expected, converted);
                // Make sure result is consistent.
                converted = sn.Convert(orig);
                Assert.AreEqual(expected, converted);
                // Make sure self is converted to self with a new normalizers
                // (because it is already sorted).
                NormSuit sn2 = new NormSuit();
                converted = sn2.Convert(converted);
                Assert.AreEqual(expected, converted);
            }
        }