Getting Started - OriginalTanks/tanks GitHub Wiki

So. Where to start.


Start with your first tank, you can download a template here.

We'll start with two basic tanks: Runner and Shooter.

For each class you must extend Tank, and include the necessary includes:

 import game.board.elements.Tank;
 import game.util.TANK_DIR;
 import game.util.TANK_MOVES;
 import org.bson.types.ObjectId;
 import org.mongodb.morphia.annotations.Embedded;

 import java.util.List;

 public class Runner extends Tank'

Tank is an interface that can be downloaded here.

Your constructor must call the superConstructor:

'public Runner(ObjectId tankID, String tankName, int health) {
    super(tankID, tankName, health);

You can do whatever else you need to do there. The only function that must be implemented is the calculate turn. This accepts a list of tanks and a board size as parameters. From this you can see the locations of all other live tanks, their directions, as well as the size of the game board (for now all boards are square.)

'public TANK_MOVES calculateTurn(List<Tank> tanks, int size)'

As you can see calculateTurn must return a TANK_MOVE - which is an enum saying what your tank will do next. Options are:

  • WAIT

All are pretty self explanatory, when a tank shoots it's a laser, and will impact the first tank in the line of fire immediately.

Runner's code is simple, turn right until your facing north, and move as fast as you can.

 'if (this.getDir() != TANK_DIR.N) {
        return TANK_MOVES.TURN_RIGHT;
    } else {

And that's all there is to it.

##Available Information to your Tank##

You can access all the information about your own tank by calling any of the methods included in the abstract parent class Tanks.

  • getCoord()
    • getX()
    • getY()
  • getTankID()
  • getTankName()
  • getHealth()
  • GetDir()

You can see code and return values below.

 public final Coordinate getCoord() {
    return this.coord;

public final ObjectId getTankID() {
    return tankID;

public final String getTankName() {
    return tankName;

public final int getHealth() {
    return health;

public final TANK_DIR getDir() {
    return dir;


We use two enums, TANK_DIR and TANK_MOVES. They are defined below:

 public enum TANK_MOVES {

public enum TANK_DIR {
N, E, S, W}


And that's all there is to it. Simple interface, endless possibilites. Feel free to create helper methods as you design your tanks (Class attribute variables must be transient). Create one to hunt down a specific tank, a 'rammer' someone to just run away. Whatever you like.

Happy Coding.

⚠️ ** Fallback** ⚠️