AntRunner.Interface - GimpArm/AntRunner GitHub Wiki
Ant
Base class for every ant, inherit from this class to create an ant.
public abstract class AntRunner.Interface.Ant
Examples
C#
public class AwesomeAnt : Ant
{
//Your code here
}
PHP
Note: The Namespace in PHP is AntRunner_Interface because Interface is a keyword.
class AwesomeAnt extends \AntRunner_Interface\Ant {
//Your code here
}
JavaScript
Note: Due to the structure of Node modules, everything is in the AntRunner namespace and Interface does not exist.
module.exports.default = (function () {
var YourAnt = function() {
//Your code here
};
return YourAnt;
}());
Python
class AwesomeAnt(AntRunner.Interface.Ant):
#Your code here
Ruby
class AwesomeAnt < AntRunner::Interface::Ant
#Your code here
end
TypeScript
Note: Due to the structure of Node modules, everything is in the AntRunner namespace and Interface does not exist.
export default class ExampleAnt extends AntRunner.Ant {
//Your code here
}
Fields
| Name | Type Summary | |
|---|---|---|
| Action | AntAction |
Action which will be performed for the end of the current tick cycle. Will be set to Wait after being read. |
Properties
Note: When not using a .NET assembly, the flag will be read from the Flag.png file in the same folder as the loaded script.
| Name | Type | Summary | Example |
|---|---|---|---|
| Flag | Stream |
Overridable Stream to return binary data for use by BitmapFrame.Create() of the ant's Flag. | public override Stream Flag => typeof(Ant).Assembly.GetManifestResourceStream("AwesomeAnt.Flag.png"); |
| FlagResource | String |
Overridable string to return the name of an embedded resource for use the ant's Flag. Ignored if Flag is overridden. | public override string FlagResource => "AwesomeAnt.Flag.png"; |
| Name | String |
Readonly property for the name of the ant. | public override string Name => "Awesome Ant"; |
Methods
| Name | Return Type | Summary |
|---|---|---|
Initialize(Int32 mapWidth, Int32 mapHeight, ItemColor antColor, Int32 startX, Int32 startY) |
void |
Initialize method called once before the start of each game. |
Tick(GameState state) |
void |
Method called to begin processing for each turn. |
Initialize Example
C#
public override void Initialize(int mapWidth, int mapHeight, ItemColor antColor, int startX, int startY)
{
_mapWidth = mapWidth;
_mapHeight = mapHeight;
_myColor = antColor;
_currentX = startX;
_currentY = startY;
}
JavaScript
YourAnt.prototype.Initialize = function(mapWidth, mapHeight, color, startX, startY) {
this.MapWidth = mapWidth;
this.MapHeight = mapHeight;
this.MyColor = color;
this.CurrentX = startX;
this.CurrentY = startY;
};
PHP
public function Initialize($mapWidth, $mapHeight, $antColor, $startX, $startY) {
$this->MapWidth = $mapWidth;
$this->MapHeight = $mapHeight;
$this->MyColor = $antColor;
$this->CurrentX = $startX;
$this->CurrentY = $startY;
}
Python
def Initialize(self, mapWidth, mapHeight, color, startX, startY):
self.MapWidth = mapWidth
self.MapHeight = mapHeight
self.MyColor = color
self.CurrentX = startX
self.CurrentY = startY
Ruby
def Initialize(mapWidth, mapHeight, color, startX, startY)
@MapWidth = mapWidth
@MapHeight = mapHeight
@MyColor = color
@CurrentX = startX
@CurrentY = startY
end
TypeScript
public Initialize(mapWidth: number, mapHeight: number, color: ItemColor, startX: number, startY: number) {
this.mapWidth = mapWidth;
this.mapHeight = mapHeight;
this.myColor = color;
this.currentX = startX;
this.currentY = startY;
}
Tick Example
C#
public override void Tick(GameState state)
{
//Do Stuff
Action = AntAction.MoveRight;
}
JavaScript
YourAnt.prototype.Tick = function(state) {
//Do Stuff
this.Action = AntAction.Wait;
};
PHP
public function Tick(GameState $state) {
//Do Stuff
$this->Action = AntAction::Wait;
}
Python
def Tick(self, state):
#Do Stuff
self.Action = AntAction.Wait
Ruby
def Tick(state)
#Do Stuff
@Action = AntAction::Wait
end
TypeScript
public Tick(state: GameState) {
//Do Stuff
this.Action = AntAction.Wait;
}
AntAction
Enum of available actions an ant can make per tick.
public enum AntRunner.Interface.AntAction
: Enum, IComparable, IFormattable, IConvertible
Enum
| Name | Value | Summary |
|---|---|---|
| Wait | 0 |
Ant does nothing. |
| MoveRight | 1 |
Ant attempts to move one space to the right. |
| MoveDown | 2 |
Ant attempts to move one space below. |
| MoveLeft | 3 |
Ant attempts to move one space to the left. |
| MoveUp | 4 |
Ant attempts to move one space above. |
| EchoRight | 5 |
Ant performs an echo to the right. The response will come in the GameState of the next Tick() call. See AntRunner.Interface.EchoResponse |
| EchoDown | 6 |
Ant performs an echo below. The response will come in the GameState of the next Tick() call. See AntRunner.Interface.EchoResponse |
| EchoLeft | 7 |
Ant performs an echo to the left. The response will come in the GameState of the next Tick() call. See AntRunner.Interface.EchoResponse |
| EchoUp | 8 |
Ant performs an echo above. The response will come in the GameState of the next Tick() call. See AntRunner.Interface.EchoResponse |
| ShieldOn | 9 |
Ant turns on its shield if it has any. For every 4 ticks the shield is on, it will lose 1 point. |
| ShieldOff | 10 |
Ant turns off its shield. |
| DropBomb | 11 |
Ant drops a bomb at the current position if it has any. |
| ShootRight | 12 |
Ant shoot its laser in a straight line to the right. |
| ShootDown | 13 |
Ant shoot its laser in a straight line below. |
| ShootLeft | 14 |
Ant shoot its laser in a straight line to the left. |
| ShootUp | 15 |
Ant shoot its laser in a straight line above. |
DamageValues
Static class of constant values used when assigning damage to an ant.
public static class AntRunner.Interface.DamageValues
Static Fields
| Name | Value | Summary |
|---|---|---|
| Bomb | 30 |
Damage applied when an ant steps on a bomb. |
| Collision | 5 |
Damage applied when an ant runs into an object. |
| Impact | 10 |
Damage applied when an ant is run into or rammed by another ant. |
| Shot | 20 |
Damage applied when an ant is shot with a laser. |
EchoResponse
Response item when an Echo action is made.
public class AntRunner.Interface.EchoResponse
Properties
| Name | Type | Summary |
|---|---|---|
| Distance | Int32 |
How many squares away is the item. |
| Item | Item |
What item is there. Map edges always return Item.SteelWall. |
GameEvent
Enum flags of possible events that can occur as a result of all ants' GameAction. Multiple events may occur at once.
public enum AntRunner.Interface.GameEvent
: Enum, IComparable, IFormattable, IConvertible
Enum
| Name | Value | Summary |
|---|---|---|
| Nothing | 0 |
Nothing has occurred. |
| CollisionDamage | 1 |
Ant ran into an object when it attempted to move and incurred damage. The move was unsuccessful and the ant remains at its current location. See AntRunner.Interface.DamageValues.Collision |
| ImpactDamageRight | 2 |
Another ant ran into or rammed the ant from the right and incurred damage. See AntRunner.Interface.DamageValues.Impact |
| ImpactDamageDown | 4 |
Another ant ran into or rammed the ant from below and incurred damage. See AntRunner.Interface.DamageValues.Impact |
| ImpactDamageLeft | 8 |
Another ant ran into or rammed the ant from the left and incurred damage. See AntRunner.Interface.DamageValues.Impact |
| ImpactDamageUp | 16 |
Another ant ran into or rammed the ant from above and incurred damage. See AntRunner.Interface.DamageValues.Impact |
| ShotDamageRight | 32 |
Ant was shot by a laser and incurred damage from the right. See AntRunner.Interface.DamageValues.Shot |
| ShotDamageDown | 64 |
Ant was shot by a laser and incurred damage from below. See AntRunner.Interface.DamageValues.Shot |
| ShotDamageLeft | 128 |
Ant was shot by a laser and incurred damage from the left. See AntRunner.Interface.DamageValues.Shot |
| ShotDamageUp | 256 |
Ant was shot by a laser and incurred damage from above. See AntRunner.Interface.DamageValues.Shot |
| BombDamage | 512 |
Ant walked over a bomb and incurred damage. See AntRunner.Interface.DamageValues.Bomb |
| PickUpBomb | 1024 |
Ant picked up a Bomb Power-up. See AntRunner.Interface.ItemBonusValues.Bomb |
| PickUpShield | 2048 |
Ant picked up a Shield Power-up. See AntRunner.Interface.ItemBonusValues.Shield |
| PickUpHealth | 4096 |
Ant picked up a Health Power-up. See AntRunner.Interface.ItemBonusValues.Health |
| PickUpFlag | 8192 |
Ant picked up the Flag. Run to the correct color home! When you pick up the flag then all other ants know exactly where you are. |
| Dead | 16384 |
Ant has died and will no longer be getting Tick() calls. |
| GameOver | 32768 |
The game is over, either an ant successfully retrieved the flag or all ants have died. |
GameState
public struct AntRunner.Interface.GameState
Properties
| Name | Type | Summary |
|---|---|---|
| AntWithFlag | ItemColor |
If an ant has the flag, this is the color of that ant. If no ants have the flag then this value is ItemColor.None. |
| Event | GameEvent |
Flag enum of which events occurred due to the previous Tick GameAction. |
| FlagX | Int32 |
If an ant has the flag, this is their current X position on the map. If no ants have the flag then this value is -1. |
| FlagY | Int32 |
If an ant has the flag, this is their current Y position on the map. If no ants have the flag then this value is -1. |
| HasFlag | Boolean |
Boolean value if an ant has the flag. You should try to prevent this ant from reaching its home. |
| Response | EchoResponse |
Echo response of the previous Tick GameAction. If previous Tick was not an echo action then this is null. See AntRunner.Interface.AntAction.EchoRight AntRunner.Interface.AntAction.EchoLeft AntRunner.Interface.AntAction.EchoUp AntRunner.Interface.AntAction.EchoDown |
| TickNumber | Int64 |
Long value of the tick turn, starts with 0 and each Tick() call is increased by 1. See AntRunner.Interface.Ant.Tick(AntRunner.Interface.GameState) |
Item
Enum of possible items on a map position.
public enum AntRunner.Interface.Item
: Enum, IComparable, IFormattable, IConvertible
Enum
| Name | Value | Summary |
|---|---|---|
| Empty | 0 |
Nothing at all, aka empty. |
| SteelWall | 1 |
Unbreakable steel wall. |
| BrickWall | 2 |
Brick wall which may be destroyed with a laser shot. There is a 25% chance a power-up will come from shooting this. |
| Bomb | 3 |
Bomb that will damage the ant if stepped on. Can be shot with the laser to destroy. See AntRunner.Interface.DamageValues.Bomb |
| PowerUpBomb | 4 |
Bomb Power-up, adds bombs to the ant's inventory. See AntRunner.Interface.ItemBonusValues.Bomb |
| PowerUpHealth | 5 |
Health Power-up, adds more health level to the ant, maximum 100. See AntRunner.Interface.ItemBonusValues.Health |
| PowerUpShield | 6 |
Shield Power-up, adds more shield level to the ant, maximum 100. See AntRunner.Interface.ItemBonusValues.Shield |
| RedAnt | 7 |
The red ant. |
| BlueAnt | 8 |
The blue ant. |
| GreenAnt | 9 |
The green ant. |
| OrangeAnt | 10 |
The orange ant. |
| PinkAnt | 11 |
The pink ant. |
| YellowAnt | 12 |
The yellow ant. |
| GrayAnt | 13 |
The gray ant. |
| WhiteAnt | 14 |
The white ant. |
| RedHome | 15 |
The home for the red ant. |
| BlueHome | 16 |
The home for the blue ant. |
| GreenHome | 17 |
The home for the green ant. |
| OrangeHome | 18 |
The home for the orange ant. |
| PinkHome | 19 |
The home for the pink ant. |
| YellowHome | 20 |
The home for the yellow ant. |
| GrayHome | 21 |
The home for the gray ant. |
| WhiteHome | 22 |
The home for the white ant. |
| Flag | 23 |
The flag, pick this up and bring it to the correct color home. |
ItemBonusValues
Static class of constant values used when assigning power-ups to an ant.
public static class AntRunner.Interface.ItemBonusValues
Static Fields
| Name | Value | Summary |
|---|---|---|
| Bomb | 4 |
Amount of bombs added to an ant's inventory when a bomb power-up is acquired. See AntRunner.Interface.Item.PowerUpBomb |
| Health | 25 |
Amount of health that is restored when a health power-up is acquired. See AntRunner.Interface.Item.PowerUpHealth |
| Shield | 25 |
Amount of shield that is restored when a shield power-up is acquired. See AntRunner.Interface.Item.PowerUpShield |
ItemColor
Enum of the available ant and home colors.
public enum AntRunner.Interface.ItemColor
: Enum, IComparable, IFormattable, IConvertible
Enum
| Name | Value | Summary |
|---|---|---|
| None | 0 |
No color at all. Note: in Python this is None_ due to None being a keyword |
| Red | 1 |
Color for the RedAnt and RedHome |
| Blue | 2 |
Color for the BlueAnt and BlueHome |
| Green | 3 |
Color for the GreenAnt and GreenHome |
| Orange | 4 |
Color for the OrangeAnt and OrangeHome |
| Pink | 5 |
Color for the PinkAnt and PinkHome |
| Yellow | 6 |
Color for the YellowAnt and YellowHome |
| Gray | 7 |
Color for the GrayAnt and GrayHome |
| White | 8 |
Color for the WhiteAnt and WhiteHome |