示例#1
0
文件: Player.cs 项目: priel/prbpkr
        public virtual PlayerDecision GetDecition(int numberRound)
        {
            string         d;
            PlayerDecision decision = new PlayerDecision();

            Console.WriteLine(name + ", you have: " + money + "$ and there is " + table.moneyOnTable + "$ on table");
            Console.WriteLine("current bet is: " + (table.currBet - betSoFar));
            Console.WriteLine("what would you like to do (c/r/d)?");
            //Console.WriteLine("Call / Raise / Drop ? (press: c/r/d)");
            d = Console.ReadLine();
            while (((d != "r") && (d != "c") && (d != "d")) || ((d == "r") && (table.currBet - betSoFar > money)))
            {
                Console.WriteLine("please choose only c/r/d and don't raise if you dont have the money!");
                d = Console.ReadLine();
            }
            switch (d)
            {
            case "c":
                decision.outcome = DecisionType.Call;
                if (table.currBet - betSoFar < money)
                {
                    bet(table.currBet - betSoFar);
                    decision.money = table.currBet - betSoFar;
                }
                else
                {
                    bet(money);
                    decision.money = money;
                }
                break;

            case "r":
                Console.WriteLine("how much do you want to raise?");
                decision.money = ModifiedConsole.GetInteger();
                while ((decision.money > money) || (decision.money < table.currBet - betSoFar))
                {
                    Console.WriteLine("invalid number!");
                    decision.money = ModifiedConsole.GetInteger();
                }
                bet(decision.money);
                break;

            case "d":
                decision.outcome = DecisionType.Drop;
                decision.money   = 0;
                isPlaying        = false;
                break;
            }

            return(decision);
        }
示例#2
0
文件: ComPlayer.cs 项目: priel/prbpkr
        public override PlayerDecision GetDecition(int numberRound)
        {
            PlayerDecision decision = new PlayerDecision();

            decision = agent.GetDecisionArena1v1(table, numberRound, this);
            switch (decision.outcome)
            {
            case DecisionType.Call:
                if (table.currBet - betSoFar < money)
                {
                    bet(table.currBet - betSoFar);
                    decision.money = table.currBet - betSoFar;
                }
                else
                {
                    bet(money);
                    decision.money = money;
                }
                Console.WriteLine(name + " has call and have " + money + "$");
                break;

            case DecisionType.Drop:
                isPlaying = false;
                Console.WriteLine(name + "has drop and have " + money + "$");
                break;

            case DecisionType.Raise:
                if ((decision.money > money) || (decision.money < table.currBet - betSoFar))
                {
                    Console.WriteLine("error, agent return illegal value on raise" + decision.money);
                }
                bet(decision.money);
                Console.WriteLine(name + "has raise " + decision.money + "$ and have " + money + "$");
                break;
            }
            return(decision);
        }
示例#3
0
        public PlayerDecision GetDecisionArena1v1(Table table, int numberOfRoound, ComPlayer comPlayer)
        {
            PlayerDecision decision       = new PlayerDecision();
            int            betNeeded      = table.currBet - comPlayer.betSoFar;
            double         ratioNeededBet = (double)betNeeded / comPlayer.money;
            int            raiseRandom    = rnd.Next(100);
            int            moneyRandom    = rnd.Next(agressiveMoney, 100);
            int            decieveRandom  = rnd.Next(decieveOponnent, 100);

            unseenCards.AddRange(table.deck.Cards);
            foreach (Player player in table.players)
            {
                if (player != comPlayer)
                {
                    unseenCards.AddRange(player.hand.Cards);
                }
            }

            double myChances = GetChances(numberOfRoound, comPlayer.hand, table.hand, table.players.Count);

            //Console.WriteLine("debug: chances are:" + myChances);

            if (raiseRandom < agressiveRaise)
            {
                decision.money   = (int)((((double)moneyRandom) / 100) * comPlayer.money);
                decision.outcome = DecisionType.Raise;
                return(decision);
            }
            switch (numberOfRoound)
            {
            case 0:

                if (myChances < 0.37)
                {
                    decision.money = 0;
                    if (betNeeded == 0)
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                    else
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                }
                else if (myChances < 0.62)
                {
                    if (ratioNeededBet > (((double)decieveRandom) / 100))
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                    else if (ratioNeededBet < 0.05)
                    {
                        decision.money   = Math.Max(comPlayer.money / 15, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        break;
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }
                else
                {
                    if (ratioNeededBet < 0.2)
                    {
                        decision.money   = Math.Max(comPlayer.money / 10, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        return(decision);
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }

            case 1:
                if (myChances < 0.3)
                {
                    decision.money = 0;
                    if (betNeeded == 0)
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                    else
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                }
                else if (myChances < 0.83)
                {
                    if (ratioNeededBet > (((double)decieveRandom) / 100))
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                    else if (ratioNeededBet < 0.05)
                    {
                        decision.money   = Math.Max(comPlayer.money / 15, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        break;
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }
                else
                {
                    if (ratioNeededBet < 0.2)
                    {
                        decision.money   = Math.Max(comPlayer.money / 10, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        return(decision);
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }

            case 2:
                if (myChances < 0.40)
                {
                    decision.money = 0;
                    if (betNeeded == 0)
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                    else
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                }
                else if (myChances < 0.75)
                {
                    if (ratioNeededBet > (((double)decieveRandom) / 100))
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                    else if (ratioNeededBet < 0.05)
                    {
                        decision.money   = Math.Max(comPlayer.money / 15, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        break;
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }
                else
                {
                    if (ratioNeededBet < 0.2)
                    {
                        decision.money   = Math.Max(comPlayer.money / 10, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        return(decision);
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }

            case 3:
                if (myChances < 0.5)
                {
                    decision.money = 0;
                    if (betNeeded == 0)
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                    else
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                }
                else if (myChances < 0.80)
                {
                    if (ratioNeededBet > (((double)decieveRandom) / 100))
                    {
                        decision.money   = 0;
                        decision.outcome = DecisionType.Drop;
                        break;
                    }
                    else if (ratioNeededBet < 0.05)
                    {
                        decision.money   = Math.Max(comPlayer.money / 15, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        break;
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }
                else
                {
                    if (ratioNeededBet < 0.2)
                    {
                        decision.money   = Math.Max(comPlayer.money / 10, betNeeded);
                        decision.outcome = DecisionType.Raise;
                        return(decision);
                    }
                    else
                    {
                        decision.outcome = DecisionType.Call;
                        break;
                    }
                }
            }
            unseenCards.Clear();
            return(decision);
        }