/// <summary> /// Get the results from one particular node into the structure /// </summary> public static ReportLine CreateReportLineForNode(IServerNode node, IServerPluginContext context) { var result = new ReportLine(); var OOP = context.ServerUtils.OOP; var IP = context.ServerUtils.IP; //the board result.Board = node.Board; // Calculate IP and OOP ev and equity in the node. // The result for EV calculation is two ranges // one range is sums and the other is matchups // EV for a given hand can be calculated by dividing // sums by matchups. // The total EV in node can be obtained by diving // total sums in the node by total counters var evIP = context.ServerWrapper.CalcEVInNode(IP, node); var evOOP = context.ServerWrapper.CalcEVInNode(OOP, node); result.EVOOPSums = evOOP.TotalWins(); result.EVOOPMatchups = evOOP.TotalMatchups(); result.EVIPSums = evIP.TotalWins(); result.EVIPMatchups = evIP.TotalMatchups(); var eqIP = context.ServerWrapper.CalcEquityInNode(IP, node); var eqOOP = context.ServerWrapper.CalcEquityInNode(OOP, node); result.EQOOPSums = eqOOP.TotalWins(); result.EQOOPMatchups = eqOOP.TotalMatchups(); result.EQIPSums = eqIP.TotalWins(); result.EQIPMatchups = eqIP.TotalMatchups(); // If the node is action node (e.g. - not a street split node nor final node) // then we also compute how often given action is selected if (node.ActionPlayer != null) { // we ask server to list all children of a current node var actions = context.ServerWrapper.ShowChildren(node); foreach (var action in actions) { // for each child we ask for the range of an action player var rangeForAction = context.ServerWrapper.ShowRange(node.ActionPlayer, action); // and store it in the result dictionary // NodeText property denotes the action (e.g. CHECK or BET 100) result.ActionFrequencies[action.NodeText] = rangeForAction.TotalWeights(); // Node name is stored separately to preserve the action's order result.ActionNames.Add(action.NodeText); } } return(result); }
/// <summary> /// Sum the results in a single structure /// </summary> /// <param name="fullReport"></param> /// <returns></returns> public static ReportLine ToSummaryCSVLine(List <ReportLine> fullReport) { var result = new ReportLine(); if (fullReport.Count > 0) { result.ActionNames = fullReport[0].ActionNames; } foreach (var line in fullReport) { if (result.Board == null) { result.Board = new Card[line.Board.Length]; for (int i = 0; i < 3; i++) { result.Board[i] = line.Board[i]; } } foreach (var actionName in line.ActionFrequencies.Keys) { if (!result.ActionFrequencies.ContainsKey(actionName)) { result.ActionFrequencies[actionName] = 0; } result.ActionFrequencies[actionName] += line.ActionFrequencies[actionName]; } result.EVIPMatchups += line.EVIPMatchups; result.EVIPSums += line.EVIPSums; result.EVOOPMatchups += line.EVOOPMatchups; result.EVOOPSums += line.EVOOPSums; result.EQIPMatchups += line.EQIPMatchups; result.EQIPSums += line.EQIPSums; result.EQOOPMatchups += line.EQOOPMatchups; result.EQOOPSums += line.EQOOPSums; } return(result); }
/// <summary> /// Generate the full report /// </summary> private void GenerateReport() { ReportBuilder.AppendLine(""); ProgressProvider.UpdateProgress("list nodes"); if (CFRFilePaths == null) { CFRFilePaths = new List <string>(); CFRFilePaths.Add(null); } int loop = 0; int loops = CFRFilePaths.Count; foreach (var path in CFRFilePaths) { loop++; if (path != null) { ProgressProvider.UpdateProgress("Load file " + loop + " out of " + loops); Context.ServerWrapper.LoadTree(path); Node = Context.ServerWrapper.RefreshNode(Node); } var similarNodes = FindSimilarNodesOnOtherBoards(Node); int total = similarNodes.Count; int progressNodeCount = 0; var root = Context.ServerWrapper.ShowRootNode(); var rootMatchups = Context.ServerWrapper.CalcEquityInNode(Context.ServerUtils.IP, root).TotalMatchups(); var results = new List <ReportLine>(); foreach (var singleNode in similarNodes) { progressNodeCount++; if (ProgressProvider.CancelRequested) { return; } if (loops > 1) { ProgressProvider.UpdateProgress("file " + loop + " out of " + loops + ". Analyse " + string.Join("", singleNode.Board.ToList()) + " " + progressNodeCount + " out of " + total); } else { ProgressProvider.UpdateProgress("Analyze " + string.Join("", singleNode.Board.ToList()) + " " + progressNodeCount + " out of " + total); } results.Add(ReportLine.CreateReportLineForNode(singleNode, this.Context)); } var summaryResult = ReportLine.ToSummaryCSVLine(results); if (loop == 1) { ReportBuilder.AppendLine(string.Join(",", GenerateHeaderNames(summaryResult.ActionNames))); } if (results.Count > 1) { ReportBuilder.AppendLine(string.Join(",", summaryResult.ToCSVLine(rootMatchups))); } foreach (var resultLine in results) { ReportBuilder.AppendLine(string.Join(",", resultLine.ToCSVLine(rootMatchups))); } } }