示例#1
0
		public GameAction Action(GameState state)
		{
			switch (Rnd.Next(0, 16))
			{
				case 0: return GameAction.Fold;
				case 1:
				case 2:
				case 3:
					var raise = Math.Max(state.Own.Stack, state.MaxWinPot);
					if (raise > 0)
					{
						return GameAction.Raise(raise);
					}
					else
					{
						return GameAction.Check;
					}
				default:
					if (state.AmountToCall > 0)
					{
						return GameAction.Call;
					}
					else
					{
						return GameAction.Check;
					}
			}
		}
		/// <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
			}
		}
		public GameAction Action(GameState state)
		{
			if (state.AmountToCall > 0)
			{
				return GameAction.Call;
			}
			else
			{
				return GameAction.Check;
			}
		}
示例#4
0
		public GameAction Action(GameState state)
		{
			var raise = Math.Max(state.Own.Stack, state.MaxWinPot);
			if (raise > 0)
			{
				return GameAction.Raise(raise);
			}
			else
			{
				return GameAction.Check;
			}
		}
		public GameAction Action(GameState state)
		{
			var pairs = CardPairs.Create(state.Own.Hand);

			// We have to (Small Blind), and a creapy hand.
			if (state.AmountToCall != 0 && state.Table.Count == 0)
			{
				if (pairs.Max < 2 && state.Own.Hand.Best.Height < 11)
				{
					return GameAction.Fold;
				}
				return GameAction.Call;
			}
			// If we need to call, we call.			
			if (state.AmountToCall != 0)
			{
				return GameAction.Call;
			}
			// we check.
			return GameAction.Check;
		}
		private static void HandleOpponentReaction(IBot bot, GameState state, Instruction instruction)
		{
			if (instruction.Player != state.YourBot)
			{
				GameActionType tp;
				if (Enum.TryParse<GameActionType>(instruction.Action, out tp))
				{
					GameAction action;

					switch (tp)
					{
						case GameActionType.raise: action = GameAction.Raise(instruction.Int32Value); break;
						case GameActionType.check: action = GameAction.Check; break;
						case GameActionType.call: action = GameAction.Call; break;
						case GameActionType.fold:
						default: action = GameAction.Fold; break;
					}
					bot.Reaction(state, action);
				}
			}
		}
		public void Result(GameState state) { }
		public void Reaction(GameState state, GameAction reaction) { }
		public GameAction Action(GameState state)
		{
			return GameAction.Fold;
		}
示例#10
0
		/// <summary>Copies the game state.</summary>
		public GameState Copy()
		{
			var copy = new GameState()
			{
				Round = this.Round,
				Table = Table.Copy(),
				Player1 = this.Player1.Copy(),
				Player2 = this.Player2.Copy(),
			};
			return copy;
		}