Package: gymie
Gymie - ServerWebSocket server that exposes an API to train AI agents onOpenAI Gymand gym-api like environments such asGym RetroorUnity ML-Agents, this last one with the help ofgym wrapperContent of this documentInstallationHow to start the serverAPI and how to consume itList of methods exposed to the clientmakestepresetcloseobservation_spaceaction_spaceaction_sampleProgrammatic API@overridestartTesting GymieLicenceInstallationGymie can be installed using:$pipinstallgymieor by cloning therepoand pip-installing in editable mode from the folder:$gitclonehttps://github.com/jscriptcoder/Gymie-Server.git
Cloninginto'Gymie-Server'...
...

$cdGymie-Server/
$pipinstall-e.
Obtainingfile:///path/to/Gymie-Server
...
SuccessfullyinstalledgymieHow to start the serverYou can start the server from the command line:$python-mgymie--host0.0.0.0--port5000(84581)wsgistartinguponhttp://0.0.0.0:5000or programmatically:importgymiegymie.start('localhost',9000)API and how to consume itA client can communicate with Gymie via JSON, with the following format:{"method":"api_method_name","params":{"param1":"string","param2":6,"param3":true,"param4":[]}}List of methods exposed to the clientmake: Instantiates an environment.// Params:{"env_id":"CartPole-v1","seed":0// optional}// Response:{"instance_id":"unique-id"}step: Performs a step on the environment.// Params:{"instance_id":"instance-id""action":[1,0,1]// MultiBinary action}// Response:[[...],// next state-2.0,// rewardfalse,// done{...},// info]reset: Resets the environment.// Params:{"instance_id":"instance-id"}// Response:[...]// initial stateclose: Closes the environment.// Params:{"instance_id":"instance-id"}// Response:trueobservation_space: Generates a dictionary with observation space info.// Params:{"instance_id":"instance-id"}// Response for Discreate observation space:{"name":"Discreate","n":4}// Response for Box (Continuous) observation space:{"name":"Box","shape":[3],"low":[-5,-5,-5],"high":[5,5,5]}// Response for MultiBinary observation space:{"name":"MultiBinary","n":5,"shape":[5]}// TODO MultiDiscreteaction_space: Generates a dictionary with action space info.// Params:{"instance_id":"instance-id"}// Response for Discreate actions:{"name":"Discreate","n":4}// Response for Box (Continuous) actions:{"name":"Box","shape":[2],"low":[-1,-1],"high":[1,1]}action_sample: Generates a random action.// Params:{"instance_id":"instance-id"}// Response for Discrete actions:2// Response for Continuous actions:[1.52,-3.67]Programmatic API@override: Decorator to override internal functionality. It takes a string, function's name, as an argument. This is useful if we want to use different gym-like wrappers. For example, both Gym Retro and Unity ML-Agents have different ways to instantiate an environment. You can take a look at the tests to see how it's done forGym RetroandUnity ML-Agents(with the help ofgym-unity). At the moment there are two internal functions that can be overriden,get_envandprocess_step.Signature:defoverride(func_name:str)->CallableHow to use:importretrofromgymieimportoverridefromgym_unity.envsimportUnityToGymWrapperfrommlagents_envs.environmentimportUnityEnvironment,UnityEnvironmentException@override('get_env')defretro_get_env(env_id,seed=None):"""Instantiates a Gym environment"""try:env=retro.make(game=env_id)exceptFileNotFoundError:raiseEnvironmentNotFoundelse:ifseed:env.seed(seed)returnenv@override('process_step')defunity_process_step(step):"""Does some processing of the step"""observation,reward,done,info=stepreturnobservation.tolist(),float(reward),done,{}start: This function takes two arguments, host and port, and starts the server, listening onws://host:portSignature:defstart(host:str='0.0.0.0',port:int=5000)->NoneHow to use:importgymiegymie.start('localhost',8080)Testing GymieYou can run all the tests by executingrun_tests.shscript:$./run_tests.shIn order to runtest_gymie_retro.pyyou need to havegym-retropackage installed. Fortests/test_gymie_unity.py, you needmlagents-envsandgym-unity.LicenseMIT License- Copyright (c) 2020 Francisco Ramos