System.out.println("previous pos = " + prevState.getPosition());
    public static void compile(Game game, int entityId, MovePath md) {        final Entity entity = game.getEntity(entityId);                // some flags        boolean isJumping = false;        boolean isInfantry = (entity instanceof Infantry);        boolean isUsingManAce = false;                // check for jumping        if (md.contains(MovePath.STEP_START_JUMP)) {            isJumping = true;        } else {            isUsingManAce = entity.getCrew().getOptions().booleanOption("maneuvering_ace");        }                // transform lateral shifts for quads or maneuverability aces        if (((entity instanceof QuadMech) || isUsingManAce) && !isJumping) {            md.transformLateralShifts();            md.transformLateralShiftsBackwards();        }        // first pass: set position, facing and mpUsed; figure out overallMoveType        for (final Enumeration i = md.getSteps(); i.hasMoreElements();) {            MoveStep step = (MoveStep)i.nextElement();            MoveStep prev = step.getPrev();                        MoveState state = step.getState();            MoveState prevState;            if (prev == null) {                prevState = new MoveState();                prevState.setFromEntity(entity, game);             } else {                prevState = prev.getState();            }                        state.setFromPrev(prevState);            //             switch(step.getType()) {            case MovePath.STEP_UNLOAD:            // TODO: Can immobilized transporters unload?            case MovePath.STEP_LOAD:                state.setMp(1);                break;            case MovePath.STEP_TURN_LEFT :            case MovePath.STEP_TURN_RIGHT :                // Check for pavement movement.                if (canMoveOnPavement(game, prevState.getPosition(), state.getPosition())) {                    state.setPavementStep(true);                } else {                    state.setPavementStep(false);                    state.setOnlyPavement(false);                }                // Infantry can turn for free.                state.setMp((state.isJumping() || state.isHasJustStood() || isInfantry) ? 0 : 1);                state.adjustFacing(step.getType());                break;            case MovePath.STEP_FORWARDS :            case MovePath.STEP_BACKWARDS :            case MovePath.STEP_CHARGE :            case MovePath.STEP_DFA :                // step forwards or backwards                if (step.getType() == MovePath.STEP_BACKWARDS) {                    state.moveInDir((state.getFacing() + 3) % 6);                    state.setThisStepBackwards(true);                    state.setRunProhibited(true);                } else {                    state.moveInDir(state.getFacing());                    state.setThisStepBackwards(false);                }                // Check for pavement movement.                if (canMoveOnPavement(game, prevState.getPosition(), state.getPosition())) {                    state.setPavementStep(true);                } else {                    state.setPavementStep(false);                    state.setOnlyPavement(false);                }                state.setMp(getMovementCostFor(game, entityId, prevState.getPosition(), state.getPosition(), state.isJumping()));                // check for water                if (!state.isPavementStep()                    && game.board.getHex(state.getPosition()).levelOf(Terrain.WATER) > 0                    && entity.getMovementType() != Entity.MovementType.HOVER) {                    state.setRunProhibited(true);                }                state.setHasJustStood(false);                if (prevState.isThisStepBackwards() != state.isThisStepBackwards()) {                    state.setDistance(0); //start over after shifting gears                }                state.addDistance(1);                break;            case MovePath.STEP_LATERAL_LEFT :            case MovePath.STEP_LATERAL_RIGHT :            case MovePath.STEP_LATERAL_LEFT_BACKWARDS :            case MovePath.STEP_LATERAL_RIGHT_BACKWARDS :                if (step.getType() == MovePath.STEP_LATERAL_LEFT_BACKWARDS                     || step.getType() == MovePath.STEP_LATERAL_RIGHT_BACKWARDS) {                    state.moveInDir((MovePath.getAdjustedFacing(state.getFacing(), MovePath.turnForLateralShiftBackwards(step.getType())) + 3) % 6);                    state.setThisStepBackwards(true);                    state.setRunProhibited(true);                } else {                    state.moveInDir(MovePath.getAdjustedFacing(state.getFacing(), MovePath.turnForLateralShift(step.getType())));                    state.setThisStepBackwards(false);                }                // Check for pavement movement.                if ( canMoveOnPavement(game, prevState.getPosition(), state.getPosition()) ) {                    state.setPavementStep(true);                } else {                     state.setPavementStep(false);                    state.setOnlyPavement(false);                }                state.setMp(getMovementCostFor(game, entityId, prevState.getPosition(), state.getPosition(),                state.isJumping()) + 1);                // check for water                if (!state.isPavementStep()                    && game.board.getHex(state.getPosition()).levelOf(Terrain.WATER) > 0) {                        state.setRunProhibited(true);                }                state.setHasJustStood(false);                if (prevState.isThisStepBackwards() != state.isThisStepBackwards()) {                    state.setDistance(0); //start over after shifting gears                }                state.addDistance(1);                break;            case MovePath.STEP_GET_UP :                // mechs with 1 MP are allowed to get up                state.setMp(entity.getRunMP() == 1 ? 1 : 2);                state.setHasJustStood(true);                break;            case MovePath.STEP_GO_PRONE :                state.setMp(1);                break;            case MovePath.STEP_START_JUMP :                state.setJumping(true);                break;            default :                state.setMp(0);            }                        state.addMpUsed(state.getMp());        }                // running with gyro or hip hit is dangerous!        // but we can't show it right now.  check officially moved anyhow.//        if (overallMoveType == Entity.MOVE_RUN//            && (entity.getDestroyedCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO,Mech.LOC_CT) > 0//                || entity.hasHipCrit())) {//            md.getStep(0).setDanger(true);//        }                // set moveType, illegal, trouble flags        compileIllegal(game, entityId, md);        // Check the last step for legality.        compileLastStep(game, entityId, md);                // check for illegal jumps        if (isJumping) {            compileJumpCheck(game, entityId, md);        }                md.setCompiled(true);    }