-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
102 lines (88 loc) · 2.84 KB
/
game.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'''
Luc Kadletz 7/19/2019
'''
# Standard Libraries
# Third Party Imports
# Local Imports
import enviroment
class Game:
def __init__(self,
name: str,
states: [str],
obs_size: [int, int],
actions: [[bool]],
loss_fn: callable):
self.name = name
self.states = states
self.obs_size = obs_size
self.actions = actions
self.loss_fn = loss_fn
def sonic_loss(info):
return info["screen_x_end"] - info["x"] - (info["novelty"] * 100)
sonic = Game(
name='SonicTheHedgehog-Genesis',
states=[
'GreenHillZone.Act1'
],
obs_size=[224, 320],
actions=[
# [ B, A, MODE, START, UP, DOWN, LEFT, RIGHT, C, Y, X, Z ]
# RIGHT
[False, False, False, False, False, False,
False, True, False, False, False, False],
# LEFT
[False, False, False, False, False, False,
True, False, False, False, False, False],
# DOWN + LEFT
[False, False, False, False, False, True,
True, False, False, False, False, False],
# DOWN + RIGHT
[False, False, False, False, False, True,
False, True, False, False, False, False],
# DOWN
[False, False, False, False, False, True,
False, False, False, False, False, False],
# JUMP + DOWN
[True, False, False, False, False, True,
False, False, False, False, False, False],
# JUMP
[True, False, False, False, False, False,
False, False, False, False, False, False],
# NOTHING
[False, False, False, False, False, False,
False, False, False, False, False, False]
],
loss_fn=sonic_loss
)
def pokemon_loss(info):
step_penalty = info["idle_count"]
agent_total_hp = (info["poke1HP"] + info["poke2HP"] + info["poke3HP"] +
info["poke4HP"] + info["poke5HP"] + info["poke6HP"]) * 10
enemy_total_hp = info["enemy1HP"] * 100
novelty = -info["novelty"] * 500
return (novelty) + step_penalty + enemy_total_hp - agent_total_hp
pokemon = Game(
name='PokemonRed-GameBoy',
states=[
'bulbasaur_vs_charmander'
],
obs_size=[144, 160],
actions=[
# [ B, A, START, SELECT, UP, DOWN, LEFT, RIGHT ]
# B
[True, False, False, False, False, False, False, False],
# A
[False, True, False, False, False, False, False, False],
# UP
[False, False, False, False, True, False, False, False],
# DOWN
[False, False, False, False, False, True, False, False],
# LEFT
[False, False, False, False, False, False, True, False],
# RIGHT
[False, False, False, False, False, False, False, True],
# NOTHING
[False, False, False, False, False, False, False, False]
],
loss_fn=pokemon_loss
)