Ejemplo n.º 1
0
        public Odds RunTrails(int NumberOfTrails)
        {
            int         x, n, missingCardsOnStreet = 5 - street.Count;
            int         wins = 0, loses = 0, draws = 0, result;
            FastWinCalc winCalc = new FastWinCalc();
            Card        NewCard = new Card(0);
            List <Card> trailStreet = new List <Card>(), opponantTrailCards = new List <Card>(), CardsInPlay, aiTrailCards;

            for (x = 0; x < NumberOfTrails; x++)
            {
                trailStreet = new List <Card>(street);
                CardsInPlay = street.Concat(aiHand).ToList();

                for (n = 0; n < missingCardsOnStreet; n++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    trailStreet.Add(NewCard);
                }

                aiTrailCards       = aiHand.Concat(trailStreet).ToList();
                opponantTrailCards = trailStreet;

                for (n = 0; n < 2; n++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    opponantTrailCards.Add(NewCard);
                }

                //forced to add to opponent hand
                //opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.King));
                //opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.Ace));

                result = winCalc.WhoWins(aiTrailCards, opponantTrailCards);

                if (result == 1)
                {
                    loses++;
                }
                else if (result == -1)
                {
                    wins++;
                }
                else
                {
                    draws++;
                }

                CardsInPlay.Clear();
                opponantTrailCards.Clear();
                aiTrailCards.Clear();
            }

            Odds Results = new Odds((double)wins / (double)NumberOfTrails * 100,
                                    (double)loses / (double)NumberOfTrails * 100,
                                    (double)draws / (double)NumberOfTrails * 100);

            PrintResults(Results);

            return(Results);
        }
Ejemplo n.º 2
0
        private void NewCards()
        {
            Player1Cards.Clear();
            Player2Cards.Clear();
            Street.Clear();
            CardsInPlay.Clear();

            AiDrawGuessLabel.Visible    = false;
            AiPlayer1GuessLabel.Visible = false;
            AiPlayer2GuessLabel.Visible = false;

            if (RandomPlayerCards)
            {
                for (int x = 0; x < 2; x++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    Player1Cards.Add(NewCard);
                }

                for (int x = 0; x < 2; x++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    Player2Cards.Add(NewCard);
                }
            }
            else
            {
                Player1Cards.Add(new Card(Suit.Hearts, Rank.Ace));
                Player1Cards.Add(new Card(Suit.Spades, Rank.Ace));
                CardsInPlay.Add(Player1Cards[0]);
                CardsInPlay.Add(Player1Cards[1]);

                Player2Cards.Add(new Card(Suit.Diamonds, Rank.Ace));
                Player2Cards.Add(new Card(Suit.Diamonds, Rank.King));
                CardsInPlay.Add(Player2Cards[0]);
                CardsInPlay.Add(Player2Cards[1]);
            }

            for (int x = 0; x < 5; x++)
            {
                NewCard = new Card(CardsInPlay);
                CardsInPlay.Add(NewCard);
                Street.Add(NewCard);
            }

            foreach (Card card in CardsInPlay)
            {
                card.LoadImage();
            }

            Player1pictureBox1.Image = Player1Cards[0].Image;
            Player1pictureBox2.Image = Player1Cards[1].Image;

            Player2pictureBox1.Image = Player2Cards[0].Image;
            Player2pictureBox2.Image = Player2Cards[1].Image;

            StreetCard1ImageBox.Image = Street[0].Image;
            StreetCard2ImageBox.Image = Street[1].Image;
            StreetCard3ImageBox.Image = Street[2].Image;
            StreetCard4ImageBox.Image = Street[3].Image;
            StreetCard5ImageBox.Image = Street[4].Image;

            AiResult = winCalc.WhoWins(Player1Cards.Concat(Street).ToList(), Player2Cards.Concat(Street).ToList());
        }
Ejemplo n.º 3
0
        public Odds RunTrails(int NumberOfTrails, List <List <Card> > Range)
        {
            int         x, n, missingCardsOnStreet = 5 - street.Count;
            int         wins = 0, loses = 0, draws = 0, result;
            FastWinCalc winCalc = new FastWinCalc();
            Card        NewCard = new Card(0);
            List <Card> trailStreet = new List <Card>(), opponantTrailCards = new List <Card>(), CardsInPlay, aiTrailCards;
            int         RangeSize;

            RangeSize = Range.Count();

            for (x = 0; x < NumberOfTrails; x++)
            {
                trailStreet = new List <Card>(street);
                CardsInPlay = street.Concat(aiHand).ToList();

                for (n = 0; n < missingCardsOnStreet; n++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    trailStreet.Add(NewCard);
                }

                aiTrailCards       = aiHand.Concat(trailStreet).ToList();
                opponantTrailCards = trailStreet;

                if (RangeSize > 1)
                {
                    x = rndNr.Next(RangeSize);

                    opponantTrailCards.Add(Range[x][0]);
                    opponantTrailCards.Add(Range[x][1]);
                }
                else
                {
                    opponantTrailCards.Add(Range[0][0]);
                    opponantTrailCards.Add(Range[0][1]);
                }


                result = winCalc.WhoWins(aiTrailCards, opponantTrailCards);

                if (result == 1)
                {
                    loses++;
                }
                else if (result == -1)
                {
                    wins++;
                }
                else
                {
                    draws++;
                }

                CardsInPlay.Clear();
                opponantTrailCards.Clear();
                aiTrailCards.Clear();
            }

            Odds Results = new Odds((double)wins / (double)NumberOfTrails * 100,
                                    (double)loses / (double)NumberOfTrails * 100,
                                    (double)draws / (double)NumberOfTrails * 100);

            PrintResults(Results);

            return(Results);
        }
Ejemplo n.º 4
0
        public Odds TestRunTrails(int NumberOfTrails)
        {
            int           x, n, missingCardsOnStreet = 5 - street.Count;
            int           wins = 0, loses = 0, draws = 0, result;
            WinConditions winCalc = new WinConditions();
            Card          NewCard = new Card(0);
            List <Card>   trailStreet = new List <Card>(), opponantTrailCards = new List <Card>(), CardsInPlay, aiTrailCards;
            List <Player> players = new List <Player>()
            {
                new Player(0, 1000), new Player(1, 1000)
            };

            for (x = 0; x < NumberOfTrails; x++)
            {
                trailStreet = new List <Card>(street);
                CardsInPlay = street.Concat(aiHand).ToList();

                for (n = 0; n < missingCardsOnStreet; n++)
                {
                    NewCard = new Card(CardsInPlay);
                    CardsInPlay.Add(NewCard);
                    trailStreet.Add(NewCard);
                }

                aiTrailCards       = aiHand.Concat(trailStreet).ToList();
                opponantTrailCards = trailStreet;

                /*
                 * for (n = 0; n < 2; n++)
                 * {
                 *  NewCard = new Card(CardsInPlay);
                 *  CardsInPlay.Add(NewCard);
                 *  opponantTrailCards.Add(NewCard);
                 * }
                 */


                //forced to add to opponent hand
                opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.King));
                opponantTrailCards.Add(new Card(Suit.Diamonds, Rank.Ace));
                players[0].Cards = opponantTrailCards;
                players[1].Cards = aiTrailCards;
                players[0].Cards.Sort();
                players[1].Cards.Sort();
                players[0].Score = winCalc.Evaluate(players[0].Cards);
                players[1].Score = winCalc.Evaluate(players[1].Cards);
                winCalc.GiveScoreHand(players[0]);
                winCalc.GiveScoreHand(players[1]);

                if (players[0].Score > players[1].Score)
                {
                    loses++;
                }
                else if (players[0].Score < players[1].Score)
                {
                    wins++;
                }
                else
                {
                    if (winCalc.WhoWins(players[0], players[1]) == null)
                    {
                        draws++;
                    }
                    else if (winCalc.WhoWins(players[0], players[1]).Id == 1)
                    {
                        wins++;
                    }
                    else
                    {
                        loses++;
                    }
                }

                CardsInPlay.Clear();
                opponantTrailCards.Clear();
                aiTrailCards.Clear();
            }

            Odds Results = new Odds((double)wins / (double)NumberOfTrails * 100,
                                    (double)loses / (double)NumberOfTrails * 100,
                                    (double)draws / (double)NumberOfTrails * 100);

            Console.WriteLine("Wins: {0} , Loses: {1} , Draws: {2}", wins, loses, draws);
            PrintResults(Results);
            Console.WriteLine("");

            return(Results);
        }