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

GetSuccessors() public method

public GetSuccessors ( ) : IEnumerable
return IEnumerable
        public IEnumerable<ISuccessor> GetSuccessors()
        {
            for (int i = 0; i < 4; i++)
            {
                var move = _moves[i];
                int idx = Array.IndexOf(_square, 0);

                if (Test(idx, move))
                {
                    var shift = _modeIdx[i];
                    yield return new SquareMove(Swap(idx, idx + shift), move);
                }
            }
        }

Usage Example

コード例 #1
0
ファイル: SquareTests.cs プロジェクト: xtellurian/numl
        public void Test_Square_Expansion()
        {
            for (int i = 0; i < 9; i++)
            {
                int[]  square = CreateSquare(i);
                IState init   = new Square(square);
                Console.WriteLine(init.ToString());
                foreach (var s in init.GetSuccessors())
                {
                    Console.WriteLine("---------\n{0} ({1}{2})", s.Action, s.Cost, s.State.IsTerminal ? ", Goal" : "");
                    Console.WriteLine(s.State);
                }

                Console.WriteLine("------------------------------------------");
            }
        }
All Usage Examples Of numl.Tests.AITests.Square::GetSuccessors