コード例 #1
0
ファイル: GameMaster.cs プロジェクト: zgm123456/Samples-2016
        // 処理の最適化のため、必要となる結果だけを返します。
        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
ファイル: GameMaster.cs プロジェクト: zgm123456/Samples-2016
        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;
 }