本文整理汇总了C#中IBoard.Aggregate方法的典型用法代码示例。如果您正苦于以下问题:C# IBoard.Aggregate方法的具体用法?C# IBoard.Aggregate怎么用?C# IBoard.Aggregate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBoard
的用法示例。
在下文中一共展示了IBoard.Aggregate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Score
protected virtual float Score(IBoard board)
{
return
board
//.Where(node => node.State.ToUnit(board.Player) > 0)
.Aggregate(0,
(score, node) =>
score + (int)node.State.ToUnit(board.Player));
}
示例2: Score
protected override float Score(IBoard board)
{
return
board
.Aggregate(0f,
(score, node) =>
{
var unit = node.State.ToUnit(board.Player);
return score + scores[unit];
});
}
示例3: Score
protected virtual float Score(IBoard board)
{
return
board
.Aggregate(0f,
(score, node) =>
{
var unit = node.State.ToUnit(board.Player);
switch (unit)
{
case Unit.AlienAlive: return score - 2;
case Unit.AlienAliveZombie: return score - 4;
case Unit.AlienZombie: return score + 1;
case Unit.AllyAlive: return score + 2;
case Unit.AllyAliveZombie: return score + 4;
case Unit.AllyZombie: return score - 1;
case Unit.None: return score;
default: return score;
}
});
}