public GameUI()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
       InitializeComponent();
       TimeLimitInput = "2.0";
       MaxStepsInput = "500";
       currentGame = new Games.GuessTheNumber();
       currentGame.GameComplete += gameCompleteHandler;
       players = new Player[currentGame.Players];
       for (Int32 i = 0; i < currentGame.Players; ++i) {
     players[i] = new Player(Dispatcher);
       }
       DataContext = this;
 }
示例#2
0
 public GameInputData(Player[] players, Int32 maxSteps, TimeSpan timeLimit)
 {
     Players = players;
     MaxSteps = maxSteps;
     TimeLimit = timeLimit;
 }
示例#3
0
 /// <summary>
 /// Run the game asynchronously with specified players and settings. Afterwards writes either pointer to winner or null in case of a draw to the Result.
 /// </summary>
 /// <param name="players">Array of players</param>
 /// <param name="maxSteps">Game steps limit</param>
 /// <param name="timeLimit">Execution time limit for a single game step</param>
 /// <exception cref="ArgumentNullException">Neither <c>players</c> nor it's element can be null</exception>
 /// <exception cref="ArgumentException">The <c>players</c> element count should match <c>Players</c> and <c>maxSteps</c> must be a positive integer</exception>
 /// <exception cref="InvalidOperationException">When the game already has been started</exception>
 public void BeginPlay(Player[] players, Int32 maxSteps, TimeSpan timeLimit)
 {
     if (players == null || Array.IndexOf(players, null) >= 0) {
     throw new ArgumentNullException("players", "The array and any element can\'t be null");
       }
       if (Players != players.Length) {
     throw new ArgumentException(String.Format("Invalid number of players. Expected {0}, passed {1}", Players, players.Length), "players");
       }
       if (maxSteps <= 0) {
     throw new ArgumentException(String.Format("The argument must be a positive integer, passed {0}", maxSteps), "maxSteps");
       }
       if (worker.IsBusy) {
     throw new InvalidOperationException("The game is still in progress");
       }
       worker.RunWorkerAsync(new GameInputData(players, maxSteps, timeLimit));
       worker.CancelAsync();
 }
示例#4
0
 protected abstract Player ActualPlay(Player[] players, Int32 maxSteps, TimeSpan timeLimit);