public HandSnapshotModel(HoldemHandRound round, int button, bool[] active, ActiveStatus[] status, float[] bets, float[] stacks, int? currentPlayer) { Round = round; Button = button; Active = active; Stacks = stacks; Bets = bets; Status = status; CurrentPlayer = currentPlayer; for (int i = 0; i < active.Length; i++) { if (!active[i]) { Status[i] = ActiveStatus.HasFolded; Bets[i] = 0; } } int start = CurrentPlayer != null ? (int)CurrentPlayer : BetPolicyService.GetRoundStart(round, button, stacks.Length); NextPlayer = BetPolicyService.GetNextActivePlayer(status, bets, start); NumPlayersInHand = status.Count(x => x != ActiveStatus.HasFolded); NumPlayersActive = status.Count(x => x != ActiveStatus.HasFolded && x != ActiveStatus.AllIn); IsRoundEnd = NextPlayer == null; IsHandEnd = NumPlayersActive == 0 || NumPlayersInHand == 1 || IsRoundEnd && round == HoldemHandRound.River; }
/// <summary> /// Constructor /// </summary> /// <param name="table">The table upon which the players for this scenario are seated</param> /// <param name="round">The current round of betting</param> /// <param name="policy">Policy information dictating what the player can and can't do</param> public DefaultNodeDataModel(PlayerModel player, HoldemHandRound round, BetTypeModel betType) : base(betType) { Player = player; Round = round; Icon = Utilities.LoadBitmap(Properties.Resources.DefaultNodeIcon); InfoDisplayType = typeof(BetTreeNodeInfo); }
/// <summary> /// Constructor /// </summary> /// <param name="table">The table upon which the players for this scenario are seated</param> /// <param name="round">The current round of betting</param> /// <param name="policy">Policy information dictating what the player can and can't do</param> public RandomBetModel(PlayerModel player, HoldemHandRound round, BetTypeModel betType) : base(betType) { Player = player; Round = round; Random = 100; Icon = Utilities.LoadBitmap(Properties.Resources.RandomBetIcon); InfoDisplayType = typeof(BetTreeNodeInfo); }
/// <summary> /// Constructor /// </summary> /// <param name="table">The table upon which the players for this scenario are seated</param> /// <param name="round">The current round of betting</param> /// <param name="policy">Policy information dictating what the player can and can't do</param> public PreflopBetModel(PlayerModel player, HoldemHandRound round, BetTypeModel betType) : base(betType) { Player = player; Round = round; Icon = Utilities.LoadBitmap(Properties.Resources.PreflopBetIcon); Range = new HandRangeModel(); InfoDisplayType = typeof(BetTreeNodeInfo); }
/// <summary> /// Constructor /// </summary> public HandValueRangeModel(HoldemHandRound round, HandRange range) { Round = round; HandRange = range; List<ConditionService> conditions = new List<ConditionService>(); conditions.Add(ConditionService.DefaultService); conditions.AddRange(ConditionService.AvailableConditionSets.Select(x => new ConditionService(x, true))); ConditionSets = conditions; SelectedConditionSet = ConditionService.DefaultService; SampleRanges = RzrDataService.Service.HandValueRanges.Where(x => x.Round == round && x.ConditionSet == SelectedConditionSet.Name).ToList(); if (SampleRanges.Count > 0) SelectedRangeRanking = SampleRanges[0]; UpdateRange(); }
public static int GetRoundStart(HoldemHandRound round, int button, int numPlayers) { return round == HoldemHandRound.PreFlop ? (button + 3) % numPlayers : (button + 1) % numPlayers; }
private void SetGridStartForRound(HoldemHandRound round) { ((Canvas)StartGrid.Parent).Children.Remove(StartGrid); StartGrid = new TreeGridStart(); _canvases[round].Children.Add(StartGrid); }
protected void UpdateNodePositions(HoldemHandRound round) { Canvas canvas = _canvases[round]; double width = 0; double height = 0; foreach (TreeGridStart child in canvas.Children) { if (child.Width > width) width = child.Width; double itemTop = child.LinkedItem == null ? height : GetGridStartTop(child.LinkedItem); Canvas.SetTop(child, itemTop); Canvas.SetLeft(child, 0); height += child.Height; } canvas.Width = width; canvas.Height = height; double colWidth = canvas.Width < 50 ? 50 : canvas.Width; _columns[canvas].Width = new GridLength(colWidth); }
private void ClearGrid(HoldemHandRound round) { foreach (UIElement el in _canvases[round].Children) { if (el is TreeGridStart) { TreeGridStart start = el as TreeGridStart; List<TreeGridItem> remove = new List<TreeGridItem>(); foreach (TreeGridItem item in start.MainGrid.Children) remove.Add(item); foreach (TreeGridItem item in remove) RemoveItem(start.MainGrid, item); } } }
protected void UpdateNodeLines(HoldemHandRound round) { foreach (TreeGridLine line in _lines) { UIElement startElement = line.Start.GetLineStart(); UIElement endElement = line.End.GetLineEnd(); Point start = startElement.TranslatePoint(new Point(0, 0), UnderlayCanvas); Point end = endElement.TranslatePoint(new Point(0, 0), UnderlayCanvas); double startX = start.X + startElement.RenderSize.Width / 2; double startY = start.Y + startElement.RenderSize.Height / 2; double endX = end.X + endElement.RenderSize.Width / 2; double endY = end.Y + endElement.RenderSize.Height / 2; double offset = 20; line.Line1.X1 = startX; line.Line1.Y1 = startY; line.Line1.X2 = endX - offset; line.Line1.Y2 = startY; line.Line1.Visibility = (line.End.Visibility == Visibility.Visible && line.Start.Model.IsExpanded) ? Visibility.Visible : Visibility.Hidden; line.Line2.X1 = endX - offset; line.Line2.Y1 = startY; line.Line2.X2 = endX - offset; line.Line2.Y2 = endY; line.Line2.Visibility = (line.End.Visibility == Visibility.Visible && line.Start.Model.IsExpanded) ? Visibility.Visible : Visibility.Hidden; line.Line3.X1 = endX - offset; line.Line3.Y1 = endY; line.Line3.X2 = endX; line.Line3.Y2 = endY; line.Line3.Visibility = (line.End.Visibility == Visibility.Visible &&line.Start.Model.IsExpanded) ? Visibility.Visible : Visibility.Hidden; } }
protected void UpdateCanvas(HoldemHandRound round) { UpdateNodePositions(round); UpdateNodeLines(round); }
private string GetRoundName(HoldemHandRound round) { switch (round) { case HoldemHandRound.PreFlop: return "PF"; case HoldemHandRound.Flop: return "F"; case HoldemHandRound.Turn: return "R"; case HoldemHandRound.River: return "R"; } return null; }
private IEnumerable<TreePartialMeta> GetComputedPartials(int activePlayers, HoldemHandRound currentRound) { return _computed.Where(x => x.StartRound == currentRound); }
protected BetTreeNodeModel AddPostflopStandard(BetTreeNodeModel parent, HoldemHandRound round, int player) { BetTypeModel betModel = new BetTypeModel(parent.Policy); BetTreeNodeStyle style = _roundStyles[round]; BetTreeNodeModel model = new BetTreeNodeModel(parent.Tree, _nodeStyles[typeof(PreflopBetModel)], style, parent.Snapshot, parent); betModel.AssociatePolicy(model); ObservableCollection<BetTreeDataNodeMeta> metaList = new ObservableCollection<BetTreeDataNodeMeta>(); metaList.Add(new BetTreeDataNodeMeta(POSTFLOP_NODE_META, new PostFlopBetModel(_players[player], round, betModel))); metaList.Add(new BetTreeDataNodeMeta(RESULT_NODE_META, new ManualResultsModel(model))); metaList.Add(new BetTreeDataNodeMeta(SHOWDOWN_NODE_META, new ShowdownModel(parent.Snapshot))); model.AllowedNodeTypes = metaList; model.Meta = POSTFLOP_NODE_META; return model; }