コード例 #1
0
        public GameViewModel(Game game)
        {
            _game = game;

            ResetCommand = new RelayCommand(ExecuteReset, CanReset);
            IterateCommand = new RelayCommand(ExecuteIterate, CanIterate);
            StartCommand = new RelayCommand(ExecuteStart, CanStart);
            StopCommand = new RelayCommand(ExecuteStop, CanStop);

            _game.WorldUpdated += (sender, e) => UpdateVmState();
        }
コード例 #2
0
 public static Game RandomGame(int x, int y)
 {
     var game = new Game(x, y);
     var rand = new Random();
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < y; j++)
         {
             game.Field[i, j].Alive = rand.Next(2)==1?true:false;
         }
     }
     return game;
 }
コード例 #3
0
 public void TestDie()
 {
     Game g = new Game(5, 5);
     g.Field[0, 1].Alive = true;
     g.Step();
     Assert.AreEqual(false, g.Field[0,1].Alive);
 }
コード例 #4
0
 public void TestField(int x, int y)
 {
     Game g = new Game(x, y);
     Assert.AreEqual(g.Field.GetLength(0), x);
 }
コード例 #5
0
 public void TestAdjacent()
 {
     Game g = new Game(5, 5);
     g.Field[0, 1].Alive = true;
     Assert.AreEqual(1, g.countAliveAdjacent(0, 0));
 }