# Packages
# README
Robot Game - Legendary Ultimate Arena
Disclaimer
The project is currently Work In Progress, some security features aren't implemented yet.
It is not safe to run untrusted scripts that you don't understand.
description
The rebirth of robotgame but in lua instead of python.
Requirement
You need golang 1.21.4 and lua 5.3.
Getting started
Build
You need to build the first time you clone the repository and everytime you pull some changes.
To build you can simply run make build (or make full-build to recompile C files).
Or you can manually run the same commands individually
Run
Once the scripts are built, you can run matches locally.
First you need to run an instance of player for each of the two robots, and one instance of referee. In three different tabs run respectively:
# Lauch blue player
./player.exe -blue
# Launch red player
./player.exe
# Launch referee
./referee.exe
To run locally a match between PATH/TO/LUA/BOT1 and PATH/TO/LUA/BOT2 you can then open a new terminal and use the following command: ./matchmaker.exe PATH/TO/LUA/BOT1 PATH/TO/LUA/BOT2.
exemple
./matchmaker.exe bots/random.lua bots/random.lua
Checkout the Documentation section to learn how to create your own robot.
Project currently Work In Progress. Stay tuned.
Documentation
Create a robot
To create a bot you just need to create a lua script with a function act(self, game) that returns an object with :
- an
actionTypeproperty with a value among[MOVE, ATTACK, GUARD, SUICIDE] xandyproperties if theactionTypeproperty is set to[MOVE, ATTACK]
Example: {actionType=ATTACK, x=8, y=9} is a valid return value.
Here is an example of a very simple bot :
function act(self, game)
return {actionType=GUARD}
end
Accessing the robot's info
A robot's own info is accessible through the self argument. The default properties exposed are :
robot_id: The unique id of the robot.player_id: An id shared by all the robots of a team.hp: The number of Health Points of the robot.location: The location of the robot as a Location with the propertiesxandycorresponding to its x and y coordinates. Note: a Location can be directly compared to another Location, for exampleself.location == rg.CENTER_POINTwill returntrueif the bot is at the center of the arena.
Accessing any robot's info
The game argument let you access robots information by Location with its property robots: game.robots[location] returns the info of the robot placed at location. If the tile at location.x, location.y is empty, nil is returned. Each robot shares the same info as self except that robot_id is not accessible for enemy robots. You can loop over game.robots with pairs:
for loc, bot in pairs(game.robots) do
-- Do something with loc and/or bot.
-- Note that you do not need loc,
-- because loc == bot.location is true
end
game also lets you access the current turn count with the property turn.
Available interfaces
an object rg is accessible by all robots, with the following functions and properties :
Loc(x, y): A function that returns a Location{ x=x, y=y }that can be directly compared to another Location. For examplerg.Loc(9, 9) == rg.Loc(9, 9)andrg.Loc(9, 9) == { x=9, y=9 }will both returntruewhen{ x=9, y=9 } == { x=9, y=9 }will returnfalse.wdist(loc1, loc2): A function that returns the walking distance (manhattan distance) between Locationsloc1andloc2.dist(loc1, loc2): A function that returns the euclidean distance between Locationsloc1andloc2.loc_type(loc): A function hat returns the type of a Location. a Location types areOBSTACLEfor tiles outside of the arena,SPAWNfor tiles where robots can spawn (border of the arena) andNORMALfor other tiles of the arena. The Location type of a tile stay the same during the game (aNORMALtile will stay of typeNORMALeven if occupied by a robot).locs_around(loc): A function that returns the list of Locations around the Locationloc. An optional list of location types to filter out can also be passed:locs_around(loc, { SPAWN, OBSTACLE })will remove from its output all tiles of typeSPAWNorOBSTACLE.toward(loc1, loc2): A function that returns the Location to move to fromloc1in order to go toloc2.CENTER_POINT = rg.Loc(9, 9): A Location corresponding to the center of the arena.GRID_SIZE = 19: The size of the grid.ARENA_RADIUS = 8: The radius of the area (The spawn tiles at the border of the arena have a distance to the center betweenARENA_RADIUS - 0.5andARENA_RADIUS + 0.5tiles).SETTINGS: an object exposing the main constants of the game :spawn_delay = 10: The delay between 2 waves of spawns.spawn_count = 5: The number of robots spawned for each team for each wave of spawns.robot_hp = 50: The maximum number of Health Points of a robot.attack_range = 1: The maximum distance to another bot for an attack to be valid.attack_damage: The min and max damage dealt by an attack :min = 8: the minimummax = 10: the maximum
suicide_damage = 15: The damage dealt by a suicide.collision_damage = 5: The damage dealt by a collision.max_turn = 100: The number of turns in a game.
Rules
Robots have 10ms to act, they have one action per turn:
MOVE: moves the robot to an adjacent tile.ATTACK: attack a tile at range.GUARD: stay in place, protect against collision damage and take half damage from attacks and suicides.SUICIDE: dies but deals damage to adjacent tiles.
There are no friendly damage (collison, attack and suicide only deal damage to enemy robots).
They are several waves in which robots spawn randomly, The team that have more robots at the end of the game wins.
custom maps
You can create your own custom map in grid.c. The map must be a square with all its edges set to OBSTACLE to avoid unexpected behaviours. If you just want to play with the size of the arena you can use generate_grid.py, otherwise you can write your own script to generate any map you want. Make sure to keep consistency betweenGRID and GRID_SIZE, and between SPAWN_LOCATIONS and SPAWN_LEN.