lojix/search/src/main/com/thesett/aima/search/examples/eightpuzzle/EightPuzzleState.java
private static EightPuzzleState charListToState(List<Character> charList)
    {
        // Create a new empty puzzle state
        EightPuzzleState newState = new EightPuzzleState();

        // Loop over the board inserting the characters into it from the character list
        Iterator<Character> k = charList.iterator();

        for (int j = 0; j < 3; j++)
        {
            for (int i = 0; i < 3; i++)
            {
                char nextChar = k.next();

                // Check if this is the empty tile and if so then take note of its position
                if (nextChar == 'E')
                {
                    newState.emptyX = i;
                    newState.emptyY = j;
                }

                newState.board[j][i] = nextChar;
            }
        }

        return newState;
    }
private static EightPuzzleState charListToState(List<Character> charList)
    {
        // Create a new empty puzzle state
        EightPuzzleState newState = new EightPuzzleState();

        // Loop over the board inserting the characters into it from the character list
        Iterator<Character> k = charList.iterator();

        for (int j = 0; j < 3; j++)
        {
            for (int i = 0; i < 3; i++)
            {
                char nextChar = k.next();

                // Check if this is the empty tile and if so then take note of its position
                if (nextChar == 'E')
                {
                    newState.emptyX = i;
                    newState.emptyY = j;
                }

                newState.board[j][i] = nextChar;
            }
        }

        return newState;
    }
Turns a list of characters representation of the board into a proper state.

@param  charList The board as a list of 9 characters.

@return The board as an EightPuzzleState.