예제 #1
0
        // 処理の最適化のため、必要となる結果だけを返します。
        public VariableFormula <PlayerTurns> Start(PlayerNumber[] numbers, PlayerIdentity targetId)
        {
            var targetNumber   = numbers.First(n => n.PlayerId == targetId).Number;
            var opponentNumber = numbers.First(n => n.PlayerId == targetId.Opponent).Number;

            var targetPlayer   = new SimulationPlayer(targetId);
            var opponentPlayer = new SimulationPlayer(targetId.Opponent);

            targetPlayer.Initialize(numbers, this);
            opponentPlayer.Initialize(numbers, this);

            for (var i = 1; ; i++)
            {
                var targetResult   = targetPlayer.Guess(i);
                var opponentResult = opponentPlayer.Guess(i);

                if (targetResult.HasValue)
                {
                    return(Variable(new PlayerTurns(targetId, i), true));
                }
                if (opponentResult.HasValue)
                {
                    return(Variable(new PlayerTurns(targetId.Opponent, i), true));
                }

                if (targetNumber > opponentNumber && i == targetNumber - 2)
                {
                    return(Variable(new PlayerTurns(targetId, i), false));
                }
            }
        }
예제 #2
0
        public VariableFormula <PlayerTurns> Start_Stub(PlayerNumber[] numbers, PlayerIdentity targetId)
        {
            var targetNumber   = numbers.First(n => n.PlayerId == targetId).Number;
            var opponentNumber = numbers.First(n => n.PlayerId == targetId.Opponent).Number;

            return(targetNumber < opponentNumber?
                   Variable(new PlayerTurns(targetId, targetNumber), true) :
                       Variable(new PlayerTurns(targetId, targetNumber - 2), false));
        }
예제 #3
0
 public PlayerTurns(PlayerIdentity playerId, int turns = 0)
 {
     PlayerId = playerId;
     Turns    = turns;
 }
예제 #4
0
 public PlayerNumber(PlayerIdentity playerId, int number)
 {
     PlayerId = playerId;
     Number   = number;
 }
예제 #5
0
 public SimulationPlayer(PlayerIdentity id) : base(id)
 {
 }
예제 #6
0
 public Player(PlayerIdentity id) : base(id)
 {
 }
예제 #7
0
 protected PlayerBase(PlayerIdentity id)
 {
     Id = id;
 }