@@ -0,0 +1,1986 @@
+/* @(#)MoveFitness.java%0A */%0A/**%0A *  Class containing all of the business logic regarding whether a%0A *  move is considered good or not.%0A *%0A * @author %3Ca href=%22mailto:geoff@minty-dark-tower%22%3EGeoff Shannon%3C/a%3E%0A */%0A%0Apackage wall_follower;%0A%0Apublic class MoveFitness %7B%0A%0A    // TODO: fix these values!!! Set arbitrarily for right now%0A    private static final float MIN_GOOD_DISTANCE = 0.1f;%0A    private static final float MAX_GOOD_DISTANCE = 1.0f;%0A%0A    private int goodMoves;%0A    private int badMoves;%0A%0A    /**%0A     *  Overall, the way that we score moves is this: there is a%0A     *  predefined %22good%22 range.  If the move caused us to stay in%0A     *  that range, then it was good.  If we were outside the range,%0A     *  then if the move put us closer to that range it was good.%0A     *  Otherwise, it was a bad move.%0A     */%0A    public void scoreMove(SensorReading before, SensorReading after) %7B%0A%0A        if (inGoodRange(before.distance)) %7B%0A            if (inGoodRange(after.distance)) %7B%0A                goodMoves++;%0A            %7D else %7B%0A                badMoves++;%0A            %7D%0A        %7D else %7B%0A            // If deltaDistance is positive then we moved away from%0A            // the wall, if it is negative then we moved closer.%0A            float deltaDistance = after.distance - before.distance;%0A%0A            // If we were too close, and got farther away: good%0A            if (before.distance %3C MIN_GOOD_DISTANCE &&%0A                deltaDistance %3E 0) %7B%0A                goodMoves++;%0A            // Or if we were too far and got closer: good%0A            %7D else if (before.distance %3E MAX_GOOD_DISTANCE &&%0A                       deltaDistance %3C 0) %7B%0A                goodMoves++;%0A%0A            %7D else %7B%0A                badMoves++;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public float getFitness() %7B%0A        return goodMoves / badMoves;%0A    %7D%0A%0A    private static boolean inGoodRange(float distance) %7B%0A        return (distance %3E= MIN_GOOD_DISTANCE) &&%0A            (distance %3C= MAX_GOOD_DISTANCE);%0A    %7D%0A%7D%0A

Add a simplistic move fitness evaluation