本文整理汇总了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;
}
}
示例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;
}
}
}