-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameEmulationStyleTransf.py
59 lines (38 loc) · 1.37 KB
/
gameEmulationStyleTransf.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
import diambra.arena
from diambra.arena.utils.gym_utils import env_spaces_summary, available_games
import random
import argparse
import sys, os
basePath = os.path.join(os.path.abspath(''))
sys.path.append(os.path.join(basePath, "realTimeStyleTransferSlim/"))
from styleTransferViz import *
from stylesList import stylesList
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--gameId', type=str, default="random", help='Game ID')
opt = parser.parse_args()
print(opt)
game_dict = available_games(False)
if opt.gameId == "random":
game_id = random.sample(game_dict.keys(),1)[0]
else:
game_id = opt.gameId if opt.gameId in game_dict.keys() else random.sample(game_dict.keys(),1)[0]
stViz = styleTransferViz(stylesList)
env = diambra.arena.make(game_id, {"step_ratio": 6})
observation = env.reset()
counter = 0
styleCounter = 0
counterLimit = 100
while styleCounter < 23:
actions = env.action_space.sample()
observation, reward, done, info = env.step(actions)
gameFrame = observation["frame"]
stViz.styleGame(gameFrame, waitPress=1)
if done:
observation = env.reset()
if counter == counterLimit:
counter = 0
styleCounter += 1
stViz.nextStyle()
counter += 1
env.close()