-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
61 lines (39 loc) · 1.73 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#imports
from DMs.simple_planner import Simple_DM
from DMs.simple_planner2 import Simple_DM2
from DMs.simple_DMs import Stay_DM, Do_action_DM
import time
## Main
# from environments.env_wrapper import BattleFieldSingleEnv
from environments.env_wrapper import BattleFieldSingleEnv, CreateEnvironment, CreateEnvironment_Battle
if __name__ == '__main__':
'''
test single agent in a scenerio
'''
# env = CreateEnvironment()
env = CreateEnvironment_Battle()
agent = "blue_80"
action_space = env.action_spaces[agent]
temp_env = BattleFieldSingleEnv(env, Simple_DM2(action_space,0.5), Simple_DM(action_space,0.5,red_team=True), agent)
# temp_env = BattleFieldSingleEnv(env, Stay_DM(action_space,6), Stay_DM(action_space,6), agent)
obs = temp_env.reset()
simple_dm = Stay_DM(temp_env.action_space,12)
total_reward = 0
for i in range(5000):
a = simple_dm.get_action(obs)
obs,rew,done,_ = temp_env.step(a)
if done:
break
temp_env.render()
total_reward+=rew
print(f"action: {a}, reward: {rew}, total rew: {total_reward}")
time.sleep(0.2)
temp_env.render()
print(f" total rew: {total_reward}")
# mac_BF_env = CreateEnvironment()
# CreateCentralizedController(mac_BF_env, CreateRandomAgent(mac_BF_env))
# CreateDecentralizedController(mac_BF_env, CreateDecentralizedIdenticalAgents(mac_BF_env, RandomDecisionMaker))
# CreateDecentralizedController(mac_BF_env, CreateDecentralizedAgents(mac_BF_env, Stay_DM , Stay_DM))
# CreateDecentralizedController(mac_BF_env, CreateDecentralizedAgents(mac_BF_env, RandomDecisionMaker, RandomDecisionMaker))
# GDM = GreedyDecisionMaker(mac_BF_env)
# GDM.get_action()