void CalculateBestAgainst_Naive(Player Opponent) { // First decide strategy for children nodes. RecursiveBest(Opponent); // For each pocket we might have, calculate what we should do. PocketData UpdatedP = new PocketData(); for (int p1 = 0; p1 < Pocket.N; p1++) { if (!MyCommunity.AvailablePocket[p1]) continue; // Update the opponent's pocket PDF using the new information, // (which is that we now know which pocket we have). UpdateOnExclusion(PocketP, UpdatedP, p1); // Calculate the EV assuming we proceed to a branch. // Loop through each possible opponent pocket and then each possible branch, // summing up the EV of each branch times the probability of arriving there. number TotalWeight = 0, BranchEV = 0; number[] BranchPDF = new number[Branches.Count]; for (int p2 = 0; p2 < Pocket.N; p2++) { if (!MyCommunity.AvailablePocket[p2]) continue; // All branches not overlapping our pocket or the opponent's pocket are equally likely. int BranchIndex = 0; foreach (Node Branch in Branches) { BranchIndex++; if (!Branch.MyCommunity.AvailablePocket[p1] || !Branch.MyCommunity.AvailablePocket[p2]) continue; number Weight = Branch.Weight; BranchEV += UpdatedP[p2] * Weight * Branch.EV[p1]; TotalWeight += UpdatedP[p2] * Weight; BranchPDF[BranchIndex - 1] += UpdatedP[p2] * Weight; } } Assert.ZeroOrOne(BranchPDF.Sum()); Assert.ZeroOrOne(TotalWeight); Assert.That(BranchEV >= -DerivedSetup.MaxPot - Tools.eps && BranchEV <= DerivedSetup.MaxPot + Tools.eps); EV[p1] = BranchEV; Assert.IsNum(EV[p1]); } }
void CalculateBestAgainst_FlopSuitReduced(Player Opponent) { System.Threading.Tasks.Parallel.ForEach(Branches, node => node.CalculateBestAgainst(Opponent)); //foreach (Node node in Branches) // node.CalculateBestAgainst(Opponent); // For each pocket we might have, calculate what we should do. PocketData UpdatedP = new PocketData(); for (int p1 = 0; p1 < Pocket.N; p1++) { if (!MyCommunity.AvailablePocket[p1]) continue; // Update the opponent's pocket PDF using the new information, // (which is that we now know which pocket we have). UpdateOnExclusion(PocketP, UpdatedP, p1); // Calculate the EV assuming we proceed to a branch. // Loop through each possible opponent pocket and then each possible branch, // summing up the EV of each branch times the probability of arriving there. number TotalWeight = 0, BranchEV = 0; number[] BranchPDF = new number[Branches.Count]; for (int p2 = 0; p2 < Pocket.N; p2++) { if (!MyCommunity.AvailablePocket[p2]) continue; // All branches not overlapping our pocket or the opponent's pocket are equally likely. // However, because we have grouped some branches together we weight representative branches more heavily. int b = 0; foreach (Node Branch in Branches) { b++; if (Branch.MyCommunity.NewCollision(p1) || Branch.MyCommunity.NewCollision(p2)) continue; FlopRoot FlopBranch = (FlopRoot)Branch; FlopRoot _Branch = FlopBranch.Representative; int _p1 = FlopBranch.MyFlop.PocketMap[p1]; //Assert.AlmostEqual(Branch.EV[p1], _Branch.EV[_p1], .05); number Weight = _Branch.Weight; BranchEV += UpdatedP[p2] * Weight * _Branch.EV[_p1]; TotalWeight += UpdatedP[p2] * Weight; BranchPDF[b - 1] += UpdatedP[p2] * Weight; } } Assert.ZeroOrOne(BranchPDF.Sum()); Assert.ZeroOrOne(TotalWeight); Assert.That(BranchEV >= -DerivedSetup.MaxPot - Tools.eps && BranchEV <= DerivedSetup.MaxPot + Tools.eps); EV[p1] = BranchEV; Assert.IsNum(EV[p1]); } }