当前位置: 首页>>代码示例>>C#>>正文


C# Single.Sum方法代码示例

本文整理汇总了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]);
            }
        }
开发者ID:JordanFisher,项目名称:Texas-Holdem-Nash-Solver,代码行数:45,代码来源:Junction.cs

示例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]);
            }
        }
开发者ID:JordanFisher,项目名称:Texas-Holdem-Nash-Solver,代码行数:54,代码来源:Junction.cs


注:本文中的System.Single.Sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。