[Home]History of Minimize the line count

Robo Home | Changes | Preferences | AllPages


Revision 5 . . June 23, 2004 2:16 EST by ABC
Revision 4 . . June 23, 2004 1:55 EST by Brainfade
  

Difference (from prior major revision) (no other diffs)

Changed: 3c3,4
I thought I would add some tips for those people trying to write SonnetBots for the Robocode Little League. This will allow your robot to get pretty big without to many semicolons. Since I like text that lines up I'm going to use the pre tag here.
I thought I would add some tips for those people trying to write SonnetBots for the Robocode Little League. This will allow your robot to get pretty big without to many semicolons. Since I like text that lines up I'm going to use the pre tag here. Since I went and wrote a 12meg SonnetBot that used only 6 lines and implemented anti-gravity and a
guess factor gun I think i'm qualified to lecture here (I was the one who actually tried to understand flood sonnet!). In case you folks are wondering why I din't enter it in the leage it's because it's still a work in progress and still gets it's but kicked by some of the simpler bots out there. :(

Added: 5a7,10

RULE #0 !!!!! K.I.S.S. (Keep it simple stupid)
Start small. Work a piece at a time and get it running.


Changed: 101,102c106,109
Determine what their arguments are before hand.

Determine what their arguments are before hand in global variables so you can see the results
from methods like onScannedRobot()

Information you need to know

Changed: 121c128,151
</pre>
Rule #6 Use print statements to debug your conditions soe you know whats going on. I consider these freebe's
because although you use a semi-colon they aren't integral to the workings of your final product and
can be removed later. However they are key to development. Usually you are only conserned with the
failure result so something like this would be appropriate.

--- before ---
absbearing = new Double(e.getBearingRadians?() + getHeadingRadians());
turn = new Double(Math.PI/2 + e.getBearingRadians?());

--- after ---
if ( ( (absbearing = new Double( e.getBearingRadians?() + getHeadingRadians())) == null)
|| ( (turn = new Double( Math.PI/2 + e.getBearingRadians?())) == null)
)
{ out.println("Error in onScannedRobot() : Failed to set absbearing our our proper turn");
} else
{ out.println("absbearing = " + absbearing.toString()); // toString is not required
out.println("turn = " + turn); // compiler assumes it's called for Objects.
}

By doing this especially for our larger conditions we know what went wrong in each condition.
Preferable we would like to keep our conditions as small as possible because in this example we
still don't know what part of the condition failed. However in order to make our code more readable
it's reasonable to assume statements like the above are NOT going to fail and can all be written in
one big long condition. Use shortcut operators frequently to increase performance and find errors quicker

Robo Home | Changes | Preferences | AllPages
Search: