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


C# State.IsWin方法代码示例

本文整理汇总了C#中State.IsWin方法的典型用法代码示例。如果您正苦于以下问题:C# State.IsWin方法的具体用法?C# State.IsWin怎么用?C# State.IsWin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State.IsWin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EvaluateWithWeights

        // Evaluation function
        public static double EvaluateWithWeights(State state, WeightVector weights)
        {
            if (state.IsGameOver()) return GetLowerBound(weights) - 10;
            else
            {
                double corner = 0, emptycells = 0, highestvalue = 0, monotonicity = 0, points = 0, smoothness = 0, snake = 0, trappedpenalty = 0;
                // Only do the heuristic calculation if the weight is not 0 (avoid unnescessary work)
                if(((WeightVectorAll)weights).Corner != 0) corner = Corner(state);
                if(((WeightVectorAll)weights).Empty_cells != 0) emptycells = EmptyCells(state);
                if(((WeightVectorAll)weights).Highest_tile != 0) highestvalue = HighestValue(state);
                if(((WeightVectorAll)weights).Monotonicity != 0) monotonicity = Monotonicity(state);
                if(((WeightVectorAll)weights).Points != 0) points = Points(state);
                if(((WeightVectorAll)weights).Smoothness != 0) smoothness = Smoothness(state);
                if(((WeightVectorAll)weights).Snake != 0) snake = WeightSnake(state);
                if(((WeightVectorAll)weights).Trapped_penalty != 0) trappedpenalty = TrappedPenalty(state);

                // evaluation function is a linear combination of heuristic values and their weights
                double eval = ((WeightVectorAll)weights).Corner * corner + ((WeightVectorAll)weights).Empty_cells * emptycells + ((WeightVectorAll)weights).Highest_tile * highestvalue
                    + ((WeightVectorAll)weights).Monotonicity * monotonicity + ((WeightVectorAll)weights).Points * points + ((WeightVectorAll)weights).Smoothness * smoothness
                    + ((WeightVectorAll)weights).Snake * snake - ((WeightVectorAll)weights).Trapped_penalty * trappedpenalty;

                if (state.IsWin())
                {
                    return eval + 10;
                }
                else return eval;
            }
        }
开发者ID:kstrandby,项目名称:2048-AI,代码行数:29,代码来源:AI.cs

示例2: Evaluate

        // Simple evaluation function only using Snake heuristic
        public static double Evaluate(State state)
        {
            if (state.IsGameOver())
            {
                return -1000;
            }
            else
            {
                double eval = WeightSnake(state);

                if (state.IsWin())
                    return eval + 1000;
                else
                {
                    return eval;
                }
            }
        }
开发者ID:kstrandby,项目名称:2048-AI,代码行数:19,代码来源:AI.cs


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