/// <summary>Runs it all.</summary>
		public void DoRun(IBot bot)
		{
			if (bot == null) { throw new ArgumentNullException("bot"); }

			var settings = new Settings();
			var match = new GameState(settings);

			string line;
			while ((line = this.Reader.ReadLine()) != null)
			{
#if !DEBUG
				try
				{
#endif
				var instruction = Instruction.Parse(line);

				switch (instruction.InstructionType)
				{
					case InstructionType.Player:
						match.UpdatePlayer(instruction);
						HandleOpponentReaction(bot, match, instruction);
						if (match.Result != RoundResult.NoResult)
						{
							bot.Result(match);
						}
						break;
					case InstructionType.Match: match.UpdateMatch(instruction); break;

					case InstructionType.Settings:
						settings.Update(instruction);
						match.Update(settings);
						break;

					case InstructionType.Action:
						match.UpdateAction(instruction);
						var action = bot.Action(match);
						Writer.WriteLine(action);
						break;

					case InstructionType.None:
					case InstructionType.Output:
					default:
						break;
				}
#if !DEBUG
				}
				catch (Exception x)
				{
					Console.Error.WriteLine(line);
					Console.Error.WriteLine(x);
				}
#endif
			}
		}
Exemplo n.º 2
0
		/// <summary>Constructs a new game state based on settings..</summary>
		public GameState(Settings settings): this()
		{
			Update(settings);
		}
Exemplo n.º 3
0
		/// <summary>Updates the player state based on the settings.</summary>
		public void Update(Settings settings)
		{
			this.TimeBank = TimeSpan.FromMilliseconds(settings.TimeBank);
			this.Stack = settings.StartingStack;
		}
Exemplo n.º 4
0
		/// <summary>Updates the state based on the settings.</summary>
		public void Update(Settings settings)
		{
			this.YourBot = settings.YourBot;
			this.Player1.Update(settings);
			this.Player2.Update(settings);
		}
Exemplo n.º 5
0
		/// <summary>Creates a new player state based on the settings.</summary>
		public PlayerState(Settings settings): this()
		{
			Update(settings);
		}