예제 #1
0
        public void TrainOneSpecificHand()
        {
            var dealer = new DeterministicDealer();

            dealer.HoleCardsPlayer1 = new List <Card> {
                new Card(CardSuit.Diamonds, CardValue.Ace), new Card(CardSuit.Clubs, CardValue.Ace)
            };
            dealer.HoleCardsPlayer2 = new List <Card> {
                new Card(CardSuit.Hearts, CardValue.Seven), new Card(CardSuit.Clubs, CardValue.Two)
            };
            dealer.BoardCards = new List <Card> {
                new Card(CardSuit.Diamonds, CardValue.Two),
                new Card(CardSuit.Diamonds, CardValue.Three),
                new Card(CardSuit.Diamonds, CardValue.Four),
                new Card(CardSuit.Spades, CardValue.Jack),
                new Card(CardSuit.Spades, CardValue.Queen)
            };

            trainer = new TexasHoldemTrainer(dealer);
            trainer.Train(1);
            foreach (var node in trainer.GameNodes)
            {
                Debug.WriteLine(node.Value);
            }
        }
예제 #2
0
        private static void train()
        {
            var dealer             = new RandomDealer();
            var trainer            = new TexasHoldemTrainer(dealer);
            int numberOfTrainings  = 10000;
            int handsPerTraining   = 100;
            int handsCounter       = 0;
            int numberOfTotalhands = numberOfTrainings * handsPerTraining;
            var trainedTree        = loadSnapShot();

            if (trainedTree != null)
            {
                trainer.GameNodes = trainedTree;
            }

            var stopwatch = new Stopwatch();

            for (int i = 0; i < numberOfTrainings; i++)
            {
                stopwatch.Restart();
                trainer.Train(handsPerTraining);
                double duration = stopwatch.Elapsed.TotalSeconds;
                handsCounter += handsPerTraining;
                var msg = string.Format("{0}/{1} hands trained in {2}s. ", handsCounter, numberOfTotalhands, duration);
                takeSnapShot(trainer.GameNodes, "cfr-tree.proto");
                log(msg);
            }
        }