-
Notifications
You must be signed in to change notification settings - Fork 71
Workers
The game worker is subordinated to the game. The worker has two components: initialization and the service.
The initialization of the worker has the responsibility of getting the user code and a set of options that the avatar uses at initialization. When the user updates the code in the code editor, the code gets saved in the database.
Updating the code of an user is done with the help of the database through the game API. The game API resource for getting the code and for posting new code is shared: when a GET is made, we receive the avatar code, a POST is made, we update the avatar code.
The code and options are saved inside a directory. The directory is built when the initilization.py
file is exected. The LocalWorkerManager(from Game) does not call the initialization.py function, updating the files by hand, then running the service.py. The KubernetesWorkerManager(from Game) run both functions by running the shell file run.py
.
The code is retrieved from
After the avatar code has been imported from the database, via the game API during initialization.
Each worker listens to POST requests for processing a turn. The data that the worker receives has the form of a world map and an avatar state. The simulation is different for the worker from the simulation of the game.
For example, the world map object has a much smaller responsibility then game's version. The idea behind this is that the worker has to handle only a state of the world at a time and decide an action for its avatar.