Ejemplo n.º 1
0
        public void ShuffleEigthPuzzleInitialState(AriciePropertyEditorControl ape)
        {
            var eightPuzzleBoard = new EightPuzzleBoard(EightPuzzleInitialState.ToArray());

            var actionsFunction = EightPuzzleFunctionFactory.getActionsFunction();
            var resultFunction  = EightPuzzleFunctionFactory.getResultFunction();
            var previousBoards  = new HashSet <EightPuzzleBoard>();

            for (int i = 0; i < EightPuzzleShuffleMoves; i++)
            {
                Object[] successors = actionsFunction.actions(eightPuzzleBoard).toArray();

                EightPuzzleBoard nextState;
                do
                {
                    var choosenSuccessorIdx = CryptoHelper.Random.Next(successors.Length);
                    var objAction           = (aima.core.agent.Action)successors[choosenSuccessorIdx];
                    nextState = (EightPuzzleBoard)resultFunction.result(eightPuzzleBoard, objAction);
                } while (previousBoards.Contains(nextState));

                previousBoards.Add(eightPuzzleBoard);
                eightPuzzleBoard = (EightPuzzleBoard)nextState;
            }
            EightPuzzleInitialState = new List <int>(eightPuzzleBoard.getState());
            ape.ItemChanged         = true;
        }
Ejemplo n.º 2
0
        public Object GetInitialState()
        {
            switch (Selection)
            {
            case SearchDemos.EightPuzzle:
                return(new EightPuzzleBoard(EightPuzzleInitialState.ToArray()));

            case SearchDemos.NQueen:
                return(new NQueensBoard(NQueenBoardSize));

            default:
                break;
            }
            return(null);
        }