You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms. This is the gym open-source library, which gives you access to a standardized set of environments.
Installation
### For gym's abstract classes for RL, install:
PM> Install-Package Gym.NET
### For implemented environments, install:
PM> Install-Package Gym.NET.Environments
PM> Install-Package Gym.NET.Rendering.Avalonia
PM> Install-Package Gym.NET.Rendering.WinForm
Example
The following example runs and renders cartpole-v1 environment.
usingNumSharp;usingSixLabors.ImageSharp;usingGym.Environments;usingGym.Environments.Envs.Classic;usingGym.Rendering.WinForm;CartPoleEnvcp=newCartPoleEnv(WinFormEnvViewer.Factory);//or AvaloniaEnvViewer.Factorybooldone=true;for(inti=0;i<100_000;i++){if(done){NDArrayobservation=cp.Reset();done=false;}else{var(observation,reward,_done,information)=cp.Step((i%2));//we switch between moving left and rightdone=_done;//do something with the reward and observation.}SixLabors.ImageSharp.Imageimg=cp.Render();//returns the image that was rendered.Thread.Sleep(15);//this is to prevent it from finishing instantly !}cp.Close();