// 処理の最適化のため、必要となる結果だけを返します。 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)); } } }
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)); }
public PlayerTurns(PlayerIdentity playerId, int turns = 0) { PlayerId = playerId; Turns = turns; }
public PlayerNumber(PlayerIdentity playerId, int number) { PlayerId = playerId; Number = number; }
public SimulationPlayer(PlayerIdentity id) : base(id) { }
public Player(PlayerIdentity id) : base(id) { }
protected PlayerBase(PlayerIdentity id) { Id = id; }