NetRexx Robocode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

NetRexx Robocode

Tom Maynard
Hot on the heels of the open source announcement, I bring you a fascinating way to develop your programming skills and to have a great time simultaneously: Robocode.

Originally developed as a Java learning/teaching tool, it's a perfect place for NetRexx, too.  The requisite URLs:

Home page: http://robocode.sourceforge.net/
Wiki page: http://robowiki.net/
Video example: http://www.youtube.com/watch?v=OgqJGUQWFHM

So, you write the code to control the behavior of a robot tank ... the Robocode API gives you plenty of tools/information.  Bots come in various "flavors" based on their code size (in bytes), from a "Nano" bot (<250B), to "Mini" bots (<1500B), and battles can be one-on-one (1v1), melee (free for all), teams, etc.  There is something for everybody in this hobby.

To give you a sample, here's a NetRexx version of one of the "My First Robot" Robocode tutorials:

import robocode.Robot
import robocode.ScannedRobotEvent

class NrxBot public extends Robot
    method run()
        loop forever
            ahead(100)
            turnGunRight(360)
            back(100)
            turnGunRight(360)
        end

    method onScannedRobot(e = ScannedRobotEvent)
        fire(1)

 
This robot doesn't do much!  It just darts back and forth (by 100 pixels), and shoots at anything it sees.  Here's a slightly better bot:

import robocode.Robot
import robocode.ScannedRobotEvent

class NrxBot1 public extends Robot
    method run()
        turnLeft(getHeading() // 90)
        turnGunRight(90)
        loop forever
            ahead(1000)
            turnRight(90)
        end

    method onScannedRobot(e = ScannedRobotEvent)
        fire(1)


Not much better!  This one heads for the nearest wall (the edge of the battle field), and travels the perimeter firing inward at anything it sees.  More sophisticated bots extract all manner of information from the ScannedRobotEvent ("e"), and modify their radar, movement, and targeting accordingly (within the limits of their code size category, of course).  There are plenty of robots available in source code form for study and/or modification.  Translation of a robot from Java to NetRexx is typically quite easy.

If you want to hone your NetRexx skills, and to test your battlefield canniness, or simply to while away some idle time ... Robocode may just be the ticket.

Enjoy,
Tom.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/