本文整理匯總了C#中Agent.UpdateGrid方法的典型用法代碼示例。如果您正苦於以下問題:C# Agent.UpdateGrid方法的具體用法?C# Agent.UpdateGrid怎麽用?C# Agent.UpdateGrid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Agent
的用法示例。
在下文中一共展示了Agent.UpdateGrid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RunGameInBrowser
private static void RunGameInBrowser()
{
using (var game = new GamePage())
{
var agent = new Agent(game.GridState, new ProbabilityLimitedExpectiMaxerFactory(), new VictorHeuristic());
try
{
while (true)
{
var result = agent.MakeDecision();
game.Turn(result.BestMove);
agent.UpdateGrid(game.GridState);
}
}
catch (GameOverException)
{
game.TakeScreenshot().SaveAsFile("game_" + game.Score + ".png", ImageFormat.Png);
Console.WriteLine(game.Score);
}
}
}
示例2: RunGameInConsole
private static LogarithmicGrid RunGameInConsole()
{
var logGrid = new LogarithmicGrid(new byte[4, 4]).AddRandomTile().AddRandomTile();
var agent = new Agent(logGrid, new ProbabilityLimitedExpectiMaxerFactory(), new OvolveHeuristic());
try
{
int counter = 0;
while (true)
{
counter++;
var startTime = SystemClock.Instance.Now;
Console.WriteLine("Start next move calculation...");
var result = agent.MakeDecision();
var elapsed = SystemClock.Instance.Now - startTime;
Console.Clear();
Console.WriteLine("End move calcualtion, time taken: {0}", elapsed.ToString("ss.fff", CultureInfo.InvariantCulture));
Console.WriteLine();
Console.WriteLine(result);
PrintTimings(agent);
logGrid = logGrid.MakeMove(result.BestMove).AddRandomTile();
agent.UpdateGrid(logGrid);
}
}
catch (GameOverException)
{
Console.WriteLine("GAME OVER!");
}
return logGrid;
}