private void CompareOnFlop() { var heroBest = new BestFiveCardsHand(new List <Card>() { HeroHoles.Hole1, HeroHoles.Hole2, BoardStatus.Flop1, BoardStatus.Flop2, BoardStatus.Flop3 }); var villainBest = new BestFiveCardsHand(new List <Card>() { VillainHoles.Hole1, VillainHoles.Hole2, BoardStatus.Flop1, BoardStatus.Flop2, BoardStatus.Flop3 }); var heroScore = BettingUtils.GetScoreForFiveCardHand(heroBest); var villainScore = BettingUtils.GetScoreForFiveCardHand(villainBest); HeroIsAhead = heroScore > villainScore; var allCards = TexasBot.Tools.Utils.GenerateAllCards().Select(c => c.ConvertCard()).ToList(); allCards.RemoveElementEqualsTo(HeroHoles.Hole1); allCards.RemoveElementEqualsTo(HeroHoles.Hole2); allCards.RemoveElementEqualsTo(VillainHoles.Hole1); allCards.RemoveElementEqualsTo(VillainHoles.Hole2); allCards.RemoveElementEqualsTo(BoardStatus.Flop1); allCards.RemoveElementEqualsTo(BoardStatus.Flop2); allCards.RemoveElementEqualsTo(BoardStatus.Flop3); allCards.RemoveElementEqualsTo(BoardStatus.Turn); BestFiveCardsHand leader = HeroIsAhead ? heroBest : villainBest; BestFiveCardsHand follower = HeroIsAhead ? villainBest : heroBest; List <Card> outs = HeroIsAhead ? VillainOuts : HeroOuts; outs.AddRange(allCards.Where(card => CardCanHelp(leader, follower, card))); }
/// <summary> /// If card can help follower to get ahead of leader /// </summary> /// <param name="leader"></param> /// <param name="follower"></param> /// <param name="card"></param> /// <returns></returns> private bool CardCanHelp(SixCardsHand leader, SixCardsHand follower, Card card) { var leaderSeven = new SevenCardsHand(leader.Hole1, leader.Hole2, leader.Flop1, leader.Flop2, leader.Flop3, leader.Turn, card); var followerSeven = new SevenCardsHand(follower.Hole1, follower.Hole2, follower.Flop1, follower.Flop2, follower.Flop3, follower.Turn, card); var leaderBest = BettingUtils.FindBestFive(leaderSeven); var followerBest = BettingUtils.FindBestFive(followerSeven); var leaderScore = BettingUtils.GetScoreForFiveCardHand(leaderBest); var followerScore = BettingUtils.GetScoreForFiveCardHand(followerBest); return(followerScore > leaderScore); }
/// <summary> /// If card can help follower to get ahead of leader /// </summary> /// <param name="leader"></param> /// <param name="follower"></param> /// <param name="card"></param> /// <returns></returns> private bool CardCanHelp(BestFiveCardsHand leader, BestFiveCardsHand follower, Card card) { var leaderSix = new SixCardsHand(leader.Cards[0], leader.Cards[1], leader.Cards[2], leader.Cards[3], leader.Cards[4], card); var followerSix = new SixCardsHand(follower.Cards[0], follower.Cards[1], follower.Cards[2], follower.Cards[3], follower.Cards[4], card); var leaderBest = BettingUtils.FindBestFive(leaderSix); var followerBest = BettingUtils.FindBestFive(followerSix); var leaderScore = BettingUtils.GetScoreForFiveCardHand(leaderBest); var followerScore = BettingUtils.GetScoreForFiveCardHand(followerBest); return(followerScore > leaderScore); }
private void CompareOnRiver() { var heroSeven = new SevenCardsHand(HeroHoles.Hole1, HeroHoles.Hole2, BoardStatus.Flop1, BoardStatus.Flop2, BoardStatus.Flop3, BoardStatus.Turn, BoardStatus.River); var villainSeven = new SevenCardsHand(VillainHoles.Hole1, VillainHoles.Hole2, BoardStatus.Flop1, BoardStatus.Flop2, BoardStatus.Flop3, BoardStatus.Turn, BoardStatus.River); var heroBest = BettingUtils.FindBestFive(heroSeven); var villainBest = BettingUtils.FindBestFive(villainSeven); var heroScore = BettingUtils.GetScoreForFiveCardHand(heroBest); var villainScore = BettingUtils.GetScoreForFiveCardHand(villainBest); HeroIsAhead = heroScore > villainScore; }
public double CalculateEquityAgainstGrid(HoldingHoles heroHoles, HoldingHoles villainHoles, BoardStatus boardStatus) { var boards = boardStatus.GenerateAllPossibleBoards(new List <Card>() { heroHoles.Hole1, heroHoles.Hole2, villainHoles.Hole1, villainHoles.Hole2 }); double heroWin = 0, villainWin = 0; foreach (var board in boards) { var heroSeven = new SevenCardsHand(heroHoles.Hole1, heroHoles.Hole2, board.Flop1, board.Flop2, board.Flop3, board.Turn, board.River); var villainSeven = new SevenCardsHand(villainHoles.Hole1, villainHoles.Hole2, board.Flop1, board.Flop2, board.Flop3, board.Turn, board.River); var heroFive = BettingUtils.FindBestFive(heroSeven); var villainFive = BettingUtils.FindBestFive(villainSeven); int heroScore = BettingUtils.GetScoreForFiveCardHand(heroFive); int villainScore = BettingUtils.GetScoreForFiveCardHand(villainFive); if (heroScore > villainScore) { heroWin++; } else { villainWin++; } } return(heroWin / (heroWin + villainWin)); }