public void AllIn(Pot mainPot, int index) { AmountContributed = ChipStack; if (mainPot.MinimumAllInAmount == 0) { mainPot.AmountInPotBeforeAllIn = mainPot.Amount; mainPot.MinimumAllInAmount = ChipStack; } else if (chipStack < mainPot.MinimumAllInAmount) { mainPot.MinimumAllInAmount = ChipStack; } if (ChipStack > mainPot.MinimumRaise) { mainPot.MinimumRaise = ChipStack; } mainPot.AddPlayer(this); mainPot.Add(ChipStack); amountInPot += ChipStack; ChipStack = 0; if (amountInPot > mainPot.getMaximumAmountPutIn()) { mainPot.setMaximumAmount(amountInPot); } Message = "I'm All-In"; SimplifiedMessage = "ALL IN"; mainPot.AgressorIndex = index; }
//leave the round public void Fold(Pot mainPot) { folded = true; mainPot.getPlayersInPot().Remove(this); Message = "Fold"; SimplifiedMessage = "FOLDED"; }
//using the knowledge of the opponent's cards, decide on a move public void HardThinking(Pot mainPot, int index) { //if you lose the showdown, don't put any more money in the pot, check or fold if (handValue < 0.5) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Fold(mainPot); return; } //call/bet/raise if you win the showdown int firstPercent = 0; if (playingStyle == (int)PLAYINGSTYLE.AGRESSIVE) { firstPercent = 50; } else if (playingStyle == (int)PLAYINGSTYLE.TIGHT) { firstPercent = 30; } else if (playingStyle == (int)PLAYINGSTYLE.BLUFFER) { firstPercent = 70; } int random = rand.Next(100) + 1; //bet or all-in on the river if (myHand.Count() == 7) { if (random <= firstPercent) { if(getAmountToCall(mainPot)==0) Bet(BetAmount(mainPot), mainPot,index); else Raise(BetAmount(mainPot), mainPot,index); } else { AllIn(mainPot,index); } return; } //call/bet before the river if (random <= firstPercent) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Call(mainPot); } else { if (getAmountToCall(mainPot) == 0) Bet(BetAmount(mainPot), mainPot,index); else Raise(BetAmount(mainPot), mainPot,index); } }
//make a decision about what to do public void MakeADecision(Pot mainPot, int index) { if (this.difficulty == (int)DIFFICULTY.EASY) EasyThinking(mainPot, index); else if (this.difficulty == (int)DIFFICULTY.MEDIUM) MediumThinking(mainPot, index); else HardThinking(mainPot, index); }
//using random values decide on a move public void EasyThinking(Pot mainPot, int index) { int firstPercent = 0, secondPercent = 0, thirdPercent = 0; //35% fold, 45% call, 18% raise, 2% all in if (playingStyle == (int)PLAYINGSTYLE.AGRESSIVE) { firstPercent = 35; secondPercent = 80; thirdPercent = 98; } //50% fold, 40% call, 9% raise, 1% all in else if (playingStyle == (int)PLAYINGSTYLE.TIGHT) { firstPercent = 50; secondPercent = 90; thirdPercent = 99; } //40% fold, 35% call, 22% raise, 3% all in else if (playingStyle == (int)PLAYINGSTYLE.BLUFFER) { firstPercent = 40; secondPercent = 75; thirdPercent = 97; } int random = rand.Next(100) + 1; if (random <= firstPercent) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Fold(mainPot); } else if (random > firstPercent && random <= secondPercent) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Call(mainPot); } else if (random > secondPercent && random <= thirdPercent) { if (getAmountToCall(mainPot) == 0) Bet((((rand.Next(15) + 10) * (mainPot.MinimumRaise * 10)) / 100), mainPot, index); else Raise((((rand.Next(15) + 10) * (mainPot.MinimumRaise * 10)) / 100), mainPot, index); } else if (random > thirdPercent) AllIn(mainPot, index); }
//bet a certain amount of money public void Bet(int bet, Pot mainPot) { if (ChipStack <= bet) { AllIn(mainPot); return; } ChipStack -= bet; amountInPot += bet; mainPot.Add(bet); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = bet; Message = "Bet " + bet.ToString("c0"); SimplifiedMessage = "BET " + bet; }
//bet enough to stay in the round public void Call(Pot mainPot) { int amount = mainPot.getMaximumAmountPutIn() - amountInPot; if (ChipStack <= amount) { AllIn(mainPot); return; } ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.AddPlayer(this); Message = "Call " + amount.ToString("c0"); SimplifiedMessage = "CALL " + amount; }
//some functions have index as they are needed to reset the agressor index to continue the round public void PaySmallBlind(int amount, Pot mainPot, int index) { if (ChipStack <= amount) { AllIn(mainPot, index); return; } ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.AddPlayer(this); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = amount; Message = this.Name + " pays the small blind"; SimplifiedMessage = "SMALL BLIND " + amount; }
public void PayBigBlind(int amount, Pot mainPot) { if (ChipStack <= amount) { AllIn(mainPot); return; } Message = "Pay blind of " + amount.ToString("c0"); ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.AddPlayer(this); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = amount; Message = this.Name + " pays the big blind"; SimplifiedMessage = "BIG BLIND " + amount; }
//call and bet additional amount of money public void Raise(int raise, Pot mainPot) { int amount = mainPot.getMaximumAmountPutIn() + raise - amountInPot; if (ChipStack <= amount) { AllIn(mainPot); return; } ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.setMaximumAmount(amountInPot); mainPot.AddPlayer(this); mainPot.MinimumRaise = raise; Message = "Call " + (amount - raise).ToString("c0") + " and raise " + raise.ToString("c0"); SimplifiedMessage = "RAISE " + (amount - raise); }
public Table() { players = new PlayerList(); deck = new Deck(); rand = new Random(); mainPot = new Pot(); sidePots = new List<Pot>(); smallBlind = new Blind(); bigBlind = new Blind(); roundCounter = 0; turnCount = 0; dealerPosition = rand.Next(players.Count); //set blind amount and position smallBlind.Amount = 500; bigBlind.Amount = 1000; mainPot.SmallBlind = 500; mainPot.BigBlind = 1000; smallBlind.position = dealerPosition + 1; bigBlind.position = dealerPosition + 2; currentIndex = dealerPosition; }
public Table() { players = new PlayerList(); deck = new Deck(); rand = new Random(); mainPot = new Pot(); sidePots = new List <Pot>(); smallBlind = new Blind(); bigBlind = new Blind(); roundCounter = 0; turnCount = 0; dealerPosition = rand.Next(players.Count); //set blind amount and position smallBlind.Amount = 500; bigBlind.Amount = 1000; mainPot.SmallBlind = 500; mainPot.BigBlind = 1000; smallBlind.position = dealerPosition + 1; bigBlind.position = dealerPosition + 2; currentIndex = dealerPosition; }
//how much to bet? public int BetAmount(Pot mainPot) { //bet 4 times the bigBlind before the flop if (myHand.Count() == 2) { return 4 * mainPot.BigBlind; } else { Random rand = new Random(); int randomValue = rand.Next(10); //under betting, between 1/2 - 3/4 of the pot if (randomValue < 2) return rand.Next(mainPot.Amount / 4) + mainPot.Amount / 2; //normal betting, between 3/4 to 1 of the pot else if (randomValue < 8) return rand.Next(mainPot.Amount / 4) + 3 * mainPot.Amount / 4; //extreme bluffing, between 1 to 3 times the pot else return rand.Next(mainPot.Amount * 2) + mainPot.Amount; } }
//don't bet public void Check(Pot mainPot) { Message = "Check"; SimplifiedMessage = "CHECK"; }
//collect the winnings if the player wins public void CollectMoney(Pot mainPot) { this.ChipStack += mainPot.Amount; this.Message = this.Name + " wins the pot!"; }
public int getAmountToCall(Pot mainPot) { return mainPot.getMaximumAmountPutIn() - amountInPot; }
//some functions have index as they are needed to reset the agressor index to continue the round public void PaySmallBlind(int amount, Pot mainPot,int index) { if (ChipStack <= amount) { AllIn(mainPot,index); return; } ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.AddPlayer(this); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = amount; Message = this.Name + " pays the small blind"; SimplifiedMessage = "SMALL BLIND " + amount; }
public void Raise(int raise, Pot mainPot, int index) { int amount = mainPot.getMaximumAmountPutIn() + raise - amountInPot; if (ChipStack <= amount) { AllIn(mainPot,index); return; } ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.setMaximumAmount(amountInPot); mainPot.AddPlayer(this); mainPot.MinimumRaise = raise; Message = "Call " + (amount - raise).ToString("c0") + " and raise " + raise.ToString("c0"); SimplifiedMessage = "RAISE " + (amount - raise); mainPot.AgressorIndex = index; }
public void Bet(int bet, Pot mainPot, int index) { if (ChipStack <= bet) { AllIn(mainPot,index); return; } ChipStack -= bet; amountInPot += bet; mainPot.Add(bet); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = bet; Message = "Bet " + bet.ToString("c0"); SimplifiedMessage = "BET " + bet; mainPot.AgressorIndex = index; }
//using a rate of return value decide on a move public void MediumThinking(Pot mainPot, int index) { //automatically drop out if hand value is less than 5-5 and not pocket pairs if (myHand.Count() == 2) { if (myHand[0].getRank() + myHand[1].getRank() <= 10 && myHand[0].getRank() != myHand[1].getRank()) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Fold(mainPot); return; } } int amountToCall = getAmountToCall(mainPot); //if nothing to call then hypothetically call 3/4 to 1 full pot if (amountToCall == 0) { if (myHand.Count() == 2) amountToCall = mainPot.Amount; else amountToCall = 3* mainPot.Amount / 4; } //calculate potOdds amountToCall/(amountInPot+amountToCall) this.potOdds = Convert.ToDouble(amountToCall) / Convert.ToDouble(amountToCall + mainPot.Amount); //rate of return is determined by dividing the two numbers this.rateOfReturn = this.handValue / potOdds; //using rate of return and hand value make appropiate action int firstPercent = 0, secondPercent = 0, thirdPercent = 0; double firstThreshold=0, secondThreshold=0, thirdThreshold=0; if (amountToCall == 0) { firstThreshold = 0.65; secondThreshold = 0.88; thirdThreshold = 1.11; } else { firstThreshold = 1.00; secondThreshold = 1.60; thirdThreshold=2.30; } if (playingStyle == (int)PLAYINGSTYLE.AGRESSIVE) { //95% fold, 0% call, 5% raise, 0% all in if (rateOfReturn < firstThreshold) { firstPercent = 95; secondPercent = 95; thirdPercent = 100; } //80% fold, 5% call, 15% raise, 0% all in else if (rateOfReturn < secondThreshold) { firstPercent = 80; secondPercent = 85; thirdPercent = 100; } //0% fold, 60% call, 39% raise, 1% all in else if (rateOfReturn < thirdThreshold) { firstPercent = 0; secondPercent = 60; thirdPercent = 99; } //0% fold, 30% call, 68% raise, 2% all in else if (rateOfReturn >= thirdThreshold) { firstPercent = 0; secondPercent = 30; thirdPercent = 98; } } else if (playingStyle == (int)PLAYINGSTYLE.TIGHT) { //99% fold, 0% call, 1% raise, 0% all in if (rateOfReturn < firstThreshold) { firstPercent = 99; secondPercent = 99; thirdPercent = 100; } //80% fold, 15% call, 5% raise, 0% all in else if (rateOfReturn < secondThreshold) { firstPercent = 80; secondPercent = 95; thirdPercent = 100; } //10% fold, 70% call, 20% raise, 0% all in else if (rateOfReturn < thirdThreshold) { firstPercent = 10; secondPercent = 80; thirdPercent = 100; } //0% fold, 40% call, 59% raise, 1% all in else if (rateOfReturn >= thirdThreshold) { firstPercent = 0; secondPercent = 40; thirdPercent = 99; } } else if (playingStyle == (int)PLAYINGSTYLE.BLUFFER) { //90% fold, 0% call, 10% raise, 0% all in if (rateOfReturn < firstThreshold) { firstPercent = 90; secondPercent = 90; thirdPercent = 100; } //70% fold, 10% call, 19% raise, 1% all in else if (rateOfReturn < secondThreshold) { firstPercent = 70; secondPercent = 80; thirdPercent = 99; } //0% fold, 50% call, 48% raise, 2% all in else if (rateOfReturn < thirdThreshold) { firstPercent = 0; secondPercent = 50; thirdPercent = 98; } //0% fold, 25% call, 70% raise, 5% all in else if (rateOfReturn >= thirdThreshold) { firstPercent = 0; secondPercent = 25; thirdPercent = 95; } } int random = rand.Next(100) + 1; if (random <= firstPercent) { if (getAmountToCall(mainPot) == 0) Check(mainPot); else Fold(mainPot); } else if (random > firstPercent && random <= secondPercent) { if (getAmountToCall(mainPot) == 0) Bet(3*mainPot.Amount/4, mainPot,index); else Call(mainPot); } else if (random > secondPercent && random <= thirdPercent) { if (getAmountToCall(mainPot) == 0) Bet(BetAmount(mainPot), mainPot, index); else Raise(BetAmount(mainPot), mainPot, index); } else if (random > thirdPercent) AllIn(mainPot, index); }
public void PayBigBlind(int amount, Pot mainPot, int index) { if (ChipStack <= amount) { AllIn(mainPot,index); return; } Message = "Pay blind of " + amount.ToString("c0"); ChipStack -= amount; amountInPot += amount; mainPot.Add(amount); mainPot.AddPlayer(this); mainPot.setMaximumAmount(amountInPot); mainPot.MinimumRaise = amount; Message = this.Name + " pays the big blind"; SimplifiedMessage = "BIG BLIND " + amount; mainPot.AgressorIndex = index; }
public int getAmountToCall(Pot mainPot) { return(mainPot.getMaximumAmountPutIn() - amountInPot); }
public void AllIn(Pot mainPot,int index) { AmountContributed = ChipStack; if (mainPot.MinimumAllInAmount == 0) { mainPot.AmountInPotBeforeAllIn = mainPot.Amount; mainPot.MinimumAllInAmount = ChipStack; } else if (chipStack < mainPot.MinimumAllInAmount) { mainPot.MinimumAllInAmount = ChipStack; } if (ChipStack > mainPot.MinimumRaise) mainPot.MinimumRaise = ChipStack; mainPot.AddPlayer(this); mainPot.Add(ChipStack); amountInPot += ChipStack; ChipStack = 0; if(amountInPot>mainPot.getMaximumAmountPutIn()) mainPot.setMaximumAmount(amountInPot); Message = "I'm All-In"; SimplifiedMessage = "ALL IN"; mainPot.AgressorIndex = index; }