コード例 #1
0
		/// <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 matches = new Matches();

			foreach (var instruction in instructions)
			{
				if (settings.Apply(instruction))
				{
					bot.ApplySettings(settings);
				}
				else if (matches.Apply(instruction)) { }
				else if (instruction is WinsInstruction)
				{
					bot.Update((WinsInstruction)instruction);
				}
				else if (instruction is RequestMoveInstruction)
				{
					bot.Update(matches);
					try
					{
						var response = bot.GetResponse(((RequestMoveInstruction)instruction).Time);
						Writer.WriteLine(response.Action);
						if (!String.IsNullOrEmpty(response.Log))
						{
							Logger.WriteLine(response.Log);
						}
					}
					catch (Exception x)
					{
						Writer.WriteLine(GameAction.Check);
						Logger.WriteLine(x);
					}
				}
			}
		}
コード例 #2
0
		public void ApplySettings(Settings settings)
		{
			Settings = settings;
		}