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(); }
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; }
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); }
public void TestField(int x, int y) { Game g = new Game(x, y); Assert.AreEqual(g.Field.GetLength(0), x); }
public void TestAdjacent() { Game g = new Game(5, 5); g.Field[0, 1].Alive = true; Assert.AreEqual(1, g.countAliveAdjacent(0, 0)); }