Top Banner
Robocode Division of Computer Engineering, SOE Page 1 ROBOCODE Seminar Report Submitted in partial fulfilment of the requirements for the award of the degree of Bachelor of Technology in Computer Science and Engineering of Cochin University Of Science And Technology by SUDHANSHU VARMA DIVISION OF COMPUTER SCIENCE SCHOOL OF ENGINEERING COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY KOCHI-682022 AUGUST 2010
25

Robocode - an Open Source educational game

Jan 19, 2015

Download

Technology

Alien Coders

Robocode is an Open Source educational game by Mathew Nelson (originally R was provided by IBM). It is designed to help people learn to program in Java and enjoy the experience. It is very easy to start - a simple robot can be written in just a few minutes but perfecting a bot can take months or more
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 1

ROBOCODESeminar Report

Submitted in partial fulfilment of the requirements

for the award of the degree of

Bachelor of Technology

in

Computer Science and Engineering

of

Cochin University Of Science And Technology

by

SUDHANSHU VARMA

DIVISION OF COMPUTER SCIENCE

SCHOOL OF ENGINEERING

COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY

KOCHI-682022

AUGUST 2010

Page 2: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 2

ABSTRACT

Robocode is an Open Source educational game by Mathew Nelson (originally R was provided byIBM). It is designed to help people learn to program in Java and enjoy the experience. It is veryeasy to start - a simple robot can be written in just a few minutes but perfecting a bot can takemonths or more. Competitors write software that controls a miniature tank that fights otheridentically-built (but differently programmed) tanks in a playing field. Robots move, shoot ateach other, scan for each other, and hit the walls (or other robots) if they aren’t careful. Thoughthe idea of this game may seem simple, the actual strategy needed to win is not.

Good robots have hundreds of lines in their code dedicated to strategy. Some of the moresuccessful robots use techniques such as statistical analysis and attempts at neural networks intheir designs. One can test a robot against many other competitors by downloading their bytecode, so design competition is fierce. Robocode provides a security sandbox (bots are restrictedin what they can do on the machine they run on) which makes this a safe thing to do.

Page 3: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 3

Table of Contents

Chapter Title Page No.

- Acknowledgement

- Abstract

1. Introduction…………………………………………………….1

2. Basic Principles used in Robocode……………………………. 22.1 Artificial Intelligence……………………………………..22.2 Computer Graphics…………………………………….....32.3 Finite state machines……………………………………...5

3. Initial version of Robocode……………………………………..7

4. Bot Design……………………………………………………..14

5. Typical Bots……………………………………………..……..16

6. Educational Importance………………………………………..19

7. Conclusion……………………………………………………..20

8. References……………………………………………………...21

Page 4: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 4

ACKNOWLEDGEMENT

I thank GOD almighty for guiding me throughout the seminar. I would like to thank all those

who have contributed to the completion of t he seminar and helped me with valuable suggestions

for improvement.

I am extremely grateful to Dr. David Peter, Head Of Division, Division of Computer Science,

for providing me with best facilities and atmosphere for the creative work guidance and

encouragement.. I would like to thank my guide, Mrs. Dhanya K Sudhish, Lecturer, Division

of Computer Science, for all help and support extend to me. I thank all Staff members of my

college and friends for extending their cooperation during my seminar.

Above all I would like to thank my parents without whose blessings, I would not have been able

to accomplish my goal.

SUDHANSHU VARMA

Page 5: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 5

Chapter 1

Introduction

Robocode is an Open Source educational game started by Mathew Nelson (originally providedby IBM). Currently contributions are being made by various people; officially Flemming N.Larsen and Pavel Šavara are working on Robocode to keep it current and fix the bugs. The gameis designed to help people learn to program in Java or, starting in version 1.7.2, .NET Frameworkprogramming languages (C#, VB.NET, etc.), and enjoy the experience. It is very easy to start - asimple robot can be written in just a few minutes - but perfecting a bot can take months or more.

Competitors write software that controls a miniature tank that fights other identically-built (butdifferently programmed) tanks in a playing field. Robots can move, shoot at each other, scan foreach other, and hit the walls (or other robots) if they aren't careful. Though the idea of this"game" may seem simple, the actual strategy needed to win is not. Good robots can havethousands of lines in their code dedicated to strategy. Some of the more successful robots usetechniques such as statistical analysis or attempts at neural networks in their designs.

Page 6: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 6

Chapter 2

Basic Principles used in Robocode

There are three basic principles used in the game of Robocode. These are Artificial intelligence,Finite state machines and computer graphics for standard display.

2.1 Artificial Intelligence

Artificial intelligence (AI) is the intelligence of machines and the branch of computer sciencethat aims to create it. AI textbooks define the field as "the study and design of intelligent agents"where an intelligent agent is a system that perceives its environment and takes actions thatmaximize its chances of success. John McCarthy, who coined the term in 1956,[ defines it as "thescience and engineering of making intelligent machines."

The field was founded on the claim that a central property of humans, intelligence—the sapienceof Homo sapiens—can be so precisely described that it can be simulated by a machine. Thisraises philosophical issues about the nature of the mind and limits of scientific hubris, issueswhich have been addressed by myth, fiction and philosophy since antiquity. Artificialintelligence has been the subject of optimism, but has also suffered setbacks and, today, hasbecome an essential part of the technology industry, providing the heavy lifting for many of themost difficult problems in computer science.

AI research is highly technical and specialized, deeply divided into subfields that often fail tocommunicate with each other. Subfields have grown up around particular institutions, the workof individual researchers, the solution of specific problems, longstanding differences of opinionabout how AI should be done and the application of widely differing tools. The central problemsof AI include such traits as reasoning, knowledge, planning, learning, communication, perceptionand the ability to move and manipulate objects. General intelligence (or "strong AI") is stillamong the field's long term goals.

Cognitive science is the interdisciplinary study of mind and how information, e.g., concerningperception, language, reasoning, and emotion, is represented and transformed in the brain. Itconsists of multiple research disciplines, including psychology, artificial intelligence,philosophy, neuroscience, learning sciences, linguistics, anthropology, sociology, and education.It spans many levels of analysis, from low-level learning and decision mechanisms to high-levellogic and planning; from neural circuitry to modular brain organization. The term cognitivescience was coined by Christopher Longuet-Higgins in his 1973 commentary on the Lighthill

Page 7: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 7

report, which concerned the then-current state of Artificial Intelligence research. In the samedecade, the journal Cognitive Science and the Cognitive Science Society were founded.

2.2 Computer graphics

Computer graphics are graphics created using computers and, more generally, the representationand manipulation of image data by a computer.

The development of computer graphics, has made computers easier to interact with, and betterfor understanding and interpreting many types of data. Developments in computer graphics havehad a profound impact on many types of media and have revolutionized animation, movies andthe video game industry.

For the purpose of Robocode we are essentially dealing with 2-D graphics .

2D graphics are the computer-based generation of digital images—mostly from two-dimensionalmodels, such as 2D geometric models, text, and digital images, and by techniques specific tothem. The word may stand for the branch of computer science that comprises such techniques, orfor the models themselves.2D computer graphics are mainly used in applications that wereoriginally developed upon traditional printing and drawing technologies, such as typography,cartography, technical drawing, advertising, etc.. In those applications, the two-dimensionalimage is not just a representation of a real-world object, but an independent artifact with addedsemantic value; two-dimensional models are therefore preferred, because they give more directcontrol of the image than 3D computer graphics, whose approach is more akin to \photographythan to typography.

The advance in computer graphics was to come from one MIT student, Ivan Sutherland. In 1961Sutherland created another computer drawing program called Sketchpad. Using a light pen,Sketchpad allowed one to draw simple shapes on the computer screen, save them and even recallthem later. The light pen itself had a small photoelectric cell in its tip. This cell emitted anelectronic pulse whenever it was placed in front of a computer screen and the screen's electrongun fired directly at it. By simply timing the electronic pulse with the current location of theelectron gun, it was easy to pinpoint exactly where the pen was on the screen at any givenmoment. Once that was determined, the computer could then draw a cursor at that location.

Sutherland seemed to find the perfect solution for many of the graphics problems he faced. Eventoday, many standards of computer graphics interfaces got their start with this early Sketchpadprogram. One example of this is in drawing constraints. If one wants to draw a square forexample, s/he doesn't have to worry about drawing four lines perfectly to form the edges of thebox. One can simply specify that s/he wants to draw a box, and then specify the location and sizeof the box. The software will then construct a perfect box, with the right dimensions and at theright location. Another example is that Sutherland's software modeled objects - not just a pictureof objects. In other words, with a model of a car, one could change the size of the tires withoutaffecting the rest of the car. It could stretch the body of the car without deforming the tires.

Page 8: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 8

These early computer graphics were Vector graphics, composed of thin lines whereas modernday graphics are Raster based using pixels. The difference between vector graphics and rastergraphics can be illustrated with a shipwrecked sailor. He creates an SOS sign in the sand byarranging rocks in the shape of the letters "SOS." He also has some brightly colored rope, withwhich he makes a second "SOS" sign by arranging the rope in the shapes of the letters. The rockSOS sign is similar to raster graphics. Every pixel has to be individually accounted for. The ropeSOS sign is equivalent to vector graphics. The computer simply sets the starting point and endingpoint for the line and perhaps bend it a little between the two end points. The disadvantages tovector files are that they cannot represent continuous tone images and they are limited in thenumber of colors available. Raster formats on the other hand work well for continuous toneimages and can reproduce as many colors as needed.

Page 9: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 9

2.3 Finite state machines

Artificial intelligence is modelled as a sequence of mental states. World events force a change instate. Let us see what finite state machines basically are.

A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a statemachine, is a mathematical abstraction sometimes used to design digital logic or computerprograms. It is a behavior model composed of a finite number of states, transitions between thosestates, and actions, similar to a flow graph in which one can inspect the way logic runs whencertain conditions are met. It has finite internal memory, an input feature that reads symbols in asequence, one at a time without going backward; and an output feature, which may be in theform of a user interface, once the model is implemented. The operation of an FSM begins fromone of the states (called a start state), goes through transitions depending on input to differentstates and can end in any of those available, however only a certain set of states mark asuccessful flow of operation (called accept states).

Finite-state machines can solve a large number of problems, among which electronic designautomation, communication protocol design, parsing and other engineering applications. Inbiology and artificial intelligence research, state machines or hierarchies of state machines aresometimes used to describe neurological systems and in linguistics — to describe the grammarsof natural languages.

Acceptors and recognizers (also sequence detectors) produce a binary output, saying either yes orno to answer whether the input is accepted by the machine or not. All states of the FSM are saidto be either accepting or not accepting. At the time when all input is processed, if the currentstate is an accepting state, the input is accepted; otherwise it is rejected. As a rule the input aresymbols (characters); actions are not used. The example in figure 2 shows a finite state machinewhich accepts the word "nice". In this FSM the only accepting state is number 7.

The machine can also be described as defining a language, which would contain every wordaccepted by the machine but none of the rejected ones; we say then that the language is acceptedby the machine. By definition, the languages accepted by FSMs are the regular languages—thatis, a language is regular if there is some FSM that accepts it.

A further distinction is between deterministic (DFA) and non-deterministic (NDFA, GNFA)automata. In deterministic automata, every state has exactly one transition for each possibleinput. In non-deterministic automata, an input can lead to one, more than one or no transition fora given state. This distinction is relevant in practice, but not in theory, as there exists analgorithm which can transform any NDFA into a more complex DFA with identicalfunctionality.

The FSM with only one state is called a combinatorial FSM and uses only input actions. Thisconcept is useful in cases where a number of FSM are required to work together, and where it isconvenient to consider a purely combinatorial part as a form of FSM to suit the design tools.

Page 10: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 10

There are four kind of finite state machines. They are :

Stack based FSM

Hierarchical FSM

Non deterministic hierarchical FSM

Fuzzy state FSM

There are two methods of debugging FSM. They are online and offline debugging. Offlinedebugging mainly consists of logging and checking verbosity levels.

Verbosity is the product of making a text verbose, a process which is the exact opposite of beingconcise. A verbose text is one that has a larger than necessary amount of words, usually theinflation being due to a higher number of adjectives. Verbose texts tend to be more descriptive,but at the cost of blurring the information, to the point where excessively verbose texts have onlydescription, and are often unreadable.

Individual words which are excessive, and unnecessary, are referred to as pleonasms, whereasincidents of excessive verbosity are referred to as logorrhoea.

Verbosity is also a term used to describe a feature of screen-reading programs that supportvision-impaired computer users. Speech verbosity controls enable users to choose how muchspeech feedback they wish to hear. Specifically, verbosity settings allow users to construct amental model of web pages displayed on their computer screen. Based on verbosity settings, ascreen-reading program informs users of certain formatting changes, such as when a frame ortable begins and ends, where graphics have been inserted into the text, or when a list appears inthe document.

Some screen reading programs also include language verbosity, which automatically detectsverbosity settings related to speech output language. For example, if a user navigated to awebsite based in the United Kingdom, the text would be read with a British accent.

Online debugging mainly deals with on the run graphical representation altering. Command linealters the behaviour.

Page 11: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 11

Chapter 3

Initial version of Robocode

Robocode is an easy-to-use robotics battle simulator that runs across all platforms supportingJava 2. You create a robot, put it onto a battlefield, and let it battle to the bitter end againstopponent robots created by other developers. Robocode comes with a set of pre-fab opponents toget you started, but once you outgrow them, you can enter your creation against the world's bestin one of the leagues being formed worldwide.

Each Robocode participant creates his or her own robot using elements of the Java language,enabling a range of developers -- from rank beginners to advanced hackers -- to participate in thefun. Beginning Java developers can learn the basics: calling API code, reading Javadocs,inheritance, inner classes, event handling, and the like. Advanced developers can tune theirprogramming skill in a global challenge to build the best-of-breed software robot. In this article,we will introduce Robocode and start you on your way to conquering the world by building yourvery first Robocode robot. We will also take a peek at the fascinating "behind the scenes"machinery that makes Robocode tick.

Robocode is the brainchild of Mathew Nelson, a software engineer in the Advanced Technology,Internet division at IBM. First, head to the Robocode page. Here, you will find the latestexecutables of the Robocode system. Once you have downloaded the distribution, which is in aself-contained installation file, you can use the following command to get the package installedon your system (assuming you have a Java VM (JDK 1.3.x) pre-installed on your machine, ofcourse):

java -jar robocode-setup.jar

During installation, Robocode will ask you if you'd like to use this external Java VM for robotcompilations. The other alternative is the Jikes compiler that is supplied as part of the Robocodedistribution.

After your installation, you can start the Robocode system from either the shell script(robocode.sh), batch file (robocode.bat), or icon on the desktop. At this point, the battlefield willappear. From here, you can invoke the Robot Editor and compiler using the menu.

When you activate Robocode, you will see two interrelated GUI windows, which formRobocode's IDE:

The battlefield The Robot Editor

Page 12: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 12

Figure 1 shows the battlefield and the Robot Editor in action.

Fig 1 Robot editor

The battlefield is where the battle between the robots plays itself out. It houses the mainsimulation engine and allows you to create, save, and open new or existing battles. You canpause and resume the battle, terminate the battle, destroy any individual robot, or get thestatistics of any robot using the controls available in the arena. Furthermore, you can activate theRobot Editor from this screen.

The Robot Editor is a customized text editor for editing the Java source files that make up arobot. It integrates both the Java compiler (for compiling robot code) and the customized Robotpackager in its menu. Any robot created with the Robot Editor and successfully compiled is in aready-to-deploy location for the battlefield.

A robot in Robocode consists of one or more Java classes. These classes can be archived into aJAR package. The latest version of Robocode provides a "Robot Packager" that can be activatedfrom the battlefield GUI window, for just this purpose.

Page 13: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 13

Following are the basic commands used in Robocode.

Let's begin with the basic commands to move the robot and its accoutrements:

turnRight(double degree) and turnLeft(double degree) turn the robot by a specifieddegree.

ahead(double distance) and back(double distance) move the robot by the specified pixeldistance; these two methods are completed if the robot hits a wall or another robot.

turnGunRight(double degree) and turnGunLeft(double degree) turn the gun, independentof the vehicle's direction.

turnRadarRight(double degree) and turnRadarLeft(double degree) turn the radar on top ofthe gun, independent of the gun's direction (and the vehicle's direction).

None of these commands will return control to the program until they are completed.Furthermore, when the vehicle is turned, the direction of the gun (and radar) will also move,unless indicate differently by calling the following methods:

setAdjustGunForRobotTurn(boolean flag): If the flag is set to true, the gun will remain inthe same direction while the vehicle turns.

setAdjustRadarForRobotTurn(boolean flag): If the flag is set to true, the radar willremain in the same direction while the vehicle (and the gun) turns.

setAdjustRadarForGunTurn(boolean flag): If the flag is set to true, the radar will remainin the same direction while the gun turns. It will also act as ifsetAdjustRadarForRobotTurn(true) has been called.

Many methods exist for getting information about the robot. Here is a short list of frequentlyused method calls:

getX() and getY() get the current coordinate of the robot.

getHeading(), getGunHeading(), and getRadarHeading() get the current heading of thevehicle, gun, or radar in degrees.

Page 14: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 14

getBattleFieldWidth() and getBattleFieldHeight() get the dimension of the battlefield forthe current round.

Once you have mastered how to move the robot and its associated weaponry, it's a good time toconsider the tasks of firing and controlling damage. Each robot starts out with a default "energylevel," and is considered destroyed when its energy level falls to zero. When firing, the robot canuse up to three units of energy. The more energy supplied to the bullet, the more damage it willinflict on the target robot. fire(double power) and fireBullet(double power) are used to fire abullet with the specified energy (fire power). The fireBullet() version of the call returns areference to a robocode.Bullet object that can be used in advanced robots.

Whenever the robot moves or turns, the radar is always active, and if it detects any robots withinits range, an event is triggered. As the robot creator, you can choose to handle various events thatcan occur during the battle. The basic Robot class has default handlers for all of these events.However, you can override any of these "do nothing" default handlers and implement your owncustom actions. Here are some of the more frequently used events:

ScannedRobotEvent. Handle the ScannedRobotEvent by overriding theonScannedRobot() method; this method is called when the radar detects a robot.

HitByBulletEvent. Handle the HitByBulletEvent by overriding the onHitByBullet()method; this method is called when the robot is hit by a bullet.

HitRobotEvent. Handle the HitRobotEvent by overriding the onHitRobot() method; thismethod is called when your robot hits another robot.

HitWallEvent. Handle the HitWallEvent by overriding the onHitWall() method; thismethod is called when your robot hits a wall.

That's all we need to know to create some pretty complex robots. You can find the rest of theRobocode API in the Javadoc, which can be accessed from either the battlefield's help menu orthe Robot Editor's help menu.

To create a new robot, start the Robot Editor and select File->New->Robot. You will beprompted for the name of the robot, which will become the Java class name. Enter DWStraightat this prompt. Next, you will be prompted for a unique initial, which will be used for the nameof the package that the robot (and potentially its associated Java file) will reside in. Enter dw atthis prompt.

The Robot Editor will display the Java code that you need to write to control the robot.

Page 15: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 15

Area1In this space we can declare class scope variables and set their value. They will be availablewithin the robot's run() method, as well as any other helper methods that you may create.

Area2The run() method is called by the battle manager to start the robot's life. It typically consists oftwo areas (designated Area 2 and Area 3 in Listing 1) where you can add code. Area 2 is whereyou will place code that will run only once per robot instance. It is often used to get the robotinto a pre-determined state before starting repetitive action.

Area3This is the second part of a typical run() method implementation. Here, within an endless whileloop, we'll program the repetitive action that a robot may be involved in.

Area4This is the area where you add helper methods for the robot to use within its run() logic. It's alsowhere you add any event handlers that you wish to override. For example, the code in Listing 1handles the ScannedRobot event and simply fires directly at the robot whenever one is detectedby the radar.

From the Robot Editor menu, select Compiler->Compile to compile your robot code. We arenow ready to try our first battle. Switch back to the battlefield and select menu Battle->New todisplay a dialog similar to the one in Figure 2.

Add our robot, dw.DWStraight to the battle, then add an opponent robot, such as sample.SittingDuck. Click Finish, and the battle will begin. Admittedly, doing battle with SittingDuck isnot too exciting, but you get to see what the DWStraight robot does by default. Experiment withother robots in the sample collection, and see how DWStraight fares against them.

When you're ready to examine the coding of another robot, check out the dw.DWRotater robotcode that is supplied with the code distribution in Resources. This robot will, by default:

Move to the center of the battlefield Keep spinning its gun until it detects a robot Fire slightly ahead of the detected robot, trying different angles each time Move rapidly back and forth whenever it is hit by another robot.

Page 16: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 16

Fig 2. New battle dialogue.

A look behind the scenes at Robocode reveals a sophisticated simulation engine that is both highperformance (in order to render the battle at realistic speed) and flexible (enabling the creation ofcomplex robotics logic without getting in the way). A special thanks to Robocode creatorMathew Nelson for graciously providing the inside information on the architecture of thesimulation engine.

A battle manager thread manages the robots, bullets, and rendering on the battlefield. Thesimulation "clock" is marked by the number of frames rendered on the battlefield. The actualframe rate is adjustable by the user.

Page 17: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 17

For a project that debuted as recently as July 12, 2001, Robocode's climb to fame is nothing shortof phenomenal. While the latest version available has yet to hit 1.0 (at the time of writing it isversion 0.98.2), it is already becoming a very popular pastime on university campuses andcorporate computers throughout the world. Robocode leagues (or roboleagues), in which peoplepit their custom creations against each other over the Internet, are springing up fast. Universityprofessors are tapping Robocode's educational properties and have incorporated it into theircomputer science curriculum. Robocode user groups, discussion list, FAQs, tutorials, andWebrings can be found throughout the Internet.

Evidently, Robocode has filled a void in the popular gaming and educational arena -- supplying asimple, fun, non-intimidating, yet competitive way for students and midnight engineers tounleash their creative energy and potentially fulfill their fantasy to conquer the world.

Page 18: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 18

Chapter 4

Bot Design

A typical Robocode bot has three basic parts. Gun, radar and a tank body.

Fig 3. A typical bot

C++ is the best programming language in general for most bots. It is the most powerful andexpansive. However, it also can get very complicated and to a new programmer. It talks a lot ofdetailed code to do what you want.

If one has not programmed before, a language like Visual Basic 6 is good. It is MUCH simplerto learn. However, it is less powerful when it comes to handling lots of data and working on alow level with the game. (But it's fine for sending mouse clicks and keyboard presses.) It caneven read application's memory fine.

Page 19: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 19

It is recommend against Java. It is not as tailored for accessing OS specific functions like mouseoverrides, memory writing, etc.

One should start by learning one of the languages via a web tutorial (many very decent onesaround) or a book. Then, coding bots will just make intuitive sense to you. Learning how to botand THEN program does not work well.

In Robocode however, the coding is usually done in Java. The bot has three basic entities. Thegun, the radar and the body.

Constraints are drawn on the gun and radar movements as they have to be synchronized as oneunit. Gun is used to fire the bullets. Radar is used for scanning purpose of other bots present inthe vicinity. The coding is done in a manner that the tanks not only avoid hitting bullets but alsothe walls of the simulator.

Page 20: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 20

Chapter 5

Typical bots

1. Druss GT

It uses a unique method of storing the Visit Count Stats. I set up a bunch of different dimensionsand slices, and randomly generated 100 buffers, which should cover all the attributes quite well.

It is very competitive. No. 1 in the main rumble.

It dodges bullets by keeping tabs on which angles (actually Guess Factors) the enemy is mostlikely to shoot at in different circumstances, and avoiding them

Between rounds it saves all the targeting and movement data, between matches nothing

Druss The Legend was an axe warrior, the hero in several books by David Gemmell. The 'GT' isbecause it uses GoTo style Wave Surfing.

The next few steps in its advancements can be speeding it up, and a refactor! Perhaps make atruesurfing variant?

2. Diamond

What's special about it?

It took the Melee throne from Shadow. It may have the strongest 1v1 gun against random movers. The Melee and Anti-Surfer guns use displacement vectors. It has pretty debugging graphics.

It is currently #2 in both Melee and 1v1.

It uses a Minimum Risk Movement, evaluating a bunch of points around itself andchoosing the "safest" (least bad / most good) one. I'm still (endlessly, perhaps) tweakingthe parameters, but some of the elements are:

Considers points in a (randomized radius) circle around itself. Stay far away from other bots, weighted by their energy. Stay perpendicular to other bots. Don't be the closest bot to any other bots (avoid being targeted).

Page 21: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 21

Some randomizing based on past locations.

In 1v1, it uses Wave Surfing (algorithm derived from Dookious) with DynamicClustering for data analysis.The gun uses Dynamic Clustering for data analysis - i.e., k-nearest neighbors to findsimilar states, and kernel density among those states to settle on a firing angle. It usesdisplacement vectors for recording and reconstructing firing angles. It fires a wave foreach scan and records the vector the enemy traveled along (interpolating missed scans, ifnecessary), relative to his initial heading and divided by bullet ticks. To reconstruct afiring angle, it applies one of these vectors to the enemy's current location, heading, anddistance (bullet ticks). I thought this made more sense for Melee than GuessFactors, andit's a lot simpler and more efficient than real play-it-forward.

As of 1.30, it no longer does. It aims at everyone on the battle field at once and tries to hitas many enemies as possible. (Big thanks to Shadow/Melee Gun for the excellent idea.)

In 1v1, it switches to a Wave Surfing movement and switches to its 1v1 Virtual Guns.

It saves nothing between matches. Between rounds, it saves all its targeting andmovement data, which includes general info about each enemy, a bunch of kd-trees, andmaps of the trees' data points to displacement vectors and/or Guess Factors.

Diamond is the ex-superhero name of the main character in Powers, my favorite comicbook series. That's how it initially occurred to me, as I like to name all my bots afterwarriors of some sort.

3. Shadow

What's special about it?

It is the first robot that uses this type of gun as describe below, and it is the first WaveSurfer ever.

Also, it is my first ever competitive bot redone with "modern" technologies.

Shadow is the first robot that features Wave Surfing.

This gun is firstly describe as Tron's Gun. I call it a "forward pattern matcher".

But later this gun is named Dynamic Clustering Play-It Forward gun.

Page 22: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 22

It dodges bullets by surfing enemy's waves.

It uses a Minimum Risk Movement

v3.84: with the HOT-avoidance system

It doesn't, instead it uses the strategy describe at Shadow/Melee Gun.

It doesn’t save any information between matches, although it saves all the information betweenrounds.

Page 23: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 23

Chapter 6

Educational Importance

Improving learning effectiveness has always been a constant challenge in software education andtraining. One of the primary tasks educators face is to motivate learners to perform to their bestabilities. One method of motivating learners is the game-based exercise. In this research, weconducted a field study in a community of software participants in the IBM Robocode game. Thecharacteristics of the Robocode game and the Robocode community were examined. Ourresearch could shed some light on how computer-programming games – such as the Robocodegame - could be used in software programming education to increase learning effectiveness.

As a Java-based environment, Robocode provides a well-defined domain for students to learnand apply concepts of object-oriented design and programming, such as proper design of classes,extension and re-use of existing codes using inheritance mechanisms, event handling andmessage passing (Bonakdarian & White, 2004). Robocode has been implemented in theclassroom to stimulate student learning-outcomes. One study found that when Robocode wasutilized in the classroom, students really enjoyed the project and also produced some verycreative solutions (Bierre, Ventura, Phelps & Egert, 2006). Research also found that Robocodeenabled students to develop skills for each stage of the software development process andfostered critical thinking (O'Kelly & Gibson, 2006).

Moreover, the results of the student’s efforts in Robocode can be seen instantly. Such instantgratification can speed up the learning cycle and is analogous to the “prototyping model” used insoftware development (O'Kelly & Gibson, 2006). Robocode also forces students to considerissues of "computer intelligence", i.e., how do agents sense and react to their environment tomaximize their goals? Thus, it is useful for courses related to artificial intelligence (Bonakdarian& White, 2004). By incorporating an enjoyable game into an artificial intelligence class andproviding students with tools for developing practical versions of the algorithms, studentsappreciated the theory better and developed greater confidence in their understanding of it(Hartness, 2004).

Page 24: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 24

Chapter 7

Conclusion

The trends in Robocode are increasing the diversity and heterogeneity of gamers and their

constituent devices. The newer version is expected to bring an explosion in terms of use of newer

ideas in our local environments. This paper presents one of the few applications in which

artificial intelligence can be put into use. This paper also provides a discussion of the challenges

associated with such a vision, framed around our conceptual model of computing. With more

progress in the fields like FSM, Artificial Intelligence and graphics , the infrastructure limitation

present currently is supposed to be broken as far as its mechanical analogy implementation is

concerned.

Page 25: Robocode - an Open Source educational game

Robocode

Division of Computer Engineering, SOE Page 25

Chapter 8

References

1. robocode.sourceforge.net/

2. en.wikipedia.org/wiki/Robocode

3. Artificial intelligence: A Philosophical Introduction by Jack Copeland

4. Synthesis of finite state machines: functional optimization by Timothy Kam