forked from Alfredvc/paac
-
Notifications
You must be signed in to change notification settings - Fork 7
/
environment_creator.py
30 lines (26 loc) · 1.19 KB
/
environment_creator.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
GYM_GAMES = ["FlappyBird-v0", "CartPole-v0", "MountainCar-v0", "Catcher-v0",
"MonsterKong-v0", "RaycastMaze-v0", "Snake-v0"]
class EnvironmentCreator(object):
def __init__(self, args):
"""
Creates an object from which new environments can be created
:param args:
"""
if args.game.lower() == 'tetris' :
from tetris_emulator import TetrisEmulator
self.num_actions = 5
self.create_environment = lambda i: TetrisEmulator(i, args)
elif args.game in GYM_GAMES :
from gym_emulator import GymEmulator
import gym
self.create_environment = lambda i: GymEmulator(i, args)
env_test = gym.make(args.game)
self.num_actions = env_test.action_space.n
else :
from atari_emulator import AtariEmulator
from ale_python_interface import ALEInterface
filename = args.rom_path + "/" + args.game + ".bin"
ale_int = ALEInterface()
ale_int.loadROM(str.encode(filename))
self.num_actions = len(ale_int.getMinimalActionSet())
self.create_environment = lambda i: AtariEmulator(i, args)