private ICalculator Calculator( ICardAdapter pocket, IGetTurnExtendedContext context, IReadOnlyCollection <Card> communityCards) { var holeCardsOfOpponentsWhoAreInHand = new List <ICardAdapter>(); holeCardsOfOpponentsWhoAreInHand.Add(pocket); var deadCards = new List <Card>(); foreach (var item in context.Opponents) { if (item.InHand) { holeCardsOfOpponentsWhoAreInHand.Add(new Pocket(item.HoleCards)); } else { deadCards.AddRange(item.HoleCards); } } return(new Calculator( holeCardsOfOpponentsWhoAreInHand, deadCards, communityCards.ToList())); }
public void Update(ICardAdapter pocket, ICardAdapter communityCards, IGetTurnContext context, IBlackBox box) { this.pocket = pocket; this.normalization.Update(pocket, communityCards, context); this.GetTurnContext = context; this.BlackBox = box; this.isUpdated = true; }
public PlayerEconomy PlayerEconomy( ICardAdapter pocket, IGetTurnExtendedContext context, IReadOnlyCollection <Card> communityCards) { var calculator = this.Calculator(pocket, context, communityCards); var handEconomy = new HandEconomy(calculator); return(handEconomy.First(p => p.Hero.Pocket.Mask == pocket.Mask)); }
public NormalizedWinOdds(ICardAdapter pocket, ICardAdapter communityCards) { double[] heroWins; double[] opponentWins; HoldemHand.Hand.HandWinOdds(pocket.Mask, communityCards.Mask, out heroWins, out opponentWins); this.Initialize(heroWins, opponentWins); }
public void Update(ICardAdapter pocket, ICardAdapter communityCards, IGetTurnContext context) { var allChips = new List <int>(); var activeOpponents = context.Opponents.Where(p => p.InHand); System.Diagnostics.Debug.Assert(activeOpponents.Count() > 0, "There are no active players."); var activeStacks = activeOpponents .Select(s => s.Money + s.CurrentRoundBet) .Concat(new int[] { context.MoneyLeft + context.MyMoneyInTheRound }); var sortedStacks = activeStacks.OrderByDescending(k => k).Distinct().ToArray(); this.excessInThePot = 0; if (sortedStacks.Count() == 1) { this.secondStack = sortedStacks[0]; allChips.AddRange(activeOpponents.Select(s => s.Money)); allChips.AddRange(activeOpponents.Select(s => s.CurrentRoundBet)); allChips.AddRange(new[] { context.CurrentPot, context.MoneyLeft, context.MyMoneyInTheRound }); } else { this.secondStack = sortedStacks[1]; var currentPot = context.CurrentPot; if (context.MyMoneyInTheRound > this.secondStack) { this.excessInThePot = context.MyMoneyInTheRound - this.secondStack; currentPot = context.CurrentPot - this.excessInThePot; } else { foreach (var item in activeOpponents) { if (item.CurrentRoundBet > this.secondStack) { this.excessInThePot = item.CurrentRoundBet - this.secondStack; currentPot = context.CurrentPot - this.excessInThePot; break; } } } allChips.Add(currentPot); allChips.Add(this.secondStack); } this.maxMoneyAtTheTable = allChips.Max(s => s); this.pocket = pocket; this.communityCards = communityCards; this.getTurnContext = context; this.isUpdated = true; }
public override PlayerAction OptimalAction( ICardAdapter pocket, IGetTurnExtendedContext context, IReadOnlyCollection <Card> communityCards) { var playerEconomy = this.PlayerEconomy(pocket, context, communityCards); if (playerEconomy.NutHand) { return(this.ReactionCausedByNutHand(context, playerEconomy)); } else if (playerEconomy.BestHand) { return(this.ReactionCausedByBestHand(context, playerEconomy)); } else { return(this.ReactionCausedByWeakHand(context, playerEconomy)); } }
public ScheduleDialog(ICardAdapter cardAdapter, ISessionService sessionService) : base(Id) { _cardAdapter = cardAdapter; _sessionService = sessionService; Dialogs.Add(Id, new WaterfallStep[] { async(dc, args, next) => { var dialogState = dc.ActiveDialog.State as IDictionary <string, object>; var techBashLuisRecognizer = args["RecognizerResult"] as TechBashLuisRecognizerResult; // figure out speaker full name (seems like a bug) var speakerNames = techBashLuisRecognizer.Entities.speaker; if (techBashLuisRecognizer.Entities.SpeakerFullName?[0].speaker.Length > 0) { speakerNames = techBashLuisRecognizer.Entities.SpeakerFullName[0].speaker; } // query the session list for topic, speaker, date, etc var selectedSessions = _sessionService.GetSessions(techBashLuisRecognizer.Entities.topic, speakerNames, techBashLuisRecognizer.Entities.datetime); List <Attachment> cards = new List <Attachment>(); foreach (var session in selectedSessions) { var attachment = _cardAdapter.ToCard(session); cards.Add(attachment); } var activity = MessageFactory.Attachment(cards); await dc.Context.SendActivity(activity); dc.ActiveDialog.State = new Dictionary <string, object>(); // clear the dialog state await dc.End(); } }); // Define the prompts used in this conversation flow. Dialogs.Add("topicPrompt", new Microsoft.Bot.Builder.Dialogs.TextPrompt()); }
public override PlayerAction OptimalAction( ICardAdapter pocket, IGetTurnExtendedContext context, IReadOnlyCollection <Card> communityCards) { var startingHand = new StartingHand(pocket); if (context.CurrentStats.FourBet.IndicatorByStreets[context.RoundType].IsOpportunity) { return(this.ReactionToFourBetOpportunity(context, communityCards, startingHand)); } else if (context.CurrentStats.ThreeBet.IndicatorByStreets[context.RoundType].IsOpportunity) { return(this.ReactionToThreeBetOpportunity(context, communityCards, startingHand)); } else if (context.PreviousRoundActions.Count(x => x.Action.Type == PlayerActionType.Raise) == 0) { return(this.ReactionToOpenRaiseOpportunity(context, startingHand)); } else { // faced with four bet and more return(this.ReactionToFourBetOpportunity(context, communityCards, startingHand)); } }
public StartingHand(ICardAdapter pocket) { this.Pocket = pocket; }
public override void StartRound(IStartRoundContext context) { base.StartRound(context); this.communityCards = new CardAdapter(context.CommunityCards.ToList()); }
public override void StartHand(IStartHandContext context) { base.StartHand(context); this.pocket = new CardAdapter(new[] { context.FirstCard, context.SecondCard }); }
public ViewScroller(ViewPager viewPager, ICardAdapter adapter) { mViewPager = viewPager; viewPager.AddOnPageChangeListener(this); mAdapter = adapter; }
public HandStrength(ICardAdapter pocket, double equity) { this.Pocket = pocket; this.Equity = equity; }
public abstract PlayerAction OptimalAction( ICardAdapter pocket, IGetTurnExtendedContext context, IReadOnlyCollection <Card> communityCards);