numl.Tests.AITests.TicTacToe.GetSuccessors C# (CSharp) Method

GetSuccessors() public method

public GetSuccessors ( ) : IEnumerable
return IEnumerable
        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()));
                }
            }
        }

Usage Example

コード例 #1
0
ファイル: TicTacToeTests.cs プロジェクト: sethjuarez/numl
 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);
     }
 }
All Usage Examples Of numl.Tests.AITests.TicTacToe::GetSuccessors