Ejemplo n.º 1
0
        private static void AssertDrawPileIsRandom(Board board)
        {
            Card       previousCard = null;
            RunCounter rcInc        = new RunCounter();
            RunCounter rcDec        = new RunCounter();
            RunCounter rcEqual      = new RunCounter();

            foreach (Card card in board.DrawPile)
            {
                if (previousCard == null)
                {
                    rcInc.Extend(true);
                    rcDec.Extend(true);
                    rcEqual.Extend(true);
                }
                else
                {
                    rcInc.Extend(previousCard.Value == card.Value - 1);
                    rcDec.Extend(previousCard.Value == card.Value + 1);
                    rcEqual.Extend(previousCard.Value == card.Value);
                }

                previousCard = card;
            }

            Debug.WriteLine("DrawPile Max ascending sequence is " + rcInc.Max);
            Debug.WriteLine("DrawPile Max descending sequence is " + rcDec.Max);
            Debug.WriteLine("DrawPile Max equal sequence is " + rcEqual.Max);
            Debug.WriteLine("Deck is " + board.DrawPile);
            // Probability of 4 in a row is 1/12^4 or about one in 20,000 cards
            if (rcInc.Max > 4 || rcDec.Max > 4 || rcEqual.Max > 4)
            {
                Assert.Fail("DrawPile is not random.");
            }
        }
Ejemplo n.º 2
0
        private static void AssertDrawPileIsRandom(Board board)
        {
            Card previousCard = null;
            RunCounter rcInc = new RunCounter();
            RunCounter rcDec = new RunCounter();
            RunCounter rcEqual = new RunCounter();

            foreach (Card card in board.DrawPile)
            {
                if (previousCard == null)
                {
                    rcInc.Extend(true);
                    rcDec.Extend(true);
                    rcEqual.Extend(true);
                }
                else
                {
                    rcInc.Extend(previousCard.Value == card.Value - 1);
                    rcDec.Extend(previousCard.Value == card.Value + 1);
                    rcEqual.Extend(previousCard.Value == card.Value);
                }

                previousCard = card;
            }

            Debug.WriteLine("DrawPile Max ascending sequence is " + rcInc.Max);
            Debug.WriteLine("DrawPile Max descending sequence is " + rcDec.Max);
            Debug.WriteLine("DrawPile Max equal sequence is " + rcEqual.Max);
            Debug.WriteLine("Deck is " + board.DrawPile);
            // Probability of 4 in a row is 1/12^4 or about one in 20,000 cards
            if (rcInc.Max > 4 || rcDec.Max > 4 || rcEqual.Max > 4)
            {
                Assert.Fail("DrawPile is not random.");
            }
        }