public void Parse_ContainsActionForOtherPlayers_DoesNotAddAnyActionToPlayerActions() { var action = new AquiredPokerAction(ActionTypes.B, 1.0); string streetHistory = OneBetOrCallActionFor("OtherPlayer", action); _parser.Parse(streetHistory, PlayerName); Assert.That(_parser.PlayerActions.Count, Is.EqualTo(0)); }
public void Parse_PlayerDidNotShowAndCollected_AddsWinningActionAsLastToPlayerActions() { const double ratio = 1.0; var winningAction = new AquiredPokerAction(ActionTypes.W, ratio); string streetHistory = DidNotShowAndCollectedFor(PlayerName, ratio); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.Last()).IsEqualTo(winningAction); }
public void Parse_PlayerHasOneActionWithoutRatio_AddsActionWithoutRatioToPlayerActions( [Values(ActionTypes.F, ActionTypes.X)] ActionTypes actionType) { var aquiredPokerAction = new AquiredPokerAction(actionType, 0); string streetHistory = OneNonRatioActionFor(PlayerName, aquiredPokerAction); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.First().What).IsEqualTo(aquiredPokerAction.What); }
public void Parse_PlayerUncalledBetActionAndAllinBetAction_AddsAllinActionAsLastToPlayerActions() { const double ratio = 1.0; var allinAction = new AquiredPokerAction(ActionTypes.A, ratio); string streetHistory = UncalledBetActionFor(PlayerName, ratio) + " \n" + AllinBetActionFor(PlayerName, ratio); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.Last()).IsEqualTo(allinAction); }
public void Parse_PlayerAllinActionAndWinningAction_AddsWinningActionAsLastToPlayerActions() { const double ratio = 1.0; var winningAction = new AquiredPokerAction(ActionTypes.W, ratio); string streetHistory = AllinBetActionFor(PlayerName, ratio) + " \n" + ShowedAndWonFor(PlayerName, ratio); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.Last()).IsEqualTo(winningAction); }
public void Parse_PlayerHasOneBetOrCallAction_AddsActionWithRatioToPlayerActions( [Values(ActionTypes.B, ActionTypes.C)] ActionTypes actionType) { const double someRatio = 1.0; var aquiredPokerAction = new AquiredPokerAction(actionType, someRatio); string streetHistory = OneBetOrCallActionFor(PlayerName, aquiredPokerAction); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.First()).IsEqualTo(aquiredPokerAction); }
public void Parse_TwoActions_AddsSecondActionAsLastToPlayerActions() { var action1 = new AquiredPokerAction(ActionTypes.B, 1.0); var action2 = new AquiredPokerAction(ActionTypes.R, 2.0); string streetHistory = OneBetOrCallActionFor(PlayerName, action1) + " \n" + OneRaiseActionFor(PlayerName, action2); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.Last()).IsEqualTo(action2); }
public void Parse_PlayerHasOnePostingAction_AddsActionWithRatioToPlayerActions( [Values(PostingTypes.Ante, PostingTypes.BigBlind, PostingTypes.SmallBlind)] PostingTypes postingType) { const double someRatio = 1.0; const ActionTypes actionType = ActionTypes.P; var aquiredPokerAction = new AquiredPokerAction(actionType, someRatio); string streetHistory = PostingActionFor(PlayerName, postingType, someRatio); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.First()).IsEqualTo(aquiredPokerAction); }
public void Parse_PlayerSomeActionAndUncalledBetAction_AddsUncalledBetActionAsLastToPlayerActions() { const double ratio = 1.0; var someAction = new AquiredPokerAction(ActionTypes.B, 1.0); var uncalledBetAction = new AquiredPokerAction(ActionTypes.U, ratio); string streetHistory = OneBetOrCallActionFor(PlayerName, someAction) + " \n" + UncalledBetActionFor(PlayerName, ratio); _parser.Parse(streetHistory, PlayerName); Affirm.That(_parser.PlayerActions.Last()).IsEqualTo(uncalledBetAction); }
public void Convert_InValidActionType_ThrowsArgumentException( [Values(ActionTypes.E, ActionTypes.N, ActionTypes.P, ActionTypes.U)] ActionTypes actionType) { double somePot = 3.0; double someToCall = 1.5; const double someTotalPot = 4.0; const double someRatio = 1.0; var aquiredAction = new AquiredPokerAction(actionType, someRatio); TestDelegate invokeConvert = () => _converter.Convert(aquiredAction, ref somePot, ref someToCall, someTotalPot); Assert.Throws<ArgumentException>(invokeConvert); }
public void Convert_FoldCheckAllinWin_DoesntChangePot( [Values(ActionTypes.F, ActionTypes.X, ActionTypes.A, ActionTypes.W)] ActionTypes actionType) { const double originalValue = 3.0; double pot = originalValue; double someToCall = 1.0; const double someTotalPot = 4.0; const double someRatio = 1.5; var aquiredAction = new AquiredPokerAction(actionType, someRatio); _converter.Convert(aquiredAction, ref pot, ref someToCall, someTotalPot); Assert.That(pot, Is.EqualTo(originalValue)); }
public void Convert_Bet_SetsToCallToRatio() { const ActionTypes actionType = ActionTypes.B; double toCall = 0; const double ratio = 1.0; const double expectedToCall = ratio; double somePot = 3.0; const double someTotalPot = 4.0; var aquiredAction = new AquiredPokerAction(actionType, ratio); _converter.Convert(aquiredAction, ref somePot, ref toCall, someTotalPot); Assert.That(toCall, Is.EqualTo(expectedToCall)); }
public void Convert_RaiseToCallIsGreaterThanRatio_DoesntChangeToCall() { const ActionTypes actionType = ActionTypes.R; const double originalValue = 2.0; double toCall = originalValue; const double ratio = 1.0; double somePot = 3.0; const double someTotalPot = 4.0; var aquiredAction = new AquiredPokerAction(actionType, ratio); _converter.Convert(aquiredAction, ref somePot, ref toCall, someTotalPot); Assert.That(toCall, Is.EqualTo(originalValue)); }
public void Convert_ValidActionType_ReturnsConvertedActionWithSameActionType( [Values(ActionTypes.A, ActionTypes.B, ActionTypes.C, ActionTypes.F, ActionTypes.R, ActionTypes.W, ActionTypes.X)] ActionTypes actionType) { double somePot = 3.0; double someToCall = 1.5; const double someTotalPot = 4.0; const double someRatio = 1.0; var aquiredAction = new AquiredPokerAction(actionType, someRatio); ActionTypes expectedActionType = actionType; IConvertedPokerAction convertedAction = _converter.Convert( aquiredAction, ref somePot, ref someToCall, someTotalPot); Assert.That(convertedAction.What, Is.EqualTo(expectedActionType)); }
public void Convert_CallBetRaise_AddsRatioToPot( [Values(ActionTypes.C, ActionTypes.B, ActionTypes.R)] ActionTypes actionType) { double pot = 2.0; const double ratio = 1.0; double expectedPot = pot + ratio; double someToCall = 3.0; const double someTotalPot = 4.0; var aquiredAction = new AquiredPokerAction(actionType, ratio); _converter.Convert(aquiredAction, ref pot, ref someToCall, someTotalPot); Assert.That(pot, Is.EqualTo(expectedPot)); }
public void Convert_Win_SetsConvertedRatioToAquiredRatioDividedByTotalPot() { const ActionTypes actionType = ActionTypes.W; const double aquiredRatio = 2.0; const double totalPot = 4.0; const double expectedRatio = aquiredRatio / totalPot; double somePot = 1.0; double someToCall = 1.5; var aquiredAction = new AquiredPokerAction(actionType, aquiredRatio); IConvertedPokerAction convertedAction = _converter.Convert( aquiredAction, ref somePot, ref someToCall, totalPot); Assert.That(convertedAction.Ratio, Is.EqualTo(expectedRatio)); }
public void Convert_CallBet_SetsConvertedRatioToAquiredRatioDividedByPot( [Values(ActionTypes.C, ActionTypes.B)] ActionTypes actionType) { const double aquiredRatio = 1.0; const double origPot = 2.0; const double expectedRatio = aquiredRatio / origPot; double pot = origPot; double someToCall = 0; const double someTotalPot = 3.0; var aquiredAction = new AquiredPokerAction(actionType, aquiredRatio); var convertedAction = _converter.Convert(aquiredAction, ref pot, ref someToCall, someTotalPot); Assert.That(convertedAction.Ratio, Is.EqualTo(expectedRatio)); }
public void Convert_FoldCheckAllin_SetsConvertedRatioToAquiredRatio( [Values(ActionTypes.F, ActionTypes.X, ActionTypes.A)] ActionTypes actionType) { // For these actions the ratio is irelevant, but still should not be changed const double aquiredRatio = 1.0; double somePot = 0; double someToCall = 1.2; const double someTotalPot = 2.0; var aquiredAction = new AquiredPokerAction(actionType, aquiredRatio); var convertedAction = _converter.Convert( aquiredAction, ref somePot, ref someToCall, someTotalPot); Assert.That(convertedAction.Ratio, Is.EqualTo(aquiredRatio)); }
RelativeRatioResult ConvertPreflopHeadsUpHand() { _stub .Value(For.HoleCards).Is(string.Empty); const double smallBlind = 1.0; const double bigBlind = 2.0; const double pot = smallBlind + bigBlind; const double toCall = bigBlind; const int totalPlayers = 2; const int smallBlindPosition = 0; const int bigBlindPosition = 1; var action1 = new AquiredPokerAction(ActionTypes.C, smallBlind); const double relativeRatio1 = smallBlind / pot; const double pot1 = pot + smallBlind; var action2 = new AquiredPokerAction(ActionTypes.R, toCall * 2); const double relativeRatio2 = 2; const double pot2 = pot1 + (toCall * 2); var action3 = new AquiredPokerAction(ActionTypes.R, toCall * 2 * 3); const double relativeRatio3 = 3; const double pot3 = pot2 + (toCall * 2 * 3); var action4 = new AquiredPokerAction(ActionTypes.C, toCall * 2 * 3); const double relativeRatio4 = (toCall * 2 * 3) / pot3; IAquiredPokerPlayer player1 = new AquiredPokerPlayer( _stub.Some <long>(), smallBlindPosition, _stub.Out <string>(For.HoleCards)) .AddRound( new AquiredPokerRound() .Add(action1) .Add(action3)); player1.Name = "player1"; player1.Position = smallBlindPosition; IAquiredPokerPlayer player2 = new AquiredPokerPlayer( _stub.Some <long>(), bigBlindPosition, _stub.Out <string>(For.HoleCards)) .AddRound( new AquiredPokerRound() .Add(action2) .Add(action4)); player2.Name = "player2"; player2.Position = bigBlindPosition; IAquiredPokerHand aquiredHand = new AquiredPokerHand( _stub.Valid(For.Site, "site"), _stub.Out <ulong>(For.GameId), _stub.Out <DateTime>(For.TimeStamp), smallBlind, bigBlind, totalPlayers) .AddPlayer(player1) .AddPlayer(player2); IConvertedPokerHand convertedHand = new ConvertedPokerHand(aquiredHand) .InitializeWith(aquiredHand) .AddPlayersFrom(aquiredHand, pot, _convertedPlayerMake); _converter .InitializeWith(aquiredHand, convertedHand, pot, toCall) .ConvertPreflop(); var player1FirstRound = convertedHand[smallBlindPosition][Streets.PreFlop]; var player2FirstRound = convertedHand[bigBlindPosition][Streets.PreFlop]; return(new RelativeRatioResult(convertedHand, player1FirstRound, player2FirstRound, relativeRatio1, relativeRatio2, relativeRatio3, relativeRatio4)); }
RelativeRatioResult ConvertPreflopThreePlayersHand() { _stub .Value(For.HoleCards).Is(string.Empty); const double smallBlind = 1.0; const double bigBlind = 2.0; const double pot = smallBlind + bigBlind; const int totalPlayers = 3; const int smallBlindPosition = 0; const int bigBlindPosition = 1; const int buttonPosition = 2; var action1 = new AquiredPokerAction(ActionTypes.B, bigBlind); const double relativeRatio1 = bigBlind / pot; const double pot1 = pot + bigBlind; var action2 = new AquiredPokerAction(ActionTypes.C, bigBlind); const double relativeRatio2 = bigBlind / pot1; const double pot2 = pot1 + bigBlind; var action3 = new AquiredPokerAction(ActionTypes.R, bigBlind * 3); const double relativeRatio3 = 3; const double pot3 = pot2 + (bigBlind * 3); var action4 = new AquiredPokerAction(ActionTypes.R, bigBlind * 3 * 2); const double relativeRatio4 = 2; const double pot4 = pot3 + (bigBlind * 3 * 2); var action5 = new AquiredPokerAction(ActionTypes.C, bigBlind * 3 * 2); const double relativeRatio5 = (bigBlind * 2 * 3) / pot4; var action6 = new AquiredPokerAction(ActionTypes.F, 1.0); // Small Blind IAquiredPokerPlayer player1 = new AquiredPokerPlayer( _stub.Some <long>(), smallBlindPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.C, 0.5))) // Flop .AddRound( new AquiredPokerRound() .Add(action1) .Add(action4)); player1.Name = "player1"; player1.Position = smallBlindPosition; // Big Blind IAquiredPokerPlayer player2 = new AquiredPokerPlayer( _stub.Some <long>(), bigBlindPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.X, 1.0))) // Flop .AddRound( new AquiredPokerRound() .Add(action2) .Add(action5)); player2.Name = "player2"; player2.Position = bigBlindPosition; // Button IAquiredPokerPlayer player3 = new AquiredPokerPlayer( _stub.Some <long>(), buttonPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.C, 1.0))) // Flop .AddRound( new AquiredPokerRound() .Add(action3) .Add(action6)); player3.Name = "player3"; player3.Position = buttonPosition; IAquiredPokerHand aquiredHand = new AquiredPokerHand( _stub.Valid(For.Site, "site"), _stub.Out <ulong>(For.GameId), _stub.Out <DateTime>(For.TimeStamp), smallBlind, bigBlind, totalPlayers) .AddPlayer(player1) .AddPlayer(player2) .AddPlayer(player3); IConvertedPokerHand convertedHand = new ConvertedPokerHand(aquiredHand) .AddPlayersFrom(aquiredHand, pot, _convertedPlayerMake); _converter .InitializeWith(aquiredHand, convertedHand, pot, bigBlind) .ConvertPreflop(); // Reset Values _converter.PotProp = pot; _converter.ToCallProp = bigBlind; _converter.ConvertFlopTurnAndRiver(); IConvertedPokerRound player1FlopRound = convertedHand[smallBlindPosition][Streets.Flop]; IConvertedPokerRound player2FlopRound = convertedHand[bigBlindPosition][Streets.Flop]; IConvertedPokerRound player3FlopRound = convertedHand[buttonPosition][Streets.Flop]; return(new RelativeRatioResult( convertedHand, player1FlopRound, player2FlopRound, player3FlopRound, relativeRatio1, relativeRatio2, relativeRatio3, relativeRatio4, relativeRatio5)); }