public void BillChenGroupValue_7() { Dictionary <string, int> pairs = new Dictionary <string, int>(); pairs.Add("K9s", 6); pairs.Add("K8s", 5); pairs.Add("K7s", 5); pairs.Add("K6s", 5); pairs.Add("K5s", 5); pairs.Add("K4s", 5); pairs.Add("K3s", 5); pairs.Add("K2s", 5); pairs.Add("J9", 6); pairs.Add("T9", 6); pairs.Add("98", 6); pairs.Add("64s", 5); pairs.Add("53s", 5); pairs.Add("44", 5); pairs.Add("43s", 5); pairs.Add("33", 5); pairs.Add("22", 5); foreach (var kvp in pairs) { var hand = new HoleCards(kvp.Key); Assert.Equal(kvp.Value, hand.BillChenValue); Assert.Equal(7, hand.BillChenGroupValue); } }
public void BillChenGroupValue_8() { Dictionary <string, int> pairs = new Dictionary <string, int>(); pairs.Add("A9", 5); pairs.Add("K9", 4); pairs.Add("Q9", 5); pairs.Add("J8", 4); pairs.Add("J7s", 4); pairs.Add("T8", 5); pairs.Add("96s", 5); pairs.Add("87", 5); pairs.Add("85s", 4); pairs.Add("76", 5); pairs.Add("74s", 4); pairs.Add("65", 4); pairs.Add("54", 4); pairs.Add("42s", 4); pairs.Add("32s", 5); foreach (var kvp in pairs) { var hand = new HoleCards(kvp.Key); Assert.Equal(kvp.Value, hand.BillChenValue); Assert.Equal(8, hand.BillChenGroupValue); } }
public void Initialize_Hand_With_CardShortnames() { var hand = new HoleCards("Ks", "Ah"); Assert.Equal("Ks", hand.FirstCard.ToString()); Assert.Equal("Ah", hand.SecondCard.ToString()); }
public void BillChenGroupValue_5() { Dictionary <string, int> pairs = new Dictionary <string, int>(); pairs.Add("A9s", 7); pairs.Add("A8s", 7); pairs.Add("A7s", 7); pairs.Add("A6s", 7); pairs.Add("A5s", 7); pairs.Add("A4s", 7); pairs.Add("A3s", 7); pairs.Add("A2s", 7); pairs.Add("KJ", 7); pairs.Add("QJ", 7); pairs.Add("JT", 7); pairs.Add("Q9s", 7); pairs.Add("T8s", 7); pairs.Add("97s", 7); pairs.Add("87s", 7); pairs.Add("77", 7); pairs.Add("76s", 7); pairs.Add("66", 6); foreach (var kvp in pairs) { var hand = new HoleCards(kvp.Key); Assert.Equal(kvp.Value, hand.BillChenValue); Assert.Equal(5, hand.BillChenGroupValue); } }
private Player AddOrUpdatePlayer(UserGameInfoNet userGameInfo, int seat, HandHistory handHistory, long heroId) { var player = handHistory.Players[userGameInfo.UserInfo.ShowID]; if (player == null) { player = new Player(userGameInfo.UserInfo.ShowID, 0, seat) { PlayerNick = userGameInfo.UserInfo.Nick }; handHistory.Players.Add(player); if (heroId == userGameInfo.UserInfo.Uuid) { handHistory.Hero = player; } } if (userGameInfo.CurrentHands == null || player.hasHoleCards) { return(player); } handHistory.Players[userGameInfo.UserInfo.ShowID].HoleCards = HoleCards.FromCards(userGameInfo.UserInfo.ShowID, userGameInfo.CurrentHands.Select(c => Card.GetPMCardFromIntValue(c)).ToArray()); return(player); }
private HoleCards parseHoleCards(string handLine) { int openSquareIndex = handLine.IndexOf('['); string cards = handLine.Substring(openSquareIndex + 2, handLine.Length - openSquareIndex - 2 - 2); return(HoleCards.FromCards(cards.Replace(",", "").Replace(" ", ""))); }
public void ParsePlayers_WaitingForBB() { var expected = new PlayerList(new List <Player>() { new Player("Player1", 2000m, 1), new Player("Player2", 2017m, 2) { HoleCards = HoleCards.FromCards("8h3hJcTc") }, new Player("Player3", 0m, 3) { IsSittingOut = true }, new Player("HERO", 1970m, 4) { HoleCards = HoleCards.FromCards("AcAd9d3d") }, new Player("Player5", 2000m, 5) { IsSittingOut = true }, new Player("Player6", 2000m, 6), }); TestParsePlayers_FullHand("WaitingForBB", expected); }
protected override PlayerList ParsePlayers(string[] handLines) { // Line 5 onward is: // Players in round: 3 // Seat 8: Max Power s ($8.96) // Seat 9: EvilJihnny99 ($24.73) // Seat 10: huda22 ($21.50) int numPlayers = ParseNumberOfPlayers(handLines); PlayerList playerList = new PlayerList(); int StartLine = isHeroHandhistory(handLines) ? 6 : 5; for (int i = 0; i < numPlayers; i++) { string handLine = handLines[StartLine + i]; int colonIndex = handLine.IndexOf(':'); int parenIndex = handLine.IndexOf('('); string name = handLine.Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int seatNumber = Int32.Parse(handLine.Substring(5, colonIndex - 5)); string amount = (handLine.Substring(parenIndex + 1, handLine.Length - parenIndex - 2)); playerList.Add(new Player(name, decimal.Parse(amount, NumberStyles.AllowCurrencySymbol | NumberStyles.Number, _numberFormatInfo), seatNumber)); } // Parse the player showdown hole-cards for (int i = handLines.Length - 2; i >= 0; i--) { // Loop backward looking for lines like: // Seat 4: mr dark hor ($37.87), net: -$15.25, [Ts, 3s] string handLine = handLines[i]; if (handLine.StartsWith("Seat") == false) { break; } if (handLine.EndsWith("]") == false) { continue; } int colonIndex = handLine.IndexOf(':'); int parenIndex = handLine.IndexOf('('); string name = handLine.Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int openSquareIdex = handLine.LastIndexOf('['); string holeCards = handLine.Substring(openSquareIdex + 1, handLine.Length - openSquareIdex - 2); Player player = playerList.First(p => p.PlayerName.Equals(name)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace(",", "")); } return(playerList); }
private IEnumerable <PlayerList> GetPlayerLists() { var playerLists = new List <PlayerList>(); var p1 = new PlayerList() { new Player("KrookedTyrant", 133.90m, 6), new Player("LOLYOU FOLD", 423.45m, 3) { HoleCards = HoleCards.FromCards("6c Ad") }, new Player("Moose4Life", 551.33m, 4), new Player("PotatoGun", 559.66m, 2) { HoleCards = HoleCards.FromCards("Qc Ac") }, new Player("WhatDayIsIt", 410.67m, 5), }; var p2 = new PlayerList() { new Player("dimatlt633", 2.06m, 3), new Player("ragga22", 17.60m, 1), }; playerLists.Add(p1); playerLists.Add(p2); return(playerLists); }
protected override string ParseHeroName(string[] handlines, PlayerList playerList) { const string DealText = "Dealt to "; for (int i = 0; i < handlines.Length; i++) { if (handlines[i][0] == 'D' && handlines[i].StartsWith(DealText)) { string line = handlines[i]; int startIndex = line.IndexOf('['); var heroName = line.Substring(9, startIndex - 10); if (playerList != null && playerList[heroName] != null && playerList[heroName].HoleCards == null) { var cards = line.Substring(startIndex + 1, line.Length - startIndex - 2) .Replace("[", string.Empty).Replace("]", string.Empty).Replace(",", " "); playerList[heroName].HoleCards = HoleCards.FromCards(CardNormalization(handlines, cards)); } return(heroName); } } return(null); }
private static HoleCards GetPlayerCardsFromHandLines(string[] handLines, int playerSeat, string playerName) { string seatString = "seat=\"" + playerSeat + "\""; for (int i = 8; i < handLines.Length; i++) { string line = handLines[i]; if (line[1] != 'C') { continue; } string showLine = handLines[i - 1]; if (showLine[1] != 'A') { continue; } int showCardsIndex = showLine.IndexOfFast("type=\"ShowCards\"", 15); if (showCardsIndex == -1) { showCardsIndex = showLine.IndexOfFast("type=\"MuckCards\"", 15); } // if the cards are shown for this player if (showCardsIndex != -1 && showLine.LastIndexOfFast(seatString) != -1) { var cards = ParseCardsFromLines(handLines, ref i); return(HoleCards.FromCards(playerName, cards.ToArray())); } } return(null); }
protected override PlayerList ParsePlayers(string[] handLines) { // line 3 onward has all seated player // Seat 1: ovechkin08 (2000€) // Seat 4: R.BAGGIO (2000€) // *** ANTE/BLINDS *** var playerList = new PlayerList(); for (int i = 2; i < handLines.Length; i++) { // when the line starts with stars, we already have all players if (handLines[i].StartsWith("***")) { break; } int colonIndex = handLines[i].IndexOf(':'); int parenIndex = handLines[i].IndexOf('('); string name = handLines[i].Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int seatNumber = Int32.Parse(handLines[i].Substring(5, colonIndex - 5)); string amount = (handLines[i].Substring(parenIndex + 1, handLines[i].Length - parenIndex - 2)); playerList.Add(new Player(name, decimal.Parse(amount, NumberStyles.AllowCurrencySymbol | NumberStyles.Number, _numberFormatInfo), seatNumber)); } for (int i = handLines.Length - 1; i >= 0; i--) { // Loop backward looking for lines like: // Seat 3: xGras (button) won 6.07€ // Seat 4: KryptonII (button) showed [Qd Ah] and won 42.32€ with One pair : Aces // Seat 1: Hitchhiker won 0.90€ // Seat 3: le parano (big blind) mucked string handLine = handLines[i]; if (!handLine.StartsWith("Seat")) { break; } string name = GetPlayerNameFromHandLine(handLine); int openSquareIndex = handLine.LastIndexOf('['); int closeSquareIndex = handLine.LastIndexOf(']'); string holeCards = ""; if (openSquareIndex > -1 && closeSquareIndex > -1) { holeCards = handLine.Substring(openSquareIndex + 1, closeSquareIndex - openSquareIndex - 1); } Player player = playerList.First(p => p.PlayerName.Equals(name)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace(",", "")); } return(playerList); }
public void ParsePlayers_RunItTwice() { var expected = new PlayerList(new List <Player>() { new Player("jedimaster82", 1000, 1), new Player("OneMoreSpin", 1859.80m, 2), new Player("FLATC@T", 2000m, 3) { HoleCards = HoleCards.ForOmaha( new Card('J', 'd'), new Card('T', 's'), new Card('Q', 'd'), new Card('Q', 's')) }, new Player("KENZA_MILOU", 1000m, 4) { HoleCards = HoleCards.ForOmaha( new Card('7', 's'), new Card('9', 's'), new Card('7', 'h'), new Card('J', 'h')) }, new Player("Legheliel", 2000m, 5), new Player("danfiu", 2000m, 6), }); TestParsePlayers("RunItTwice", expected); }
public void EmptyHand() { var hand = new HoleCards(); Assert.Equal(null, hand.FirstCard); Assert.Equal(null, hand.SecondCard); }
/// <summary> /// Parses Hero from the specified HH lines /// </summary> /// <param name="handlines">Lines to parse</param> /// <param name="playerList">List of players</param> /// <returns>Name of hero</returns> protected override string ParseHeroName(string[] handlines, PlayerList playerList) { for (var i = 2; i < handlines.Length; i++) { if (handlines[i].StartsWith("Dealt to", StringComparison.OrdinalIgnoreCase)) { var heroName = handlines[i].TakeBetween("Dealt to ", " [", false, true); var hero = playerList.FirstOrDefault(p => p.PlayerName == heroName); if (hero != null) { var cardsText = handlines[i].TakeBetween("[", "]", true); if (!string.IsNullOrEmpty(cardsText)) { hero.HoleCards = HoleCards.FromCards(heroName, cardsText); } } return(heroName); } ; if (handlines[i].StartsWith("***", StringComparison.Ordinal)) { break; } } return(string.Empty); }
protected override PlayerList ParsePlayers(string[] handLines) { // Line 5 onward is: // Players in round: 3 // Seat 8: Max Power s ($8.96) // Seat 9: EvilJihnny99 ($24.73) // Seat 10: huda22 ($21.50) int firstColon = handLines[4].LastIndexOf(':'); int numPlayers = Int32.Parse(handLines[4].Substring(firstColon + 1, handLines[4].Length - firstColon - 1)); PlayerList playerList = new PlayerList(); for (int i = 0; i < numPlayers; i++) { string handLine = handLines[5 + i]; int colonIndex = handLine.IndexOf(':'); int parenIndex = handLine.IndexOf('('); string name = handLine.Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int seatNumber = Int32.Parse(handLine.Substring(5, colonIndex - 5)); string amount = (handLine.Substring(parenIndex + 2, handLine.Length - parenIndex - 2 - 1)); playerList.Add(new Player(name, decimal.Parse(amount, System.Globalization.CultureInfo.InvariantCulture), seatNumber)); } // Parse the player showdown hole-cards for (int i = handLines.Length - 2; i >= 0; i--) { // Loop backward looking for lines like: // Seat 4: mr dark hor ($37.87), net: -$15.25, [Ts, 3s] string handLine = handLines[i]; if (handLine.StartsWith("Seat") == false) { break; } if (handLine.EndsWith("]") == false) { continue; } int colonIndex = handLine.IndexOf(':'); int parenIndex = handLine.IndexOf('('); string name = handLine.Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int openSquareIdex = handLine.LastIndexOf('['); string holeCards = handLine.Substring(openSquareIdex + 1, handLine.Length - openSquareIdex - 2); Player player = playerList.First(p => p.PlayerName.Equals(name)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace(",", "")); } return(playerList); }
public void Initialize_Hand_With_Shortname_Suited() { var hand = new HoleCards("AKs"); Assert.Equal("Ah", hand.FirstCard.ToString()); Assert.Equal("Kh", hand.SecondCard.ToString()); Assert.Equal(true, hand.SameSuit); }
public Player(string playerName, decimal startingStack, int seatNumber) { PlayerName = playerName; StartingStack = startingStack; SeatNumber = seatNumber; HoleCards = HoleCards.NoHolecards(playerName); }
public void Initialize_Hand_With_CardObjects() { var card1 = new Card("Th"); var card2 = new Card("As"); var hand = new HoleCards(card1, card2); Assert.Equal("Th", hand.FirstCard.ToString()); Assert.Equal("As", hand.SecondCard.ToString()); }
public void Initialize_Hand_Two_Times() { var hand = new HoleCards("AA"); Assert.Equal(20, hand.BillChenValue); hand.FirstCard = new Card(7, Card.SuitName.Clubs); hand.SecondCard = new Card(2, Card.SuitName.Diamonds); Assert.Equal(-1, hand.BillChenValue); }
public void Eval_Hand1Wins(string hand1, string hand2, string board) { var thisBoard = Board.Parse(board); var hc1 = HoleCards.Parse(hand1); var hc2 = HoleCards.Parse(hand2); var results = thisBoard.Evaluate(hc1, hc2); Assert.True(results[0].HandStrength > results[1].HandStrength); }
public void ClearGame() { StartCurrency = Currency; AmountWon = 0; AmountToReturn = 0; HasFolded = false; HoleCards.Clear(); CloseAllGumps(); ClearRound(); }
public void Eval_EqualStrength(string hand1, string hand2) { var board = Board.Parse("Ac Js 7h 6h 3d"); var hc1 = HoleCards.Parse(hand1); var hc2 = HoleCards.Parse(hand2); var results = board.Evaluate(hc1, hc2); Assert.Equal(results[0].HandStrength, results[1].HandStrength); }
public PokerHand(HoleCards holeCards, CardsCollection board) { HoleCards = holeCards; Board = board; _pokerHand = holeCards.ToLong(); foreach (var card in Board) { _pokerHand |= Convert.ToInt64(card.AbsoluteValue); } Kickers = new CardsCollection(); }
private void displayState() { int heroStack = getPlayers()[_heroInd].Stack; this.Text = "Play vs Bots (" + moneyToString(heroStack - _totalInvestedMoney) + ")"; int playerToActInd = _botGameStates[_heroInd].getPlayerToActInd(); int buttonInd = _botGameStates[_heroInd].getButtonInd(); for (int i = 0; i < 6; i++) { _gameTableControl.hidePlayerInfo(i); } for (int i = 0; i < NUM_PLAYERS; i++) { HoleCards hh = null; var street = _botGameStates[_heroInd].getStreet(); if (i == _heroInd || playerToActInd < 0 && street == Street.River || _botGameStates[_heroInd].numActiveNonAllInPlayers() == 0 /*|| * _botGameStates[_heroInd].getPlayers()[_heroInd].StatusInHand == Status.Folded*/) { hh = _botGameStates[i].getHeroHoleCards(); } Player player = getPlayers()[i]; int wherePlayerSits = (NUM_PLAYERS == 2) ? (i * 3) : i; _gameTableControl.updatePlayerInfo(wherePlayerSits, player.Name, player.Stack, player.MoneyInPot, player.StatusInHand, hh, player.PreFlopPosition, (playerToActInd == i)); if (i == buttonInd) { _gameTableControl.setButtonPosition(wherePlayerSits); } } _gameTableControl.disablePlayerControls(); _gameTableControl.setbuttonNextEnabled(true); if (playerToActInd == _heroInd && (_botGameStates[_heroInd].numActivePlayers() >= 2)) { _gameTableControl.enablePlayerControls(); _gameTableControl.setbuttonNextEnabled(false); _gameTableControl.setupPlayerControls(_botGameStates[_heroInd].getNumBets(), _botGameStates[_heroInd].getAmountToCall(), _botGameStates[_heroInd].getRaiseAmmount(), getPlayers()[_heroInd].Stack); } _gameTableControl.setPotSize(_botGameStates[_heroInd].potSize()); _gameTableControl.displayBoard(_botGameStates[_heroInd].getBoard().Cards); }
protected override PlayerList ParsePlayers(string[] handLines) { int seatCount = Int32.Parse(NumPlayersRegex.Match(handLines[5]).Value); PlayerList playerList = new PlayerList(); for (int i = 0; i < seatCount; i++) { string handLine = handLines[6 + i]; // Expected format: // Seat 1: Velmonio ( $1.05 ) int colonIndex = handLine.IndexOf(':'); int openParenIndex = handLine.IndexOf('('); int seat = int.Parse(handLine.Substring(5, colonIndex - 5)); string playerName = handLine.Substring(colonIndex + 2, openParenIndex - colonIndex - 3); decimal amount = ParseAmount(handLine.Substring(openParenIndex + 3, handLine.Length - openParenIndex - 3 - 2)); playerList.Add(new Player(playerName, amount, seat)); } // Add hole-card info for (int i = handLines.Length - 2; i >= 0; i--) { string handLine = handLines[i]; if (handLine[0] == '*') { break; } if (handLine.EndsWith("]") && char.IsDigit(handLine[handLine.Length - 3]) == false) { // lines such as: // slyguyone2 shows [ Jd, As ] int openSquareIndex = handLine.IndexOf('['); string cards = handLine.Substring(openSquareIndex + 2, handLine.Length - openSquareIndex - 2 - 2); HoleCards holeCards = HoleCards.FromCards(cards.Replace(",", "").Replace(" ", "")); string playerName = handLine.Substring(0, openSquareIndex - 7); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); player.HoleCards = holeCards; } } return(playerList); }
private void ReadPlayers(HandHistory hand, List <JSON_player> players) { hand.Players = new PlayerList(); foreach (var player in players) { hand.Players.Add(new Player(player.player, player.startingStack, player.seat) { IsSittingOut = player.sitout, HoleCards = HoleCards.FromCards(player.cards), }); } }
public static string ToHoleCards(HoleCards holeCards) { if (holeCards == null) { return(string.Empty); } var mask = Hand.ParseHand(holeCards.ToString()); var cards = Hand.Cards(mask).ToList(); cards.Sort(new CardComparer()); return(string.Join(string.Empty, cards)); }
public void ParsePlayers_Hero() { var expected = new PlayerList(new List <Player>() { new Player("WM_Hero", 400m, 1) { HoleCards = HoleCards.FromCards("4c5s") }, new Player("Opponent1", 400m, 2), new Player("Opponent2", 400m, 3), }); TestParsePlayers("Hero", expected); }
public void ClearGame() { Bet = 0; RoundCurrency = 0; RoundBet = 0; HoleCards.Clear(); Game = null; CloseAllGumps(); IsAllIn = false; Forced = false; LonePlayer = false; m_Action = PlayerAction.None; }