Skip to main content
replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/
Source Link
replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/
Source Link

Parts of this challenge are based off of Ant Queen of the Hill ContestAnt Queen of the Hill Contest.

Parts of this challenge are based off of Ant Queen of the Hill Contest.

Parts of this challenge are based off of Ant Queen of the Hill Contest.

added 176 characters in body
Source Link
TheNumberOne
  • 11.6k
  • 11
  • 9

ToYour objective is to conquer the ants of the world ... or have the biggest army of ants. To do this, you start with a single queen. The queen can create worker ants by using food gathered by itself or other worker ants. Your worker ants can kill other ants by attacking them. In addition, a large enough group of worker ants can kill a queen ant thereby making that colony extinct. You win if you have the only queen left, or if the time is up[5] and you have the biggest army of ants.

The board will be a square with wraparound borders. The sizelength of each edge will beis determined by sqrt(1000*n)[1]1 where n is the number of competitors or starting queens. Before the game fierce battle for domination starts, 100*n[2] pieces of food will be distributed randomlysemi-randomly on the board at the beginning of the game. n queens, `1 for each player, will also randomly be randomly distributed on the board. Every cell on

1: n is the board will have a 24-bit pheromone which can be changed by your ants. A cell can contain multiple ants.number of starting players

Sight and Smell

Every antAnts are usually near-sighted and have somewhat short antenna. Because of this, ants in this simulation can only see ants and smell ants, food, and pheromonespheromone in its 3 by 3 neighborhood. They do not havecan also tell the ability to see outdifference between ants of this areadifferent species.

EveryBecause of limited brain space, every ant has a memory of up to 5 characters long. The starting memory for queens is null5 spaces.

Every ant is oriented in the same direction throughout the entire gamethat it last moved.[3] Queens start out oriented in a random direction.

Each worker ants can carry up to 1 unit of food. A queen ant can carry an unlimited amount (so that's what her body is for). Every ant picks up as much food on its current square as possible. A queen ant takes all the food from all adjacent squares including that carried by workers of any player.

Every turn, every ant is given a view of the local surroundings and then choses adecides to move. After every ant has made their choice, the movesAnts are then executedgiven priority in a randomtheir movement with those that are oldest moving first. The initial order for the starting queens is random.

Every square has a defensive value and an attacking value. Every queen adds 8 defensive value to the cell it is in. Every worker adds 2 defensive valueAn ant attacks by attempting to the cell it is inmove onto another ant. At the beginning of a turn, theWorker ants require two ants attacking value for each cell is resetthem in order to 0be killed. Every time an attack move is executed, the cell that is being attacked'sQueen ants require eight ants attacking value is incremented. If, after it is incremented, the attacking value is greater than the defensive value, allin order to be killed. Queen ants on that cell are eliminatedcannot attack. EveryAn ant after being killed drops 1all food and whatever it wasis carrying on deathand one additional unit of food.

An ant can move to any of the 8 surrounding squares. This does not changechanges the orientation of the ant to the direction it is moving.[3] If it tries to move to a square with an ant already on it, it is assumed to be attacking that ant, no matter if friendly or not.

An ant can drop a 24-bit pheromone on any ofoptionally increase the 8 surrounding squares orvalue of 4 different pheromones on the current onecell it is on, 1 of which can only be seen by ants of that particular colony. Pheromone has a value of a double-precision float and decreases by 1% every game tick. An ant can increase pheromone by up to 10.

A queen ant may create a worker and spawn it in any of the surrounding cells ... or its own cell. The queen ant also chooses the memory of the new worker.

To play this game, you mustYou can implement a bot inprogram or a java class that takes in an ant input and gives an ant output for that ant. Alternatively

Input:

Input contains your player id, I will provide a wrapper class which will allow your bot to play using stdinant's memory, if your ant is a queen, and stdoutthen the contents of the cells surrounding it. You can findThe cells are given from the controller [here](linktop left to controller).

Your bot must implementthe top right in this interfaceorder:

package ants;
import controller.*;
public0 abstract| class1 Player| {2
    public abstract String3 getName();| //Your4 bot's| name.5
    public abstract Action moveAnt(Ant ant, Cell[] surroundings, String memory);  //Applied to6 each| of7 your| ants.
}8

Your bot may not save state between each invocation of moveAnt. If it does, the bot will be disqualified. To create an action you can call one of the following functionsInput is format thus:

Actionplayer_id;ant_memory;is_queen;cell_0_info;cell_1_info.move(String newMemory, int destCell);
Action.attack(String newMemory, int destCell);
Action.createWorker(String newMemory

Cell info is formated like this:

pheromone_0, int destCellpheromone_1, String workerMem);
Action.dropPheromone(String newMemorypheromone_2, int destCellpheromone_3, int pheromone);   //pheromone will be truncated to 24 bits.
Action.doNothing(String newMemory);ant_type,ant_owner

surroundingsplayer_id and ant_owner are positive integers.
ant_memory is a 15-D arraycharacter long string.
is_queen is one of Celltrues representing the surrounding 3 by 3 area or false. The cells in each index of the array
The pheromones are given indouble-precision (64-bit) floats.
ant_type is one of W (for worker ants) and Q (for queen ants).
If there is no ant on a cell, ant_type and ant_owner will be omitted from the following configuration:input.

0 1 2
3 4 5
6 7 8

Output:

When you specify a destinationYou have to output the cell foryou want to move to, the pheromone you wish to add to your actioncurrent cell, and whether the ant would like to create an ant instead of moving (only works for queens :P).

It should be formatted thus: next_memory;cell;pheromone_0;pheromone_1;pheromone_2;pheromone_3;create_ant;created_ants_memory

The controller is rather flexible and should be able to understand what you must alsowrite if you use different delimiters or leave out some of the same configurationinformation. Make sure that next_memory comes first in your programs output and that it is exactly 5 characters long. If creating an ant, created_ants_memory needs to be the last 5 characters in the input.

Every Cellcell object has to be an integer in the following functions thatrange [0, 8] (defaults to 4).
pheromone_n has to be a positive float (defaults to 0).
create_ant needs to be one of: true, false, yes, no, 1, or 0 (defaults to false).

How to create a bot:

You have 3 options for this. You can:

  1. Implement the Ant interface with a java class. (Very fast)
  2. Communicate to the controller via I/O streams. (Fast (I think))
  3. Be called via command arguments and output via STDOUT (Slow depending on OS and programming language)

Note: Your bot must be completely deterministic. Given the same input, your bot should always return properties of the cellsame output.

Method 1:

Ant interface:

publicinterface intAnt getColor();{
public List<Ant> getAnts(); //Returns list of ants on current cell.
public intString getFoodmove(String input);       //Returns the amount of food on the current cell.
}

Implement this interface for your ants :)

Method 2:

Every ant hastime it is one of your ants' turns, your program will receive a line of input through STDIN followed by a newline. After receiving the following properties:input, your program is expected to output a line through STDOUT followed by a newline.

public String getOwner();   //Returns your name if you are the owner ... otherwise someone elses.
public boolean isQueen();
public int getFood();       //How much food this ant is carrying.

Method 3:

Your program will be executed with the input line as its first argument. Your program is expected to output through STDOUT.

Each time the moveAnt functionyour program is called, it should return within 5[4] milliseconds. Since the time limit may be exceeded due to fluctuations outside the ant function'syour control, an average will be calculated. If at any point the average is above 5[4] milliseconds and the total time taken by that particular ant functionyour program across all calls so far is more than 10 seconds, the relevant player will be disqualified. This means they will not be eligible to win and, their ant function will not be called again during that game, and all ants of that player will instantaneously perish.

  1. Should I make the board smaller or bigger than this? This gives each player an average of 1000 cells. Is this too much ... or too small?
  2. Is this too much food? This much food would be enough for each player to create an average of 1000 ants. Is this too many ants?
  3. Should ants stay in the same orientation throughout the game or:
    • Should they change to a random orientation every turn?
    • Change orientation so that the direction they last moved is now forward?
    • Same as last but randomly rotate it 45 degrees clockwise or counterclockwise.
    • Same as last but 90 degrees instead of 45 degrees.
  4. Should I make the time limit:
    • The same?
    • Shorter? If so, how much shorter?
    • Longer? If so, how much longer?
  5. How many turns should a game go before it is ended prematurely? Or should it be a time limit (for example, 5 minutes)? If so, how long should the time limit be?
  6. How can I improve this to look prettier?
  7. Any typos or formatting issues?
  8. Any other ways I can improve this challenge?

To conquer the ants of the world ... or have the biggest army of ants. To do this, you start with a single queen. The queen can create worker ants by using food gathered by itself or other worker ants. Your worker ants can kill other ants by attacking them. In addition, a large enough group of worker ants can kill a queen ant thereby making that colony extinct. You win if you have the only queen left, or if the time is up[5] and you have the biggest army of ants.

The board will be a square with wraparound. The size of each edge will be sqrt(1000*n)[1] where n is the number of competitors or starting queens. 100*n[2] pieces of food will be distributed randomly on the board at the beginning of the game. n queens, ` for each player, will also randomly be distributed on the board. Every cell on the board will have a 24-bit pheromone which can be changed by your ants. A cell can contain multiple ants.

Sight

Every ant can see ants and food and pheromones in its 3 by 3 neighborhood. They do not have the ability to see out of this area.

Every ant has a memory of up to 5 characters long. The starting memory for queens is null.

Every ant is oriented in the same direction throughout the entire game.[3]

Each worker ants can carry up to 1 unit of food. A queen ant can carry an unlimited amount. Every ant picks up as much food on its current square as possible. A queen ant takes all food from all adjacent workers.

Every turn, every ant is given a view of the local surroundings and then choses a move. After every ant has made their choice, the moves are then executed in a random order.

Every square has a defensive value and an attacking value. Every queen adds 8 defensive value to the cell it is in. Every worker adds 2 defensive value to the cell it is in. At the beginning of a turn, the attacking value for each cell is reset to 0. Every time an attack move is executed, the cell that is being attacked's attacking value is incremented. If, after it is incremented, the attacking value is greater than the defensive value, all ants on that cell are eliminated. Every ant drops 1 food and whatever it was carrying on death.

An ant can move to any of the 8 surrounding squares. This does not change the orientation of the ant.[3]

An ant can drop a 24-bit pheromone on any of the 8 surrounding squares or the current one it is on.

A queen ant may create a worker and spawn it in any of the surrounding cells ... or its own cell. The queen ant also chooses the memory of the new worker.

To play this game, you must implement a bot in java. Alternatively, I will provide a wrapper class which will allow your bot to play using stdin and stdout. You can find the controller [here](link to controller).

Your bot must implement this interface:

package ants;
import controller.*;
public abstract class Player {
    public abstract String getName(); //Your bot's name.
    public abstract Action moveAnt(Ant ant, Cell[] surroundings, String memory);  //Applied to each of your ants.
}

Your bot may not save state between each invocation of moveAnt. If it does, the bot will be disqualified. To create an action you can call one of the following functions:

Action.move(String newMemory, int destCell);
Action.attack(String newMemory, int destCell);
Action.createWorker(String newMemory, int destCell, String workerMem);
Action.dropPheromone(String newMemory, int destCell, int pheromone);   //pheromone will be truncated to 24 bits.
Action.doNothing(String newMemory);

surroundings is a 1-D array of Cells representing the surrounding 3 by 3 area. The cells in each index of the array are given in the following configuration:

0 1 2
3 4 5
6 7 8

When you specify a destination cell for your action, you must also use the same configuration.

Every Cell object has the following functions that can return properties of the cell:

public int getColor();
public List<Ant> getAnts(); //Returns list of ants on current cell.
public int getFood();       //Returns the amount of food on the current cell.

Every ant has the following properties:

public String getOwner();   //Returns your name if you are the owner ... otherwise someone elses.
public boolean isQueen();
public int getFood();       //How much food this ant is carrying.

Each time the moveAnt function is called, it should return within 5[4] milliseconds. Since the time limit may be exceeded due to fluctuations outside the ant function's control, an average will be calculated. If at any point the average is above 5[4] milliseconds and the total time taken by that particular ant function across all calls so far is more than 10 seconds, the relevant player will be disqualified. This means they will not be eligible to win and their ant function will not be called again during that game.

  1. Should I make the board smaller or bigger than this? This gives each player an average of 1000 cells. Is this too much ... or too small?
  2. Is this too much food? This much food would be enough for each player to create an average of 1000 ants. Is this too many ants?
  3. Should ants stay in the same orientation throughout the game or:
    • Should they change to a random orientation every turn?
    • Change orientation so that the direction they last moved is now forward?
    • Same as last but randomly rotate it 45 degrees clockwise or counterclockwise.
    • Same as last but 90 degrees instead of 45 degrees.
  4. Should I make the time limit:
    • The same?
    • Shorter? If so, how much shorter?
    • Longer? If so, how much longer?
  5. How many turns should a game go before it is ended prematurely? Or should it be a time limit (for example, 5 minutes)? If so, how long should the time limit be?
  6. How can I improve this to look prettier?
  7. Any typos or formatting issues?
  8. Any other ways I can improve this challenge?

Your objective is to conquer the ants of the world ... or have the biggest army of ants. To do this, you start with a single queen. The queen can create worker ants by using food gathered by itself or other worker ants. Your worker ants can kill other ants by attacking them. You win if you have the only queen left, or if you have the biggest army of ants.

The board will be a square with wraparound borders. The length of each edge is determined by sqrt(1000*n)1. Before the game fierce battle for domination starts, 100*n pieces of food will be distributed semi-randomly on the board . n queens, 1 for each player, will also be randomly distributed on the board.

1: n is the number of starting players

Sight and Smell

Ants are usually near-sighted and have somewhat short antenna. Because of this, ants in this simulation can only see and smell ants, food, and pheromone in its 3 by 3 neighborhood. They can also tell the difference between ants of different species.

Because of limited brain space, every ant has a memory of up to 5 characters long. The starting memory for queens is 5 spaces.

Every ant is oriented in the direction that it last moved. Queens start out oriented in a random direction.

Each worker ants can carry up to 1 unit of food. A queen ant can carry an unlimited amount (so that's what her body is for). Every ant picks up as much food on its current square as possible. A queen ant takes all the food from adjacent squares including that carried by workers of any player.

Every turn, every ant is given a view of the local surroundings and then decides to move. Ants are given priority in their movement with those that are oldest moving first. The initial order for the starting queens is random.

An ant attacks by attempting to move onto another ant. Worker ants require two ants attacking them in order to be killed. Queen ants require eight ants attacking it in order to be killed. Queen ants cannot attack. An ant after being killed drops all food it is carrying and one additional unit of food.

An ant can move to any of the 8 surrounding squares. This changes the orientation of the ant to the direction it is moving. If it tries to move to a square with an ant already on it, it is assumed to be attacking that ant, no matter if friendly or not.

An ant can optionally increase the value of 4 different pheromones on the cell it is on, 1 of which can only be seen by ants of that particular colony. Pheromone has a value of a double-precision float and decreases by 1% every game tick. An ant can increase pheromone by up to 10.

A queen ant may create a worker and spawn it in any of the surrounding cells. The queen ant also chooses the memory of the new worker.

You can implement a program or a java class that takes in an ant input and gives an ant output for that ant.

Input:

Input contains your player id, your ant's memory, if your ant is a queen, and then the contents of the cells surrounding it. The cells are given from the top left to the top right in this order:

0 | 1 | 2
3 | 4 | 5
6 | 7 | 8

Input is format thus:

player_id;ant_memory;is_queen;cell_0_info;cell_1_info...

Cell info is formated like this:

pheromone_0,pheromone_1,pheromone_2,pheromone_3,ant_type,ant_owner

player_id and ant_owner are positive integers.
ant_memory is a 5-character long string.
is_queen is one of true or false.
The pheromones are double-precision (64-bit) floats.
ant_type is one of W (for worker ants) and Q (for queen ants).
If there is no ant on a cell, ant_type and ant_owner will be omitted from the input.

Output:

You have to output the cell you want to move to, the pheromone you wish to add to your current cell, and whether the ant would like to create an ant instead of moving (only works for queens :P).

It should be formatted thus: next_memory;cell;pheromone_0;pheromone_1;pheromone_2;pheromone_3;create_ant;created_ants_memory

The controller is rather flexible and should be able to understand what you write if you use different delimiters or leave out some of the information. Make sure that next_memory comes first in your programs output and that it is exactly 5 characters long. If creating an ant, created_ants_memory needs to be the last 5 characters in the input.

cell has to be an integer in the range [0, 8] (defaults to 4).
pheromone_n has to be a positive float (defaults to 0).
create_ant needs to be one of: true, false, yes, no, 1, or 0 (defaults to false).

How to create a bot:

You have 3 options for this. You can:

  1. Implement the Ant interface with a java class. (Very fast)
  2. Communicate to the controller via I/O streams. (Fast (I think))
  3. Be called via command arguments and output via STDOUT (Slow depending on OS and programming language)

Note: Your bot must be completely deterministic. Given the same input, your bot should always return the same output.

Method 1:

Ant interface:

interface Ant {
    String move(String input);
}

Implement this interface for your ants :)

Method 2:

Every time it is one of your ants' turns, your program will receive a line of input through STDIN followed by a newline. After receiving the input, your program is expected to output a line through STDOUT followed by a newline.

Method 3:

Your program will be executed with the input line as its first argument. Your program is expected to output through STDOUT.

Each time your program is called, it should return within 5 milliseconds. Since the time limit may be exceeded due to fluctuations outside your control, an average will be calculated. If at any point the average is above 5 milliseconds and the total time taken by your program across all calls so far is more than 10 seconds, the relevant player will be disqualified. This means they will not be eligible to win, their ant function will not be called again during that game, and all ants of that player will instantaneously perish.

  1. How can I improve this to look prettier?
  2. Any typos or formatting issues?
  3. Any other ways I can improve this challenge?
added 137 characters in body
Source Link
TheNumberOne
  • 11.6k
  • 11
  • 9
Loading
added 285 characters in body
Source Link
TheNumberOne
  • 11.6k
  • 11
  • 9
Loading
added 11 characters in body
Source Link
TheNumberOne
  • 11.6k
  • 11
  • 9
Loading
Source Link
TheNumberOne
  • 11.6k
  • 11
  • 9
Loading