GBQ57
Posts: 3
Joined: Sun Jan 29, 2012 10:10 pm

Re: An Introduction to Robocode

Wed Feb 01, 2012 3:52 pm

Can I introduce this forum to an application called Robocode.

I used this program to give me a “purpose” to learn Java – I was soon addicted.

Essentially you write a program (in Robocode’s case a Java Class that extended a class called Robot) to control a robot/tank in a simple rectangular arena – you control movement back and forth, turn,  rotate a turret and radar, fire a bullet etc – you get the idea.

Two or more robots are placed in an arena to battle it out.

The beauty of this application is that:


It is highly visual – think Turtle on steroids.
The Robocode environment takes care of the security aspects of code sharing –  The class does not run in isolation – it has to be loaded by Robocode, each robot could write to data files (but only in it’s own data folder and with a strict quota).  No access to OS etc.  In other words no accidental introduction of malicious code.
Any IDE could be used – you wrote real Java code/classes.
A working robot can be written in only a few lines of code – instant feedback for beginners.
The robot coders have to think about strategy and how to convert that to code - it's imaginative but bounded by the rules of the game.

What could be adopted for education purposes....


Convert / support Python (I’ve not yet looked at Python – but it looks like its flavour of the month).
Allow the robot environment to be controlled by another extended class set by a teacher/community – it doesn’t need to be ‘tanks and bullets’ it could be ‘ants and foraging’, ‘baloons and fans’, ‘mice in a maze’ etc.  It doesn't even need to be multi robot.
If the environment in which the robots are placed can be easily changed by changing the ‘Environment’ class - it makes lifting code from the internet no longer productive – plagiarism can be controlled.

Robocode is step based (but does't look like it - each robot had to take a decision quickly) – with identical R-PI’s on a network a fare,real time robot environment could be used with the Teachers System acting as the Main Display on a whiteboard as an Environment Server.

Load Robocode from the Internet and have a look – it’s a free, slick, bit of software.  An application like this introduced into ICT on the R-PI would catch their attention - with a different robot environments you could cater for all sorts of different mindsets - from the artist to the budding defence industry developer.

Paul.

o19
Posts: 38
Joined: Sat Jan 28, 2012 8:42 pm

Re: An Introduction to Robocode

Wed Feb 01, 2012 5:14 pm

Robocode is really great. But I suspect that JVM + IDE + Robocode might require some additional resources.

edit: Which is not meant to stop the discussion. Robocode is probably the best learning environment I've seen so far. (recommended age: middle school, I guess)

GBQ57
Posts: 3
Joined: Sun Jan 29, 2012 10:10 pm

Re: An Introduction to Robocode

Wed Feb 01, 2012 7:52 pm

It may be a little big – not sure – its been a few years since I ran it – that said it was released in 2001 – back then I think the average PC was round 500 MHz and 256MB of RAM – it may not be that far off the R_PI specs – time will tell not long to wait now.

The good thing was you could get straight into writing code that did something – there was even an inbuilt compiler to make getting started easier – you didn"t even need to use the Java JDK.

For a taster for those who have not seen Robocode this is the code for a fully functioning robot (it won"t win competitions but it"s a start) – only the bold bits are entered by the student.

package man;

import robocode.*;

public class MyFirstRobot extends Robot {

  public void run() {

    while (true) {

    ahead(100);

    turnGunRight(360);

    back(100);

    turnGunRight(360);

    }

  }

  public void onScannedRobot(ScannedRobotEvent e) {

    fire(1);

  }

}

The key point here is that once the little ones start writing code and sharing it you need to make sure the code runs in it"s own sandbox – robocode is a tool that provides that and would be a desirable model for any other educational tool to stop them viruses spreading.

Paul.

o19
Posts: 38
Joined: Sat Jan 28, 2012 8:42 pm

Re: An Introduction to Robocode

Wed Feb 01, 2012 8:10 pm

There is also a pretty good community. Here's an example of a bit more elaborate code, which you'll nonetheless reach within a few weeks, once you're infected.

http://robowiki.net/wiki/Wave_.....g_Tutorial

User avatar
MonitorMan
Posts: 22
Joined: Tue Jan 03, 2012 1:31 am
Contact: Website

Re: An Introduction to Robocode

Thu Feb 02, 2012 4:25 am

I think this used to be called 'Turtle' in the days of the BBC Micro.  We used to feature it regularly in Acorn User and Educational Computing. This may be a little more advanced, but the concept is the same.

In the case of Turtle the code used to control a 'turtle' avatar on the screen and the kids could program it to draw shapes and colour them. It was a captivating way for them to learn about geometry. 'Program your turtle to draw an equilateral triangle that has a base width of 100mm.'

The software could also be used to control a peripheral too.

The concept would still be great in schools today.
Raspberry Pi Assembly Language now available in book and eBook formats.
For details, go to www.brucesmith.info - examples and programming hints and tips.
Check out the Raspberry Pi Resources page on the website for more information.

User avatar
n3tw0rk5
Posts: 216
Joined: Fri Jan 06, 2012 6:04 pm

Re: An Introduction to Robocode

Thu Feb 02, 2012 7:06 am

MonitorMan said:


I think this used to be called 'Turtle' in the days of the BBC Micro.  We used to feature it regularly in Acorn User and Educational Computing. This may be a little more advanced, but the concept is the same.

In the case of Turtle the code used to control a 'turtle' avatar on the screen and the kids could program it to draw shapes and colour them. It was a captivating way for them to learn about geometry. 'Program your turtle to draw an equilateral triangle that has a base width of 100mm.'

The software could also be used to control a peripheral too.

The concept would still be great in schools today.



Ah yeah the turtle, wasnt it logo that they used to control it?

Totally agree that the concept would work well in schools today, especially primary schools where it would catch the kids imagination being able to draw pictures via a robot.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: An Introduction to Robocode

Thu Feb 02, 2012 5:27 pm

It" far closer to Core Wars" "redcode" than Logo, although elements are quite obviously derived from logo"s turtle graphics.

Looks like fun. I mean, who doesn"t want to kill something every now and then?

nmahoney
Posts: 9
Joined: Mon Feb 06, 2012 9:48 am

Re: An Introduction to Robocode

Mon Feb 06, 2012 10:12 am

There's also the TeamBots project (http://www.teambots.org/) which is similar but without the tanks.

I used to have great fun with the SoccerBots (http://www.teambots.org/Domain.....index.html) version back when I was learning Java. A great little Java application where you code your own 5-a-side team to play against others. My teams were always rubbish, but that's not the point.

Could be quite good for those that (for whatever reason) think tanks are too violent for education.

GBQ57
Posts: 3
Joined: Sun Jan 29, 2012 10:10 pm

Re: An Introduction to Robocode

Mon Feb 06, 2012 2:40 pm

I share the concern that tanks may be too violent – I have already put out in a request to the robocode community to allow the 'game physics' to be an extendible class so that other, less violent, but still competitive games may be developed with ease – including football type variants.

I think robocode is a good starting point – robocode already has support for teams, messaging between team members etc and, as I said before, support for safely importing robot code from untrusted sources.

It also has a presently active user base, as well as an automated league – submit your bot and have it battle it out with all other bots on a server in the ether somewhere (over 800 bots have been submitted over the years).

I can write a top notch bot – but I'm not sure I have the skills to start messing with other peoples code to fix up all the shortcomings of robocode for the PI and education.

Paul.

nmahoney
Posts: 9
Joined: Mon Feb 06, 2012 9:48 am

Re: An Introduction to Robocode

Mon Feb 06, 2012 6:08 pm

Guess it's been longer since I was learning Java than I thought. TeamBots/SoccerBots doesn't seem to have been updated or had any leagues for a while. Oops.

Still, I agree robocode is a great way to learn programming. A quick google found that someone did implement a football game mode (http://old.robowiki.net/robowi.....erRobocode) but again that seems like it was from some time ago. I might have a go at trying to bring it up to date.

chase
Posts: 3
Joined: Tue Feb 14, 2012 8:32 pm
Contact: Website

Re: An Introduction to Robocode

Wed Feb 15, 2012 1:21 am

While tanks and bullets are a bit violet, and that is a valid concern. I wonder if that is that big of a problem. As it is none the less somewhat interesting.

That is to say, I am not disagreeing that the apparently simple 2D graphics are to a degree violent, but wonder if that will really be a big negative factor. Not sure I see the violence as imitable or immersive, as they are not directly controlling the machine. Most cartoons are more violent in my opinion.

I only mention this not because I condone violence or wish to corrupt anyone's children, but that every additional change makes it less likely the project of getting it onto the Pi will move forward quickly.

tl;dr

Is it really violent enough that a change is required to make it a viable and nondestructive teaching tool?

@nmahoney: Just as a warning. That modified version is very old and the code has changed considerably since it was made, which might make it more difficult to port.

nmahoney
Posts: 9
Joined: Mon Feb 06, 2012 9:48 am

Re: An Introduction to Robocode

Wed Feb 15, 2012 5:33 pm

Chase said:


tl;dr

Is it really violent enough that a change is required to make it a viable and nondestructive teaching tool?


Short answer, no. I see nothing wrong with it as it is and certainly don't consider it too violent.

It's more a matter of me remembering enjoying SoccerBots more than Robocode when I was learning Java. The less violent nature is just a good excuse from my point of view.

I did spot that the modified version is indeed very old. Might even be old enough to make writing a new modified version from scratch an easier alternative to porting it. In either case, I'd like to give it a go if only for my own amusement. Just need to find the spare time to do so. Sadly that seems in short supply at the moment.

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: An Introduction to Robocode

Wed Feb 15, 2012 6:08 pm

Change it to "paintgun"?

chase
Posts: 3
Joined: Tue Feb 14, 2012 8:32 pm
Contact: Website

Re: An Introduction to Robocode

Wed Feb 15, 2012 10:53 pm

Gert said:


Change it to "paintgun"?


Well you can already change the color of the bullet, what is to say that is not already the case.

Voidious
Posts: 15
Joined: Mon Aug 20, 2012 8:05 pm

Re: An Introduction to Robocode

Tue Aug 21, 2012 2:34 pm

A couple folks have now posted about running stock Robocode on the Raspberry Pi (near the bottom of http://robowiki.net/wiki/Raspberry_Pi). One report of "battles are slow but the app/editor seem ok", another of "everything's painfully slow, even the editor and battles between sample bots".

I've only just ordered mine, so no first hand info to report. I'm looking into the idea of writing a new game from scratch in C++ with bots in Lua, but not sure what will come of that yet.

Voidious
Posts: 15
Joined: Mon Aug 20, 2012 8:05 pm

Re: An Introduction to Robocode

Mon Sep 10, 2012 5:07 am

Just posted a video with a very early look at a programming game I've been working on for the Raspberry Pi, if anyone's interested. http://www.youtube.com/watch?v=kSVarS29-UQ

Doing my best to make something that runs well on the Raspberry Pi and is very beginner friendly. Still lots to do but it's coming along pretty nicely.

Voidious
Posts: 15
Joined: Mon Aug 20, 2012 8:05 pm

Re: An Introduction to Robocode

Tue Sep 25, 2012 6:33 pm

Posted a couple more vids of the programming game I've been working on.

* part 1: sample stages, battle mode
* part 2: stage and bot APIs

It's a lot further along now and actually quite playable, and I'm pretty excited about how it's turning out. Probably still a few weeks away from actually releasing anything.

Return to “Staffroom, classroom and projects”