public void next() {
        // if the game state is not RUNNING, ignore.
        if (state <= STATE_END) return;

        int originState = state;
        setState(STATE_NEXT);

        // notify the current path node changes.
        setPathNodes(pathNodes + 1);

        List<Integer> pos = nextPosition(getCurrentTile());
        if (pos != null) {
            MazeTile tile = getTile(pos);

            if (tile != null) {
                // notify the current tile.
                setCurrentTile(tile);
                next();
            } else {
                addTile(createTile(pos));
            }

            if (originState == STATE_START) {
                setState(STATE_START);
            }
        } else {
            // notify the end of game.
            setState(STATE_END);
        }
    }