private void PlayGame(bool humanFirst, int size, params ValueTuple <int, int>[] moves) { viewModel = new TicTacToeViewModel(); viewModel.AutoStartComputerMove = false; // Computer doesn't automatically start thinking about it's move when it's the computer's turn // so that we can examine the state of the system before the computer move starts // viewModel.StartNewGame(size, humanFirst); square1 = viewModel.FindSquare(0, 0); square2 = viewModel.FindSquare(0, 1); square3 = viewModel.FindSquare(0, 2); square4 = viewModel.FindSquare(1, 0); square5 = viewModel.FindSquare(1, 1); square6 = viewModel.FindSquare(1, 2); square7 = viewModel.FindSquare(2, 0); square8 = viewModel.FindSquare(2, 1); square9 = viewModel.FindSquare(2, 2); foreach (var move in moves) { viewModel.HumanMove(viewModel.FindSquare(move.Item1, move.Item2)); } }
// Construct a new model specific child of the View Model public TicTacToeViewModelChild(TicTacToeViewModel parent, ITicTacToeModel <Game, Move, Player> TicTacToeModel) { this.parent = parent; this.TicTacToeModel = TicTacToeModel; // if the game state has changed and it's not null, update the UI to reflect the new game state this.WhenAnyValue(vm => vm.gameState) .Where(gameState => gameState != null) .Subscribe(gameState => RefreshView()); }