本文整理汇总了C#中IGame.GenerateAllMoves方法的典型用法代码示例。如果您正苦于以下问题:C# IGame.GenerateAllMoves方法的具体用法?C# IGame.GenerateAllMoves怎么用?C# IGame.GenerateAllMoves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGame
的用法示例。
在下文中一共展示了IGame.GenerateAllMoves方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeMoves
public List<IPlayerMove> MakeMoves(IGame game)
{
var result = (from move in game.GenerateAllMoves().Shuffle()
let scoredMove = ScoreMove(game, move)
orderby scoredMove.Score descending
select scoredMove);
return new List<IPlayerMove> {result.First().Move};
}
示例2: PrintAllMoves
private static void PrintAllMoves(IGame game)
{
var allMoves = game.GenerateAllMoves();
if (game.CurrentPhase == GamePhase.Play || allMoves.Count() < 10)
{
PrintMoves(ConsoleColor.Yellow, allMoves);
}
else // game.CurrentPhase == Setup1 & Setup 2
{
ColorConsole.WriteLine(ConsoleColor.Yellow, "Example move: {0}", ImprovedEMN.Instance.MakeMoves(game)[0]);
}
}
示例3: MakeMoves
public List<IPlayerMove> MakeMoves(IGame game)
{
if (game.CurrentPhase != GamePhase.Play)
{
return _setupPlayer.MakeMoves(game);
}
IEnumerable<ScoredMove> result = (from move in game.GenerateAllMoves().Shuffle()
select ScoreMove(game, move));
IOrderedEnumerable<ScoredMove> result2 = (from scoredMove in result
orderby scoredMove.Score descending
select scoredMove);
return new List<IPlayerMove> {result2.First().Move};
}
示例4: SearchBestMoves
private GameState SearchBestMoves(IGame game, int depth, int playerIndex)
{
if ((game.CurrentUniversityIndex == playerIndex && game.HasWinner())
|| depth == 0)
{
return new GameState(Evaluate(game));
}
var allMoves = game.GenerateAllMoves();
if (allMoves.Count() == 1 && playerIndex == game.CurrentUniversityIndex)
{
return new GameState(allMoves.First(), Evaluate(game));
}
var bestMoves = new GameState(game.NumberOfUniversities, double.MinValue);
foreach (IPlayerMove move in allMoves)
{
if (move is IProbabilityPlayerMove)
{
var expectedScores = new GameState(game.NumberOfUniversities, 0);
double totalProbability = 0.0;
foreach (var possibleMove in ((IProbabilityPlayerMove) move).AllProbabilityMoves)
{
var thisProbability = possibleMove.Probability.Value;
if (thisProbability < 0.06)
{
continue; // skip 2, 12, 3, 11 for end turn
}
totalProbability += thisProbability;
GameState nextScores = GetNextScores(game, depth, playerIndex, possibleMove);
for (int i = 0; i < expectedScores.Scores.Length; ++i)
{
expectedScores[i] += thisProbability*nextScores[i];
}
}
for (int i = 0; i < game.NumberOfUniversities; ++i)
{
expectedScores[i] /= totalProbability;
}
// trust it with probability
if (_random.NextDouble() < totalProbability)
{
bestMoves.TakeIfBetter(expectedScores, game.CurrentUniversityIndex, move);
}
}
else //move is BuildCampusMove || move is BuildLinkMove || move is TradingMove)
{
GameState nextScores = GetNextScores(game, depth, playerIndex, move);
bestMoves.TakeIfBetter(nextScores, game.CurrentUniversityIndex, move);
}
}
return bestMoves;
}
示例5: SearchBestMoves
private GameState SearchBestMoves(IGame game, int depth)
{
if (game.HasWinner() || depth == 0)
{
return new GameState(Evaluate(game));
}
var allMoves = game.GenerateAllMoves();
if (allMoves.Count() == 1)
{
return new GameState(allMoves.First(), Evaluate(game));
}
var bestMoves = new GameState(game.NumberOfUniversities, double.MinValue);
int currentUniversityIndex = game.CurrentUniversityIndex;
foreach (var move in allMoves)
{
if (move is IBuildCampusMove || move is IBuildLinkMove || move is ITradingMove)
{
game.ApplyMove(move);
GameState nextScoredMoves = SearchBestMoves(game, depth - 1);
game.UndoMove();
bestMoves.TakeIfBetter(nextScoredMoves, currentUniversityIndex, move);
}
else if (move is IProbabilityPlayerMove)
{
var expectedScores = new GameState(game.NumberOfUniversities, 0);
foreach (IProbabilityPlayerMove possibleMove in ((IProbabilityPlayerMove) move).AllProbabilityMoves)
{
game.ApplyMove(possibleMove);
GameState nextScores = SearchBestMoves(game, depth - 1);
game.UndoMove();
for (int i = 0; i < expectedScores.Scores.Length; ++i)
{
expectedScores[i] += possibleMove.Probability.Value*nextScores[i];
}
}
bestMoves.TakeIfBetter(expectedScores, currentUniversityIndex, move);
}
}
return bestMoves;
}