Warning: main() [function.main]: open_basedir restriction in effect. File(/home/novasurf/public_html/_borders/toppy.txt) is not within the allowed path(s): (/home/ozzzie/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/ozzzie/public_html/ozwarren/java/index.php on line 30

Warning: main(/home/novasurf/public_html/_borders/toppy.txt) [function.main]: failed to open stream: Operation not permitted in /home/ozzzie/public_html/ozwarren/java/index.php on line 30

Warning: main() [function.main]: open_basedir restriction in effect. File(/home/novasurf/public_html/_borders/toppy.txt) is not within the allowed path(s): (/home/ozzzie/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/ozzzie/public_html/ozwarren/java/index.php on line 30

Warning: main(/home/novasurf/public_html/_borders/toppy.txt) [function.main]: failed to open stream: Operation not permitted in /home/ozzzie/public_html/ozwarren/java/index.php on line 30

Warning: main() [function.include]: Failed opening '/home/novasurf/public_html/_borders/toppy.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ozzzie/public_html/ozwarren/java/index.php on line 30
 

Ozzie's Java pages

Sad though I am, I quite enjoy a bit of Java programming in my spare time. One of my favourite time sinks over the last few months has been Robocode.

Robocode is a robot combat game where programmers compete to create the most intelligent fighting robot using their own Java classes. Although I've played with Java on and off over the last few years and I've formally studied it as part of my IT degree, my knowledge is fairly rudimentary compared to a day-in day-out programmer. This game is an excellent way of sharpening up your Java skills - trust me.

My own experiments with this game have been fairly basic, but I have been able to figure out some simple algorithms for features like predictive firing etc. on my own. I won't post my own 'bots here, as the embarrassment would kill me, although I am intending to put down some of the basic tips that I have picked up and figured out along the way.

Tip 1

Brush up on your trigonometry and the use of Math.sin and Math.cos within the Java library. Using these two methods you can calculate the x, y coordinates of a point using an angle and a distance.

Below is a simple example of this in use:

/**
* Takes an angle in the range 0-359 and a radius and calculates an x,y coordinate
* relative to 0,0 and returns this as a Point.

*/
public static Point pointFromAngle(int angle, int radius)
{
double xSin = Math.sin((angle * (Math.PI/180 ))) * radius;
double yCos = (Math.cos((angle * (Math.PI/180 ))) * radius) * -1;
return new Point((int) xSin,(int) yCos);
}

Teach Yourself Trigonometry (Teach Yourself)
P. Abbott, Hugh Neill

cover

Ozzie's applets

I do also create my own applets and other Java programs to serve specific needs. My current development project is a charting tool for Web pages as shown below. You can find out more about it on the Khartz page.

Recommended reading

There are several books that I would recommend to get you going with Java.

Book 1:Core Java 2: Fundamentals (The Sun Microsystems Press Java Series)
Cay S. Horstmann, Gary Cornell

cover

Book2:Core Java 2: Advanced Features (The Java Series)
Cay Horstmann, Gary Cornell

cover

Book3: Effective Java: Programming Language Guide (AW Java Series)
Josh Bloch

cover

Book3:Java in a Nutshell
David Flanagan

cover

Search

This site     web                

Robocode


Robocode home page

The Robocode API

The Java 2 API version 1.3

The Robocode repository

Robocode fanatics!

Robocode central

KhartzChart


Khartz page