private void RunBotAndGetNextMove() { if (_totalDoNothingCommands >= 10) { Logger.LogInfo( "Bot is sending to many do nothing commands, in order to save the game the player will plant a bomb and kill itself soon"); } if (_totalDoNothingCommands >= 20) { Logger.LogInfo( "Bot sent to many do nothing commands, something is most likely going wrong, please fix your bot. Your player will now attempt to kill itself to save the game."); } if (_totalDoNothingCommands == 21) { PublishCommand(new TriggerBombCommand()); return; } ICommand command; try { _botRunner.RunBot(); command = _botRunner.GetBotCommand(); } catch (TimeLimitExceededException ex) { Logger.LogException("Bot time limit exceeded ", ex); command = new DoNothingCommand(); } if (command.GetType() == typeof(DoNothingCommand)) { _totalDoNothingCommands++; } else { _totalDoNothingCommands = 0; } if (_totalDoNothingCommands == 20) { PublishCommand(new PlaceBombCommand()); return; } WriteLogs(); PublishCommand(command); }
private void RunBotAndGetNextMove() { if (_totalDoNothingCommands >= 10) { Logger.LogInfo( "Bot is sending to many do nothing commands, if this continues it the bot will be killed off"); } if (_totalDoNothingCommands >= 20) { BotUnresponsive(); Logger.LogInfo( "Bot sent to many do nothing commands, something is most likely going wrong, please fix your bot. The player's ships will all be marked as destroyed and killed off."); BattleshipPlayer.Killoff(); } if (BattleshipPlayer.FailedFirstPhaseCommands == 5) { Logger.LogInfo("Bot has failed to place ships in the last 5 rounds and will be killed off"); BattleshipPlayer.Killoff(); } ICommand command; try { _botRunner.RunBot(); command = _botRunner.GetBotCommand(); } catch (TimeLimitExceededException ex) { Logger.LogException("Bot time limit exceeded ", ex); command = new DoNothingCommand(); } if (command.GetType() == typeof(DoNothingCommand)) { _totalDoNothingCommands++; } else { _totalDoNothingCommands = 0; } WriteLogs(); RemoveCommandFile(true); BotCommandPublished(command); PublishCommand(command); }