forked from DeepRLChinese/DeepRL-Chinese
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""7.3节DQN算法实现。 | ||
"""4.3节DQN算法实现。 | ||
""" | ||
import argparse | ||
from collections import defaultdict | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""8.3节多步SARSA算法实现。 | ||
"""5.3节多步SARSA算法实现。 | ||
""" | ||
import argparse | ||
import os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""11.3节A2C算法实现。""" | ||
"""8.3节A2C算法实现。""" | ||
import argparse | ||
import os | ||
from collections import defaultdict | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""13.4节TD3算法实现。 | ||
"""10.4节TD3算法实现。 | ||
""" | ||
import argparse | ||
from collections import defaultdict | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""16.3节A3C算法实现。""" | ||
"""13.3节A3C算法实现。""" | ||
import argparse | ||
import os | ||
import gym | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""14.3节MPE环境。 | ||
安装依赖环境:pip install "pettingzoo[mpe]" | ||
""" | ||
|
||
from pettingzoo.mpe import simple_crypto_v2 | ||
import time | ||
|
||
env = simple_crypto_v2.env() | ||
|
||
num_agents = len(env.possible_agents) | ||
num_actions = env.action_space(env.possible_agents[0]).n | ||
observation_size = env.observation_space(env.possible_agents[0]).shape | ||
|
||
print(f"{num_agents} agents") | ||
for i in range(num_agents): | ||
num_actions = env.action_space(env.possible_agents[i]).n | ||
observation_size = env.observation_space(env.possible_agents[i]).shape | ||
print(i, env.possible_agents[i], "num_actions:", num_actions, "observation_size:", observation_size) | ||
|
||
|
||
env.reset() | ||
for i, agent in enumerate(env.agent_iter()): | ||
observation, reward, termination, info = env.last() | ||
action = 0 | ||
|
||
action = env.action_space(agent).sample() | ||
env.step(action) | ||
|
||
print(i, agent) | ||
print(f"action={action}, observation={observation}, reward={reward}, termination={termination}, info={info}") | ||
|
||
env.render() | ||
time.sleep(0.1) | ||
|
||
if i == 50: | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters