Pinball is an environment written on Godot for testing artificial agents.
RandomForce:
angles: [phi1, phi2, ...]
strength: m
reward: r
terminal: is_terminal
When ball enters ring area, RandomFroce uniformly choses a direction from angles and applies impluse of magnitude m.
Attractor:
strength: m
frequency: f
reward: r
terminal: is_terminal
When ball enters ring area, Attractor slowes down the ball and attracts to its center with frequency f.
Both entities have fields:
reward-ris amount of reward that agent gets by entering the areaterminal- ifis_terminal==true, ball resets the environment by entering the area
Ctrl+S- open or save confgiurationCtrl+R- reset ball to initial positionLeft/Right arrow- change direction of initial impulseUp/Down arrow- change magnitude of initial impulseSpace- apply initial impulse to ball
- Add new
RandomForceandAttractorobjects, position and edit them as needed in Godot editor. - Run game in debug mode, open settings (
Ctrl+S) and enter new config path, click "OK" button.
To use the environment in Python programms you can install Python module python_env/pinball.py using python_env/setup.py.
Control of the environment is through Pinball class:
obs()- returns a tuple: (image observation array, reward, terminal state flag)act([phi float, m float])- apply impulse with directionphiin radians and magnitudemstep()- do one simulation step if run with--sync=trueflagreset(position=None)- return ball to initial position and zero velocity, if position is not specified, it uses initial position from config file
For more detailed API see the source code.
To run the environment through Python you need to compile an executable file of the environment through Godot editor. The executable has several useful flags:
--config=config_pathspecify wich configuration you would like to run with--host=ip_addrand--port=portspecify ip address and port of the environment that will be used for TCP connection between Python and Godot parts.--disable-render-loopand--no-windoware useful for a headless run.--fixed-fpsbreaks real-time synchronization of physics and render, useful for headless rendering.--sync=true/falseiftrue, simulation is paused until the next frame is requested by Python environment.--seed=seedsetup seed to reproduce simulations.
Code realisation of interaction between Godot and Python parts of the environment is mostly inspired by this repository.
