An API driven bot battle for exploring AI development - inspired by vindinium
The purpose of the game is to create a bot that can outsmart the other players in a competition to navigate a grid of tiles and control the most gold resources for the most turns
- Each turn the players can make one move by posting their desired action to the game
- After all players have submitted their moves, the game is updated and the turn is advanced
- If two players are on the same tile, they battle and both lose 20pts of health
- If a player is on a heal tile, their health is restored by 20pts
- If a player moves onto a gold tile, it is captured and their health is decreased by 20pts
- Each player is awarded 1 point per gold tile they control at the end of the round
- If a player's health falls below 1pt they are killed, losing all captured gold tiles, and restart at the nearest heal tile
- The players continue to make moves until the turn limit is reached at which point the player with the most points wins
0 = Grass
1 = Wall
2 = Gold
3 = Heal
2 0 0 0 0 0 0 0 0 0 2
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 1 1 1 3 1 3 1 1 1 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 2
# | Action | Method | Endpoint | Payload | Response |
---|---|---|---|---|---|
1 | Log in / Create user | POST |
/api/users |
{ "username": "MyUserName" } |
User |
2 | Find / Create a game | POST |
/api/games |
{ "difficulty": [0-4] } |
Game |
3 | Join the game found | POST |
/api/games/{gameId}/players |
Player | |
4 | Wait for the game to start { "state" : 1 ... } |
GET |
/api/games/{gameId} |
Game | |
5 | Make a move | POST |
/api/games/{gameId}/moves |
{ "action" : [0-4] } |
Move |
6 | Wait for the turn to advance { "turn" : 1 ... } |
GET |
/api/games/{gameId} |
Game |
Repeat steps 5-6 until the game is over: { "state" : 2 ... }
# | State |
---|---|
0 | Waiting for players |
1 | Running |
2 | Done |
# | Action |
---|---|
0 | None |
1 | Left |
2 | Right |
3 | Up |
4 | Down |
There are starter clients available in the BotBattle-Clients Repository
- Start vagrant
vagrant up
- Create a
deploy_resources/app.cfg
based ondeploy_resources/app.cfg.example
DB_HOST=db.hostname.com # <-- The hostname of your database (will be mapped to localhost in /etc/hosts)
DB_USER=battle_admin # <-- The username to create in the DB
DB_PASS=db_password # <-- The password to use for the created user
- Create a
src/public/api/config.php
based onsrc/public/api/config.php.example
return [
Config::DB_HOST => 'db.hostname.com', // <-- The hostname of your database (same as above)
Config::DB_USER => 'battle_admin', // <-- The username to access the DB (same as above)
Config::DB_PASS => 'db_password' // <-- The password to access the DB (same as above)
];
- Run the application initialization script
cd /vagrant/deploy_resources
./app_bootstrap.sh
Note: You may need to run vagrant reload
for everything to get up to date after the initial setup
- PHP 7
- MySQL
- Composer
- Create a user in your MySQL DB to use for the application
- Load the database by running the initialization script:
/vagrant/deploy_resources/db/init.sql
- Create a
src/public/api/config.php
based onsrc/public/api/config.php.example
return [
Config::DB_HOST => 'db.hostname.com', // <-- The hostname of your database
Config::DB_USER => 'battle_admin', // <-- The username to access the DB
Config::DB_PASS => 'db_password' // <-- The password to access the DB
];
- Install the dependencies by running
composer install
in thesrc
directory