本文整理汇总了C#中System.Single.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# Single.Sum方法的具体用法?C# Single.Sum怎么用?C# Single.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Single
的用法示例。
在下文中一共展示了Single.Sum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateBestAgainst_Naive
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]);
}
}
示例2: CalculateBestAgainst_FlopSuitReduced
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]);
}
}