/// <summary>Runs it all.</summary> public void DoRun(IBot bot, IEnumerable<IInstruction> instructions) { if (bot == null) { throw new ArgumentNullException("bot"); } if (instructions == null) { throw new ArgumentNullException("instructions"); } var settings = new Settings(); var state = new GameState(); foreach (var instruction in instructions) { if (settings.Apply(instruction)) { bot.ApplySettings(settings); } else if (state.Apply(instruction)){ } else if (instruction is RequestMoveInstruction) { bot.Update(state); try { var response = bot.GetResponse(((RequestMoveInstruction)instruction).Time); Writer.WriteLine(response.Move); if (!String.IsNullOrEmpty(response.Log)) { Logger.WriteLine(response.Log); } } catch (Exception x) { Writer.WriteLine(new MoveInstruction(4)); Logger.WriteLine(x); } } } }
public void ApplySettings(Settings settings) { Settings = settings; }