lojix/search/src/main/com/thesett/aima/search/examples/eightpuzzle/EightPuzzleState.java
protected void updateWithOperator(Operator op)
    {
        // Get the operator as a character by taking the first character of the operator string
        char opc = ((String) op.getOp()).charAt(0);

        // Move the empty tile according to the specified operation
        switch (opc)
        {
        // Swap the empty tile with the one above it.
        case 'U':
        {
            swapTiles(emptyX, emptyY, emptyX, emptyY - 1);
            break;
        }

        // Swap the empty tile with the one below it.
        case 'D':
        {
            swapTiles(emptyX, emptyY, emptyX, emptyY + 1);
            break;
        }

        // Swap the empty tile with the one to the left of it.
        case 'L':
        {
            swapTiles(emptyX, emptyY, emptyX - 1, emptyY);
            break;
        }

        // Swap the empty tile with the one to the right of it.
        case 'R':
        {
            swapTiles(emptyX, emptyY, emptyX + 1, emptyY);
            break;
        }

        default:
        {
            throw new IllegalStateException("Unkown operator: " + opc + ".");
        }
        }
    }
protected void updateWithOperator(Operator op)
    {
        // Get the operator as a character by taking the first character of the operator string
        char opc = ((String) op.getOp()).charAt(0);

        // Move the empty tile according to the specified operation
        switch (opc)
        {
        // Swap the empty tile with the one above it.
        case 'U':
        {
            swapTiles(emptyX, emptyY, emptyX, emptyY - 1);
            break;
        }

        // Swap the empty tile with the one below it.
        case 'D':
        {
            swapTiles(emptyX, emptyY, emptyX, emptyY + 1);
            break;
        }

        // Swap the empty tile with the one to the left of it.
        case 'L':
        {
            swapTiles(emptyX, emptyY, emptyX - 1, emptyY);
            break;
        }

        // Swap the empty tile with the one to the right of it.
        case 'R':
        {
            swapTiles(emptyX, emptyY, emptyX + 1, emptyY);
            break;
        }

        default:
        {
            throw new IllegalStateException("Unkown operator: " + opc + ".");
        }
        }
    }
protected void updateWithOperator ( Operator op ) { // Get the operator as a character by taking the first character of the operator string char opc = ( ( String ) op . getOp ( ) ) . charAt ( 0 ) ; // Move the empty tile according to the specified operation switch ( opc ) { // Swap the empty tile with the one above it. case ' ' : { swapTiles ( emptyX , emptyY , emptyX , emptyY - 1 ) ; break ; } // Swap the empty tile with the one below it. case ' ' : { swapTiles ( emptyX , emptyY , emptyX , emptyY + 1 ) ; break ; } // Swap the empty tile with the one to the left of it. case ' ' : { swapTiles ( emptyX , emptyY , emptyX - 1 , emptyY ) ; break ; } // Swap the empty tile with the one to the right of it. case ' ' : { swapTiles ( emptyX , emptyY , emptyX + 1 , emptyY ) ; break ; } default : { throw new IllegalStateException ( "Unkown operator: " + opc + "." ) ; } } }
Applies a move to the board position. This changes the board position stored in this object. This is different
from the {@link #getChildStateForOperator} method which updates the board position in a new object.

@param op The move to apply to this board; "U" for up, "D" for down, "L" for left and "R" for right.
Applies a move to the board position . This changes the board position stored in this object . This is different from the { @link #getChildStateForOperator } method which updates the board position in a new object .