protected void createFrequencyValues() { groupedFrequencies = new Dictionary <string, FrequencyValues>(); // iterate over all the handgroups (one handgroup per handstrengthorder) foreach (KeyValuePair <int, List <Hand> > handGroup in groupedHands) { // iterate over all the hands in the handstrength group foreach (Hand hand in handGroup.Value) { // iterate over the different betting frequencies for the hand foreach (KeyValuePair <string, float> frequency in hand.Frequencies) { FrequencyValues freqValues; if (groupedFrequencies.TryGetValue(frequency.Key, out freqValues)) { freqValues.AddFrequency(handGroup.Key, frequency.Value, hand.Weight); } else { FrequencyValues newFreqValues = new FrequencyValues(frequency.Key); newFreqValues.AddFrequency(handGroup.Key, frequency.Value, hand.Weight); groupedFrequencies.Add(frequency.Key, newFreqValues); } } } } }
public void addHand(Hand reportHand) { // add the hand in the grouped hands dictionary (ordered by handstrengthorder) List <Hand> hands; if (groupedHands.TryGetValue(reportHand.Strength.StrengthOrder, out hands)) { hands.Add(reportHand); } else { List <Hand> newList = new List <Hand>(); newList.Add(reportHand); groupedHands.Add(reportHand.Strength.StrengthOrder, newList); strengthLabels.Add(reportHand.Strength.StrengthOrder, reportHand.Strength.StrengthLabel); } // add the hand frequencies in the frequencyvalues dictionary (ordered by frequencylabel) Dictionary <string, float> .KeyCollection freqlabels = reportHand.Frequencies.Keys; foreach (string freqLabel in freqlabels) { FrequencyValues frequencyValues; if (groupedFrequencies.TryGetValue(freqLabel, out frequencyValues)) { frequencyValues.AddFrequency(reportHand); } else { FrequencyValues newFreqValues = new FrequencyValues(freqLabel); newFreqValues.AddFrequency(reportHand); groupedFrequencies.Add(freqLabel, newFreqValues); } } }
static void TestAverages() { Timer totalTimer = new Timer("Total execution"); Timer parseTimer = new Timer("Parsing CSV content"); Timer strengthTimer = new Timer("Calculating handstrength"); Timer outputTimer = new Timer("Writing output"); totalTimer.start(); ReportReader reader = new ReportReader("E:\\PIOprocessing\\Reports"); outputTimer.start(); OutputFile testOutput = new OutputFile("E:\\PIOprocessing\\test.csv"); outputTimer.stop(); foreach (Report report in reader.Reports) { // outputTimer.start(); report.GenerateHandsFile(testOutputDir); // outputTimer.stop(); string reportName = report.GetReportDirectory(); foreach (KeyValuePair <HandType, HandGroup> handType in report.HandTypes) { foreach (string freqLabel in handType.Value.GetFrequencyLabels()) { FrequencyValues freqValues = handType.Value.GetFrequencyValues(freqLabel); string[] outputLine = new string[freqValues.GetHandStrengthOrders().Length + 3]; outputLine[0] = reportName; outputLine[1] = handType.Key.ToString(); outputLine[2] = freqLabel; int index = 3; foreach (int order in freqValues.GetHandStrengthOrders()) { outputLine[index] = freqValues.GetFrequency(order).ToString(); index++; } testOutput.writeCsvLine(outputLine); } } } totalTimer.stop(); totalTimer.log(); }
public void LoadPlotModel(HandType type) { string title = $"{Report.Spot.Action} {Report.Spot.AggPos}vs{Report.Spot.CllPos} {Report.Spot.BoardType} {Report.Spot.BoardSubtype} {type}"; PlotModel = new PlotModel { Title = title, TitleColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour, LegendTextColor = ThemeModel.OxyForegroundColour, PlotAreaBorderColor = ThemeModel.OxyForegroundColour }; OxyPlot.Axes.LinearAxis yAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, MajorStep = 10, MinorStep = 10, Minimum = 0, Maximum = 100, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour }; OxyPlot.Axes.LinearAxis xAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour }; // CategoryAxis catAxis = new CategoryAxis( {Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1); xAxis.LabelFormatter = getXLabel; PlotModel.Axes.Add(xAxis); PlotModel.Axes.Add(yAxis); handGroup = Report.GetHandGroup(type); string[] frequencyLabels = handGroup.GetFrequencyLabels(); foreach (string frequencyLabel in frequencyLabels) { List <DataPoint> pointsList = new List <DataPoint>(); FrequencyValues freqValues = handGroup.GetFrequencyValues(frequencyLabel); foreach (int order in freqValues.GetHandStrengthOrders()) { pointsList.Add(new DataPoint(order, freqValues.GetFrequency(order))); } LineSeries series = new LineSeries() { InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline, Title = frequencyLabel, ItemsSource = pointsList, MarkerSize = 5, MarkerType = MarkerType.Circle }; PlotModel.Series.Add(series); } }