Ejemplo n.º 1
0
        //This calc impl. determines the value of the bet based off whether the other player checked
        public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
        {
            //determines the monetary value of the hand
            int estVal = estimateValueOfHand(details);

            Console.WriteLine(estVal);

            //If the other player went first that means their hand wasn't good enough to wager
            if (actions.Count > 0)
            {
                //If this hand is decent, wager a lot
                if (details.rating > 4)
                {
                    details.betAmount += estVal / 2;
                    return(new PlayerAction(details.name, details.phase, "bet", estVal / 2));
                }
                //otherwise still wager something because of their bad hand
                details.betAmount += estVal / 4;
                return(new PlayerAction(details.name, details.phase, "bet", estVal / 4));
            }
            //If we are first, only wager if we have a decent hand (better then 1)
            else if (details.rating >= 2)
            {
                details.betAmount += estVal / 4;
                return(new PlayerAction(details.name, details.phase, "bet", estVal / 4));
            }

            //Otherwise check
            Check check = new Check();

            return(check.calc(actions, details));
        }
Ejemplo n.º 2
0
        //EstimateValueOfHand: This determines the monetary range the AI will work with in their betting
        public int estimateValueOfHand(TurnDetails details)
        {
            int max;

            //This is for the first betting phase
            if (details.phase == "Bet1")
            {
                max = 200;
                if (details.money < max)
                {
                    max = details.money;                        //keeps the max value from exceeding the current money
                }
                float percent1 = details.rating / 5f;
                max = (int)(max * percent1);

                return(max);
            }

            //this raises the mentary range for the second betting phase
            max = 400;
            if (details.money < max)
            {
                max = details.money;                        //keeps the max value from exceeding the current money
            }
            float percent2 = details.rating / 5f;

            max = (int)(max * percent2);

            return(max);
        }
Ejemplo n.º 3
0
        //this calc impl. will match the other players wager if its not too far from the value of our own hand
        public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
        {
            //determine current values
            Fold fold        = new Fold();
            int  estVal      = estimateValueOfHand(details);
            int  actionIndex = actions.Count - 1;
            int  inValue     = actions[actionIndex].Amount + details.betAmount;

            //if they aren't wagering more than 120% our est. monetary value, then call
            if (inValue <= (estVal + (estVal * .2f)))
            {
                details.betAmount += actions[actionIndex].Amount;
                return(new PlayerAction(details.name, details.phase, "call", 0));
            }

            //otherwise fold, we're beat
            return(fold.calc(actions, details));
        }
Ejemplo n.º 4
0
        //This calc implementation only allows the player do fold instead of check in the second round.
        public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
        {
            //Bet1 always returns a check from here
            if (details.phase == "Bet1")
            {
                return(new PlayerAction(details.name, details.phase, "check", 0));
            }

            //Bet2 only cheks if it has a hand ranking higher then 1
            if (details.rating >= 2)
            {
                return(new PlayerAction(details.name, details.phase, "check", 0));
            }

            //Otherwise it folds
            Fold fold = new Fold();

            return(fold.calc(actions, details));
        }
Ejemplo n.º 5
0
        //The calc implementation in this class is the head of the behavior tree and returns the final PlayerAction determined
        public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
        {
            //The two different directions the tree can branch
            Bet   bet   = new Bet();
            Raise raise = new Raise();

            //only allows bet if it hasn't been called already, otherwise raise is called
            int actionIndex = actions.Count;

            if (actionIndex > 0)
            {
                if (actions[actionIndex - 1].ActionName != "check")
                {
                    return(raise.calc(actions, details));
                }
            }

            return(bet.calc(actions, details));
        }
Ejemplo n.º 6
0
        //this calc impl. will raise depending on our hand value, rating and current bet pool
        public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
        {
            //determine current values
            Call call        = new Call();
            int  estVal      = estimateValueOfHand(details);
            int  actionIndex = actions.Count - 1;
            int  inValue     = actions[actionIndex].Amount + details.betAmount;

            //if the current pool commitment isn't moer then double our est. hand value
            if (inValue >= estVal && inValue < estVal * 2)
            {
                //if we have a great hand, wager a lot
                int raiseAmount = (estVal * 2) - inValue;
                if (details.rating > 7)
                {
                    details.betAmount += raiseAmount;
                    return(new PlayerAction(details.name, details.phase, "raise", raiseAmount));
                }

                //otherwise just call
                return(call.calc(actions, details));
            }

            //if the wager is still low, raise
            if (inValue < (estVal / 2))
            {
                details.betAmount += (estVal / 4);
                return(new PlayerAction(details.name, details.phase, "raise", (estVal / 4)));
            }

            //if the wager is still low, commit our est. hand value
            if (inValue < estVal)
            {
                details.betAmount += estVal;
                return(new PlayerAction(details.name, details.phase, "raise", estVal));
            }

            //otherwise call
            return(call.calc(actions, details));
        }
Ejemplo n.º 7
0
 //this calc impl. returns the fold playeraction
 public override PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
 {
     return(new PlayerAction(details.name, details.phase, "fold", 0));;
 }
Ejemplo n.º 8
0
 //calc: must be used by all children. All behavior logic is contained in these
 public virtual PlayerAction calc(List <PlayerAction> actions, TurnDetails details)
 {
     return(null);
 }
Ejemplo n.º 9
0
 public Player4(int idNum, string nm, int mny) : base(idNum, nm, mny)
 {
     //initialize game details
     details = new TurnDetails(mny, Name);
 }