|
Britbot
|
Invokes the bot. Called from cshRunner.
Definition at line 59 of file Bot.cs. {
//update the game so other classes will get updated data
Bot.Game = state;
bool commanderOk = false;
try
{
/*
* NOTE: I changed the commander and Group classes so the do not move anything by themselves, they just return
* moving instructions in the form of a Dictionary<Pirate,Direction>. This is because we do not want to abort the commander
* after it moved couple of pirates but not all of them
*/
//run the commander and check if it returned true (so it went OK)
commanderOk = Bot.ExecuteBot();
}
catch (Exception ex) //catch any FATAL errors from the ExecuteBot method
{
Logger.Write("=================BOT ERROR=====================", true);
Logger.Write("Bot almost crashed because of exception: " + ex.Message, true);
//print the exception stack trace
StackTrace exTrace = new StackTrace(ex, true);
StackFrame frame = exTrace.GetFrame(0);
Logger.Write(
string.Format("The exception was thrown from method {0} at file {1} at line #{2}", frame.GetMethod(),
frame.GetFileName(), frame.GetFileLineNumber()), true);
Logger.Write("=================BOT ERROR=====================", true);
}
finally //whatever has happened there, move pirates so we will not crash
{
//Actually move stuff
if (commanderOk) //if the commander was OK, use its results
Mover.MoveAll(Bot._movesDictionary);
else //else use the fallback results
Mover.MoveAll(Bot._fallbackMoves);
}
}
|
1.7.6.1