saber shall be reborn as phoenix this year :wink:.
Games are configured by a single JSON file and are run inside the environment of an arena
. Here's a description of what is to be contained in each directory:
├──api
│ └── The APIs, one in each folder.
├──errorlogs
│ └── Unique error logs for each game (DB stores filename alone)
├──debuglogs
│ └── Unique debug logs for each game (DB stores filename alone)
├──replays
│ └── Unique replays for each game (DB stores filename alone)
├──maps
│ └── The maps
├──bots
│ └── The bots submitted by users. They implement `__main__.py`
├──sample_bots
│ └── The bots created by us. They implement `__main__.py`
└──arena
└── temp folder(s)
Create the following directories (write a shell script for this?)
mkdir -p out/errorlogs
mkdir out/debuglogs
mkdir out/movelogs
mkdir out/replays
Move the Bot APIs to /api
. So this is how your /api
dir should look:
api
├── python2
│ └── src
│ ├── botapi.py
│ └── __init__.py
└── python3
└── src
├── botapi.py
└── __init__.py
You can see that this folder lacks __main__.py
.
Copy the __main__.py
of the bots into /bots
bots
├── py2_bot.py
└── py3_bot.py
Create atleast 1 arena
folder, this is where bot codes are copied, and logs are generated. gameloop.commit
moves them to the /out
folders.
mkdir arena_a
NEW
Add a game_config.json
to the root dir. Here's an example,
<PHOENIX>
stands for absolute path-to-phoenix
{
"bots": [
["kevin", ["/usr/bin/python2", "python2", "<PHOENIX>/bots/py2_bot.py"]],
["joker", ["/usr/bin/python3", "python3", "<PHOENIX>/bots/py3_bot.py"]]
],
"map": "<PHOENIX>/maps/fakemap.json",
"arena" : "<PHOENIX>/arena",
"filenames" : {
"error" : "elog.json",
"debug" : "dlog.json",
"replay" : "replay.json",
"move" : "moves.json"
},
"commit_paths" : {
"error" : "<PHOENIX>/out/errorlogs",
"debug" : "<PHOENIX>/out/debuglogs",
"replay" : "<PHOENIX>/out/replays",
"move" : "<PHOENIX>/out/movelogs"
},
"max_iters" : 1000,
"timeout" : 2,
"api_dir" : "<PHOENIX>/api"
}
Run python2 src
OLD
bots_config.json
and map_config.json
appropriatelymove_left()
or split_two()
.Game <---> Engine <-.
|
+--> Bot
|
+--> Bot
|
.
.
Hence we require 2 APIs
terra
) is the backbone of our operation.
Game
gets inputs, transforms its "state", and returns it to the Engine
.Engine
can query status, scores, etc from Game
.sky
)
So,
Game
details by sky
.Engine
uses sky
to control Bot process and its function and also to handover Game
state, score and logs to them.Engine
uses terra
to send Bot moves and Bot
status to Game
.Game
uses terra
to return latest game-state, scores and logs to Engine
which are forwarded).Whatever be the Game, we can start work on the APIs and the Engine. We already know what the responsibilities of the Engine are.
bots_config.json
as JSON objects. They must be directly usable by system calls such as exec*We can protect our system by running bot process in chroot
jails or containers
(LXD, LXC or Docker) which help in minimising damages when scripts attempt privilege escalation or arbit code injection.
How do we make sure processes cannot open any kind of file descriptors
? Be it for IPC or network sockets?