public IEnumerable<ISuccessor> GetSuccessors() { for(int i = 0; i < _board.Length; i++) { if(_board[i] == 0) { var play = Player ? 1 : -1; var newBoard = (int[])_board.Clone(); newBoard[i] = play; yield return new TicTacToeMove(new TicTacToe(!Player, newBoard), new Action(i.ToString())); } } }
public void Test_Expansion() { TicTacToe t = new TicTacToe(false, new[] { -1, 0, -1, 1, 0, 0, 0, 1, 0 }); Console.WriteLine(t); foreach (var successor in t.GetSuccessors()) { PrintSuccessor(successor); } }