from k1lib.imports import *
Experiments on cart pole environment.
range(0, 360, 10) | shape()
(36,)
def gen():
for i in range(10):
yield
gen() | deref()
[None, None, None, None, None, None, None, None, None, None]
f"{3:04}"
'0003'
import gym
env = gym.make('CartPole-v1')
import gym
env = gym.make("CartPole-v1")
observation, info = env.reset(seed=42)
for _ in range(1000):
action = env.action_space.sample()
observation, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
observation, info = env.reset()
env.close()
observation
array([ 0.01650463, -0.3214381 , -0.0796994 , -0.08315308], dtype=float32)
!pip install gym
Collecting gym Downloading gym-0.26.2.tar.gz (721 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 721.7/721.7 kB 4.7 MB/s eta 0:00:00[31m5.1 MB/s eta 0:00:01 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: numpy>=1.18.0 in /home/kelvin/anaconda3/envs/torch/lib/python3.8/site-packages (from gym) (1.21.2) Collecting gym-notices>=0.0.4 Downloading gym_notices-0.0.8-py3-none-any.whl (3.0 kB) Requirement already satisfied: importlib-metadata>=4.8.0 in /home/kelvin/anaconda3/envs/torch/lib/python3.8/site-packages (from gym) (4.11.4) Requirement already satisfied: cloudpickle>=1.2.0 in /home/kelvin/anaconda3/envs/torch/lib/python3.8/site-packages (from gym) (2.2.0) Requirement already satisfied: zipp>=0.5 in /home/kelvin/anaconda3/envs/torch/lib/python3.8/site-packages (from importlib-metadata>=4.8.0->gym) (3.9.0) Building wheels for collected packages: gym Building wheel for gym (pyproject.toml) ... done Created wheel for gym: filename=gym-0.26.2-py3-none-any.whl size=827632 sha256=765abb335488c70477377767dfe972229c80c801d859bcb937425058faf61005 Stored in directory: /home/kelvin/.cache/pip/wheels/37/37/10/969be0b4bdeedbba8ecab056f1cbbf3a959cd7dffd435c9a39 Successfully built gym Installing collected packages: gym-notices, gym Successfully installed gym-0.26.2 gym-notices-0.0.8