Skip to content

Commit 401bcfe

Browse files
committed
Reinforcement Learning: Gym's Built-in & third-party environments
1 parent 82a6e63 commit 401bcfe

File tree

11 files changed

+142
-10
lines changed

11 files changed

+142
-10
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ ___
3333
___
3434

3535
### Illustrated results
36+
37+
#### Gym's Built-in & third-party environments
38+
- Lunar Lander<br>
39+
<img src="ml/rl_in_robotics/images/lunar_lander.gif" height="480"/> <br>
40+
- Mountain Car<br>
41+
<img src="ml/rl_in_robotics/images/mountain_car.gif" height="480"/> <br>
42+
- Phoenix<br>
43+
<img src="ml/rl_in_robotics/images/phoenix.gif" height="480"/> <br>
44+
3645
#### How reinforcement learning helps a robot balance a pole
3746
- Random movements cannot keep the balance for a long time<br>
3847
<img src="ml/rl_in_robotics/images/cart-pole-rl.gif" height="480"/> <br>

ml/rl_in_robotics/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Packages Installation for Python 3.8+
2+
3+
- pip install gym==0.19.0
4+
- pip install gym[atari]==0.19.0 or <br> pip install atari-py==0.2.6, then [Download ale_c.dll](https://stackoverflow.com/questions/63080326/could-not-find-module-atari-py-ale-interface-ale-c-dll-or-one-of-its-dependenc) <br>
5+
- pip install pyglet==1.5.27
6+
- pip install swig
7+
- pip install ufal.pybox2d==2.3.10

ml/rl_in_robotics/cart-pole_balancing_rl.py renamed to ml/rl_in_robotics/cart_pole/cart_pole_balancing_rl.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535
sleep(.01)
3636
if done:
3737
print(f'Episode {i} reward: {reward_sum}')
38-
sleep(.01)
39-
if done:
40-
print(f'Episode {i} reward: {reward_sum}')
41-
sleep(1)
42-
break
38+
sleep(1)
39+
break
4340

4441
env.close()

ml/rl_in_robotics/cart_pole_rl.py renamed to ml/rl_in_robotics/cart_pole/cart_pole_rl.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
sleep(.01)
3939
if done:
4040
print(f'Episode {i} reward: {reward_sum}')
41-
sleep(.01)
42-
if done:
43-
print(f'Episode {i} reward: {reward_sum}')
44-
sleep(1)
45-
break
41+
sleep(1)
42+
break
4643

4744
env.close()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Learner: Nguyen Truong Thinh
2+
# Contact me: [email protected] || +84393280504
3+
#
4+
# Topic: Reinforcement Learning (RL): RL in robotics
5+
# Gym environments: Lunar Lander Reinforcement Learning
6+
# The agent's goal is to land the lander between yellow flags.
7+
8+
from ml.rl_in_robotics.utility import gym_rl_tasks, init_environment
9+
10+
# Hyperparameters we can adjust
11+
EPISODES = 10
12+
13+
env = init_environment("LunarLander-v2")
14+
15+
random_action = env.action_space.sample()
16+
17+
gym_rl_tasks(env, EPISODES, random_action)
18+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Learner: Nguyen Truong Thinh
2+
# Contact me: [email protected] || +84393280504
3+
#
4+
# Topic: Reinforcement Learning (RL): RL in robotics
5+
# Gym environments: Phoenix Reinforcement Learning
6+
# This environment is one of the legendary Atari video game series.
7+
# In this game, you have to maximize your score.
8+
9+
from ml.rl_in_robotics.utility import gym_rl_tasks, init_environment
10+
11+
# Hyperparameters we can adjust
12+
EPISODES = 10
13+
14+
env = init_environment("Phoenix-v0")
15+
16+
random_action = env.action_space.sample()
17+
18+
gym_rl_tasks(env, EPISODES, random_action)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Learner: Nguyen Truong Thinh
2+
# Contact me: [email protected] || +84393280504
3+
#
4+
# Topic: Reinforcement Learning (RL): RL in robotics
5+
# Gym environments: Mountain Car Reinforcement Learning
6+
# A car is positioned between two mountains.
7+
# The goal is to reach the mountain on the right.
8+
9+
from ml.rl_in_robotics.utility import gym_rl_tasks, init_environment
10+
11+
# Hyperparameters we can adjust
12+
EPISODES = 30
13+
14+
env = init_environment("MountainCar-v0")
15+
16+
random_action = env.action_space.sample()
17+
18+
gym_rl_tasks(env, EPISODES, random_action)
6.78 MB
Loading
2.65 MB
Loading

ml/rl_in_robotics/images/phoenix.gif

8.66 MB
Loading

0 commit comments

Comments
 (0)