public static double CellVsSpectrums(string heroCell, HandSpectrumCell[] opp1Spectrum, HandSpectrumCell[] opp2Spectrum = null) { if (heroCell.Length == 2 && opp2Spectrum != null) { bool holeLine1 = opp1Spectrum.Count(e => e.CellSymbol.Contains(heroCell[0])) == opp1Spectrum.Length; bool holeLine2 = opp2Spectrum.Count(e => e.CellSymbol.Contains(heroCell[0])) == opp1Spectrum.Length; bool hasSameCell1 = opp1Spectrum.Count(e => e.CellSymbol == heroCell) != 0; bool hasSameCell2 = opp2Spectrum.Count(e => e.CellSymbol == heroCell) != 0; if (hasSameCell1 && holeLine2) { opp1Spectrum = opp1Spectrum.Where(e => e.CellSymbol != heroCell).ToArray(); } if (hasSameCell2 && holeLine1) { opp2Spectrum = opp2Spectrum.Where(e => e.CellSymbol != heroCell).ToArray(); } } IAsyncResult[] results = new IAsyncResult[1000]; CalculateOddsDelegate d = new CalculateOddsDelegate(CalculateOdds); long wins = 0, ties = 0, ties2 = 0, total = 0; ulong[] heroPockets = PocketHands.Query(heroCell); var opp1Sp = new CellsArray(opp1Spectrum); CellsArray opp2Sp = null; if (opp2Spectrum != null) { opp2Sp = new CellsArray(opp2Spectrum); } for (int i = 0; i < results.Length; i++) { results[i] = d.BeginInvoke(heroPockets, opp1Sp, opp2Sp, null, null); } var situations = new Dictionary <string, long>(); for (int i = 0; i < results.Length; i++) { Results r = d.EndInvoke(results[i]); wins += r.win; ties += r.ties; ties2 += r.ties2; total += r.total; } return((double)(wins + ties / 2 + ties2 / 3) / total * 100); }
public CellsArray(HandSpectrumCell[] spectrum) { double weightSum = spectrum.Sum(c => c.Weight); double lastWeight = 0; var hList = new List <ulong>(); for (int i = 0; i < spectrum.Length; i++) { double currentWeight = spectrum[i].Weight / weightSum; lastWeight += currentWeight; var cell = PocketHands.Query(spectrum[i].CellSymbol); Cells.Add(lastWeight, cell); for (int j = 0; j < currentWeight * 100; j++) { hList.Add(Hand.RandomHand(cell, 0UL, 2)); } } HandsList = hList.ToArray(); }
/// <exclude/> public SpecDoc_2_1(Parser yyq):base(yyq){yylval = new PocketHands();}}