User:AW/guideToRobocode/UnderstandingGilgalad
Getting the Source
First, if you are bothering to read this tutorial you should have the source code for Gilgalad. It's available in the jar, which can be downloaded from Gilgalad's bot page (before the I finish writing this tutorial, a new version should be released, wherein I should have finished another round of refactoring and documentation, that will hopefully make the code easier to understand). To view the source in eclipse, which will make reading it much easier, open eclipse and create a new java project as in here. Select this project, then go to file-->import-->general-->archive file and browse to the jar file. Hit finish, and you've got the source, nicely laid out with eclipse's outlining tools to help you understand it.
Overall layout
Gilgalad was designed to be modular, so that new guns and movements could be plugged in to create new robots. This hasn't been used yet, since the gun supports virtual guns (more on this later) and making a new movement is a fairly large task; however, it hopefully makes the code easier to read since the gun and movement are more or less independent. (Note: fortunately for you, this structure is true of many top bots, some of which inspired Gilgalad's design.)
The code is more or less of a tree structure, with the "trunk" being Gilagald.java. This class just contains code to setup the gun and movement, so that the various events in robocode will cause the correct methods in the gun and movement to be called.