Jolly Ninja

JollyNinja was designed to be easy to add functionality to. It has accumulated tricks over time and is pretty effective at both melee and 1v1 battles.

Multiple Strategy Architecture

JollyNinja utilises a multiple strategy architecture. At any one time, a single strategy is in operation. The active strategy determines which strategy to change to and when. Each strategy runs using the same sequence of simple functions in an AdvancedRobot class. The interface to each strategy is most easily seen by looking at the run() function.

public void run()
{
	reset();

	while (true)
	{
		currentStrategy.startTurn(); //any init that needs doing at the start of the turn
		currentStrategy.setMovement(); //sets the turning angle and the ahead/back movement
		currentStrategy.setScan(); //control the radar motion
		currentStrategy.setGunRotation(); //control the gun motion and fires if neccessary
		currentStrategy.endTurn();
		execute(); // finish the turn
	}
}

This simple endless loop scheduling is reminiscent of the simplest kind of task scheduling used in Embedded Systems with simple microcontrollers. In fact, programming Robocode robots is very similar to programming a simple microcontroller. The event handlers are analogous to interrupt handlers.

JollyNinja Melee Strategy

Scanning and Target information gathering

The information stored about the other robots in the battle is what enables all of the other strategies for both movement and targeting. Amount of information and it's timeliness are what I have tried to maximise.

The following information is maintained about each of the other robots that are in the current battle:

The optimal scanning technique is to always move the radar in the direction of (and a little bit past) the target robot that was scanned the longest ago. So I just select the target with the most out of date scanning data and move the radar towards it. This changes the scanning pattern between a fast side to side motion or circular motion depending on the position of the other robots and gives a faster update time on average for most the robots, compared to simple circular scanning.

Movement

The general idea of the movement strategy is simple. I calculate the position, velocity and heading of my robot for 4 possible canditate moves (ahead/back, left/right). I then wrote a function that returns a "goodness" value that uses this future robot information as well as the current known state of all of the other robots. I then move the robot using the best move. In this way all of the complexity is in the single function that calculates the goodness of a given game state.

The following is a list of the factors that are summed as a linear combination in order to determine the "goodness" of JollyNinja's position:

Targeting

Firstly, I select a target. I currently select targets on the basis of how many times that they have died (picking on better robots), how long since they have hit me (Revenge is a dish best served cold - Klingon Proverb) and how far away they are.

The data collection that I am already doing lets me use one of my Intercept classes that I have written to fire at the selected robot. I have written a few intercept classes that calculate firing information for Linear Movement, Circular Movement and Oscillating Movement.

JollyNinja 1v1 Strategy (MadHatter like Strategy)

Scanning

I finally implemented a "wide scan" scanning pattern. I keep track of the enemy position, velocity, angular velocity. I also use a Jiggle Analyser to work out if the enemy is moving back and forth.

Movement

Ahead/back movement is a simple oscilation, where the length of the move is a random number between 180 and 240.

The left and right turning uses a similar idea to the melee strategy. A goodness function evaluates the value of each potential move. The robot then picks the best one.

The goodness function tries to keep about 200 away from the enemy. It also tries to keep away from the walls. This technique has proved quite successful against nearly all of the other robots. Except those with better aiming algorithms.

Targeting

Targeting is very similar to the melee strategy. In fact I adapted the JiggleIntercept, LinearIntercept and CircularIntercept classes to work with the slower update rates of melee scanning. So the orginal targeting was designed for 1v1. If the oposition robots move in a straight line, a circle or jiggle back and forth, they soon die.

Send me an email if you have any cool ideas for melee or 1v1 strategies.

Home