Ejemplo n.º 1
1
        /// <summary>
        /// Given S and B = B(S), verify that B is the best strategy against S.
        /// Procedure: Verify EV(B', S) is less than EV(B, S) for all other strategies B'.
        /// </summary>
        public static void B_Test(PocketRoot root)
        {
            number EV;

            // Calculate Strategy B = B(S)
            EV = root.BestAgainstS();

            // Calculate EV(B', S) for many B'
            double Min = double.MaxValue;
            for (int k = 0; k < 10000; k++)
            {
                // Pure passive
                //root.Process(Node.VarB, (n, i) => (number)0);

                // Pure aggressive
                //root.Process(Node.VarB, (n, i) => (number)1);

                // Totally randomize
                //root.Process(Node.VarB, (n, i) => (number)(Tools.Rnd.NextDouble()));

                // Random perturbation
                //root.Process(Node.VarB, (n, i) => n.B[i] + (number)((Tools.Rnd.NextDouble() - .5f) * .1f));

                // Random raise
                root.Process(Node.VarB, (n, i) => n.B[i] + (number)(Tools.Rnd.NextDouble() > .85 ? 1 : 0));

                // Random fold
                //root.Process(Node.VarB, (n, i) => n.B[i] + (number)(Tools.Rnd.NextDouble() > .99 ? -1 : 0));

                // Full simulation
                //number ModdedEV = Simulation(Node.VarB, Node.VarS, root);

                // Monte Carlo simulation
                var game = new Game(new StrategyPlayer(Node.VarB), new StrategyPlayer(Node.VarS), Seed: 0);
                float ModdedEV = (float)game.Round(4999999);
                Tools.LogPrint("Monte Carlo Simulation EV = {0}", ModdedEV);

                Min = Math.Min((double)Min, (double)EV - (double)ModdedEV);
                Tools.LogPrint("Difference = {0}, min = {1}", (double)EV - (double)ModdedEV, Min);
            }
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            // Initialize the global variables
            GlobalVariables.initGlobalVariables();
            GlobalVariables.player1 = player1;
            GlobalVariables.player2 = player2;

            // Start a new game
            game = new Game(pot);
            game.start();
        }
Ejemplo n.º 3
0
        public GameForm(int numPlayers, int numChips)
        {
            InitializeComponent();

            // gives labels to the seats, groups list of seats into a table
            table = new List<Seat>()
            {
                new Seat(playerOneName, playerOneChipCount, playerOneChipsCommitted, playerOneLastAction, playerOneCards, playerOneButton, playerOneAction),
                new Seat(playerTwoName, playerTwoChipCount, playerTwoChipsCommitted, playerTwoLastAction, playerTwoCards, playerTwoButton, playerTwoAction),
                new Seat(playerThreeName, playerThreeChipCount, playerThreeChipsCommitted, playerThreeLastAction, playerThreeCards, playerThreeButton, playerThreeAction),
                new Seat(playerFourName, playerFourChipCount, playerFourChipsCommitted, playerFourLastAction, playerFourCards, playerFourButton, playerFourAction),
                new Seat(playerFiveName, playerFiveChipCount, playerFiveChipsCommitted, playerFiveLastAction, playerFiveCards, playerFiveButton, playerFiveAction),
                new Seat(playerSixName, playerSixChipCount, playerSixChipsCommitted, playerSixLastAction, playerSixCards, playerSixButton, playerSixAction),
                new Seat(playerSevenName, playerSevenChipCount, playerSevenChipsCommitted, playerSevenLastAction, playerSevenCards, playerSevenButton, playerSevenAction),
                new Seat(playerEightName, playerEightChipCount, playerEightChipsCommitted, playerEightLastAction, playerEightCards, playerEightButton, playerEightAction),
                new Seat(playerNineName, playerNineChipCount, playerNineChipsCommitted, playerNineLastAction, playerNineCards, playerNineButton, playerNineAction)

            };
            game = new Game(numPlayers, numChips);
            state = game.state;

            // moves just created players into the seats
            int seatNumber;
            int lastSeatFilled = 0;
            for (int i = 0; i < state.players.Count; i++)
            {
                if (state.players[i].human)
                { // there should only be one human player
                    table[0].refreshPlayer(state.players[i], state); // used to update info or seat the player the first time
                    lastSeatFilled = 0;
                }
                else
                {
                    Random random = new Random();
                    seatNumber = random.Next(lastSeatFilled + 1, 9 - (state.players.Count - (i+1))); // this fills in order, semirandomly
                    lastSeatFilled = seatNumber;
                    if (table[seatNumber].player == null)
                        table[seatNumber].refreshPlayer(state.players[i], state);

                }

            }
            var timer = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 250;
            timer.Start();
        }
Ejemplo n.º 4
0
        // Testing mainframe
        static void Main(String[] args)
        {
            Game game = new Game();
             game.start_game();

             Console.ReadKey(true);
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            game = new Game();

            this.ReloadView();
        }
        private static void Iteration_Test(int i, number EV_FromBest)
        {
            if (i % Setup.Test_Period == 0 && i != StartIteration)
            {
                // Monte Carlo Simulation
                var game = new Game(new StrategyPlayer(Node.VarB), new StrategyPlayer(Node.VarS), Seed: 0);
                float EV_FromMonteCarlo = (float)game.Round(2999999);
                Tools.LogPrint("Monte Carlo Simulation EV = {0}", EV_FromMonteCarlo);

                //// Full Simulation
                //number EV_FromSim = Tests.Simulation(Node.VarB, Node.VarS, GameRoot);
                //Tools.LogPrint("Simulated EV = {0}", EV_FromSim);
            }
        }