Building - GimpArm/AntRunner GitHub Wiki

See the Examples in the release zip file for an example of how to successfully create a basic ant.

C# netstandard2.0

Create a .Net standard 2.0 assembly, include AntRunner.Interface.dll as a reference (located in the AntRunner program folder) and create a class which inherits from AntRunner.Interface.Ant. Build your project and load the resulting DLL into AntRunner.exe.

using AntRunner.Interface;

public class MyAnt : Ant {
    public string Name => "C# Ant";
    public void Initialize(int mapWidth, int mapHeight, ItemColor color, int startX, int startY) {
        //Initialize code here
    }
    public Tick(GameState state) {
        //Game code here
    }
}

JavaScript (node)

Create a .js file and require("antrunner"); (available as an npm package) and set your ant object to modules.exports.default. Load the .js file into AntRunner.exe.

var AntRunner = require("AntRunner");
modules.exports.default = (function() {
   function ExampleAnt() {
        this.Name = "NodeJs Ant";
    }
    ExampleAnt.prototype.Initialize = function(mapWidth, mapHeight, color, startX, startY) {
        //Initialize code here
    };
    ExampleAnt.prototype.Tick = function(state) {
        //Game code here
    }
    return ExampleAnt;
}());

PHP

Create a .php file and a class that extends \AntRunner_Interface\Ant. Load the .php file into AntRunner.exe. Note that the namespace in PHP is AntRunner_Interface due to Interface being a key word in PHP.

<?php
class MyAnt extends \AntRunner_Interface\Ant {
    public $Name = "PHP Ant";
    public function Initialize($mapWidth, $mapHeight, $color, $startX, $startY) {
        //Initialize code here
    }
    public function Tick(\AntRunner_Interface\GameState $state) {
        //Game code here
    }
}

Python

Currently using Python 3.7.2

Create a .py file, import AntRunner.Interface.Ant, and create a class that inherits from AntRunner.Interface.Ant. Load the .py file into AntRunner.exe. If you want to include other local python files you need to also create a ___init___.py file.

import AntRunner.Interface.Ant

class MyAnt(AntRunner.Interface.Ant):
	Name = "Python Ant"
	def Initialize(self, mapWidth, mapHeight, color, startX, startY):
		#Initialize code here
		pass

	def Tick(self, state):
		#Game code here
		pass

Ruby

Currently using Ruby 2.6.1

Create a .rb file, include AntRunner::Interface, and create a class that inherits from AntRunner::Intreface::Ant. Load the .rb file into AntRunner.exe.

include AntRunner::Interface

class MyAnt < AntRunner::Interface::Ant
	def Name
		"Ruby Ant"
	end

	def Initialize(mapWidth, mapHeight, color, startX, startY)
		#Initialize code here
	end

	def Tick(state)
		#Game code here
	end
end

TypeScript (node)

Create a .ts file and import * from "antrunner"; (available as an npm package) and export default a class that extends Ant. Compile and load the resulting .js file into AntRunner.exe.

import { GameEvent, Item, ItemColor, AntAction, EchoResponse, GameState, Ant, DamageValues, ItemBonusValues } from "antrunner";
export default class ExampleAnt extends Ant {
    public Name: string = "TypeScript Ant";
    public Initialize(mapWidth: number, mapHeight: number, color: ItemColor, startX: number, startY: number) {
        //Initialize code here
    }
    public Tick(state: GameState) {
        //Game code here
    }
}