-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmarioPresentation.py
433 lines (355 loc) · 63.5 KB
/
marioPresentation.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
#Amanda Israel Graeff Borges, Lucas Veit de Sá e Mateus Karvat Camara
import numpy as np
from numpy.random import default_rng
import time, copy
import pandas as pd
import random
import os
import sys
from pyboy import PyBoy, WindowEvent
import json
from torch.utils.tensorboard import SummaryWriter
emulation_speed = 5
class environment:
def __init__(self):
#start the game
filename = 'roms/Super Mario Land.gb'
quiet = "--quiet" in sys.argv
self.pyboy = PyBoy(filename, window_type="headless" if quiet else "SDL2", window_scale=3, debug=quiet, game_wrapper=True)
self.pyboy.set_emulation_speed(emulation_speed) #velocidade de emulação
assert self.pyboy.cartridge_title() == "SUPER MARIOLAN"
self.mario = self.pyboy.game_wrapper()
self.mario.start_game()
self.done= False
self.time = 10
assert self.mario.score == 0
assert self.mario.lives_left == 2
assert self.mario.time_left == 400
assert self.mario.world == (1, 1) #stage
assert self.mario.fitness == 0 # A built-in fitness score for AI development
#set state and action size
state_full = np.asarray(self.mario.game_area())
np.append(state_full,self.mario.level_progress) #talvez usar o append corretamente
self.state_size = state_full.size
def reset(self):
self.mario.reset_game() #back to the last state saved
self.done = False
self.pyboy.tick()
assert self.mario.lives_left == 2
self.position = self.mario.level_progress
state_full = np.asarray(self.mario.game_area())
np.append(state_full,self.mario.level_progress)
return state_full
def step(self,action, reduced_action):
if not reduced_action:
if action == 0: # Pular
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN)
self.pyboy.send_input(WindowEvent.PRESS_BUTTON_A)
self.time = 2
elif action == 1: # Soltar Pular
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN)
self.pyboy.send_input(WindowEvent.RELEASE_BUTTON_A)
self.time = 2
elif action == 2: # Andar para esquerda
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_RIGHT)
self.pyboy.send_input(WindowEvent.PRESS_ARROW_LEFT)
self.time = 2
elif action == 3: # Parar de andar para esquerda
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_LEFT)
self.time = 2
elif action == 4: # Andar para direita
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_LEFT)
self.pyboy.send_input(WindowEvent.PRESS_ARROW_RIGHT)
self.time = 2
elif action == 5: # Parar de andar para direita
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_RIGHT)
self.time = 2
elif action == 6: # Apertar Correr / Fogo
self.pyboy.send_input(WindowEvent.PRESS_BUTTON_B)
self.time = 2
elif action == 7: # Soltar Correr / Fogo
self.pyboy.send_input(WindowEvent.RELEASE_BUTTON_B)
self.time = 2
elif action == 8: # Apertar para Baixo
self.pyboy.send_input(WindowEvent.RELEASE_BUTTON_A)
self.pyboy.send_input(WindowEvent.PRESS_ARROW_DOWN)
self.time = 2
elif action == 9: # Soltar para Baixo
self.pyboy.send_input(WindowEvent.RELEASE_BUTTON_A)
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN)
self.time = 2
else:
if action == 0: # Pular
self.pyboy.send_input(WindowEvent.PRESS_BUTTON_A)
self.time = 2
elif action == 1: # Soltar Pular
self.pyboy.send_input(WindowEvent.RELEASE_BUTTON_A)
self.time = 2
elif action == 2: # Andar para direita
self.pyboy.send_input(WindowEvent.PRESS_ARROW_RIGHT)
self.time = 2
elif action == 3: # Parar de andar para direita
self.pyboy.send_input(WindowEvent.RELEASE_ARROW_RIGHT)
self.time = 2
return action, self.time
class Network():
def __init__(self, cromossome_size, reduced_action):
# Gera cromossomo com sequência aleatória de ações
if reduced_action:
self.actions = [0, 3, 0, 0, 3, 1, 2, 2, 0, 0, 3, 2, 1, 0, 3, 0, 0, 0, 5, 1, 7, 9, 0, 3, 3, 1, 3, 0, 3, 1, 3, 2, 1, 3, 2, 0, 2, 8, 3, 3, 1, 3, 1, 0, 0, 8, 2, 0, 0, 0, 8, 1, 2, 1, 3, 4, 0, 2, 1, 3, 2, 0, 0, 2, 1, 1, 3, 1, 2, 2, 0, 0, 2, 1, 3, 1, 0, 2, 1, 3, 7, 7, 2, 2, 3, 3, 2, 2, 3, 2, 3, 1, 0, 3, 1, 1, 3, 2, 1, 3, 6, 1, 2, 1, 1, 3, 2, 0, 3, 1, 8, 3, 2, 5, 7, 3, 1, 3, 7, 5, 1, 0, 3, 0, 3, 2, 2, 8, 0, 2, 3, 1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 0, 3, 2, 0, 2, 3, 0, 2, 1, 0, 2, 0, 8, 0, 1, 1, 3, 2, 1, 7, 1, 2, 0, 1, 3, 2, 0, 0, 2, 1, 1, 9, 5, 3, 1, 2, 0, 0, 0, 0, 3, 2, 1, 2, 0, 8, 0, 3, 0, 2, 0, 0, 1, 2, 3, 2, 0, 6, 0, 2, 2, 3, 3, 2, 5, 2, 2, 0, 0, 9, 3, 1, 9, 2, 2, 2, 8, 3, 3, 4, 2, 2, 2, 0, 2, 1, 3, 3, 1, 1, 0, 3, 0, 0, 9, 2, 7, 0, 1, 0, 4, 1, 6, 1, 1, 0, 1, 3, 1, 2, 2, 3, 9, 5, 3, 2, 1, 3, 2, 2, 1, 1, 3, 3, 0, 1, 3, 3, 4, 3, 0, 3, 2, 2, 2, 1, 2, 0, 1, 3, 7, 1, 1, 3, 1, 1, 1, 1, 1, 3, 2, 0, 0, 3, 2, 1, 1, 1, 2, 0, 1, 2, 0, 0, 3, 3, 2, 2, 0, 2]
#self.actions = [4]*100+[0]*3+[1]+[5]+[2]*15+[3]+[0]+[5]*400
self.generation = 0
self.death_iteration = 0
self.lucro = 0
def get_actions(self):
return self.actions
def set_actions(self,actions,lucro):
self.actions = actions
self.lucro = lucro
return self.lucro
def init_networks(population, cromossome_size, reduced_action):
return [Network(cromossome_size, reduced_action) for _ in range(population)]
def fitness(networks, reduced_action):
for network in networks:
#init env
env = environment()
state_size = env.state_size
fitness = env.mario.fitness
state = env.reset()
state = np.reshape(state, [1, state_size])
actions = network.get_actions()
# loop through actions
vidas = env.mario.lives_left
action_counter = 0
for act in actions:
t_act_ini = time.time()
if action_counter == len(actions)-1:
print(f"Ultima ação {action_counter}!!!")
try:
filteredMario = [x for x in list(state[0]) if (x>10 and x<30)]
index_mario = list(state[0]).index(filteredMario[0])
feet_val = state[0][index_mario + 20]
except:
pass
#print(iterator)
#break
act, tempo = env.step(act, reduced_action)
state = np.asarray(env.mario.game_area())
position = env.mario.level_progress
state = np.reshape(state, [1, state_size])
i=0
while feet_val <= 350:
env.pyboy.tick()
i += 1
if i > 60:
break
if feet_val >= 350:
tempo = 2
for _ in range(tempo):
env.pyboy.tick() # Progresses the emulator ahead by one frame.
t = 0.0167 * tempo
time.sleep(t)
fitness = env.mario.fitness
fitness = env.mario.fitness
if env.mario.lives_left < vidas:
network.death_iteration = action_counter
done = True
break
vidas = env.mario.lives_left
action_counter+=1
network.lucro = fitness
env.pyboy.stop()
return networks
def selection(networks, population, selection_percentage):
# Ordena os membros da população com base em seu lucro
networks = sorted(networks, key=lambda network: network.lucro, reverse=True)
# Seleciona os selection_percentage % melhores daquela população
networks = networks[:int(selection_percentage * population)]
return networks
def crossover(networks, self_crossover, population, selection_percentage, cromossome_size, death_mutation, reduced_action):
children = []
if death_mutation:
num_pares_filhos = int(population*((1-selection_percentage)/4))
for _ in range(num_pares_filhos):
parent1 = random.choice(networks)
parent2 = random.choice(networks)
if not self_crossover:
while parent1==parent2:
parent1 = random.choice(networks)
parent2 = random.choice(networks)
child1 = Network(cromossome_size, reduced_action)
child2 = Network(cromossome_size, reduced_action)
child3 = copy.deepcopy(parent1)
child4 = copy.deepcopy(parent2)
# Escolha aleatória do ponto de crossover
n = np.random.randint(0,cromossome_size)
# Crossover dos pais
p1_beginning = parent1.actions[:n]
p1_end = parent1.actions[n:]
p2_beginning = parent2.actions[:n]
p2_end = parent2.actions[n:]
child1.actions = p1_beginning+p2_end
child2.actions = p2_beginning+p1_end
children.append(child1)
children.append(child2)
children.append(child3)
children.append(child4)
else:
num_pares_filhos = int(population*((1-selection_percentage)/2))
for _ in range(num_pares_filhos):
parent1 = random.choice(networks)
parent2 = random.choice(networks)
if not self_crossover:
while parent1==parent2:
parent1 = random.choice(networks)
parent2 = random.choice(networks)
child1 = Network(cromossome_size, reduced_action)
child2 = Network(cromossome_size, reduced_action)
# Escolha aleatória do ponto de crossover
n = np.random.randint(0,cromossome_size)
# Crossover dos pais
p1_beginning = parent1.actions[:n]
p1_end = parent1.actions[n:]
p2_beginning = parent2.actions[:n]
p2_end = parent2.actions[n:]
child1.actions = p1_beginning+p2_end
child2.actions = p2_beginning+p1_end
children.append(child1)
children.append(child2)
networks.extend(children)
return networks
def mutate(networks, mutation_rate, mutation_probability, population, selection_percentage, cromossome_size, death_mutation):
# Mutação
num_old_members = int(population*selection_percentage)
if death_mutation:
rng = default_rng()
child1 = list(range(num_old_members,population,4))
child2 = list(range(num_old_members+1,population,4))
child1.extend(child2)
child1.sort()
child3 = list(range(num_old_members+2,population,4))
child4 = list(range(num_old_members+3,population,4))
child3.extend(child4)
child3.sort()
mutated_networks = rng.choice(child1, size=int(len(child1)*mutation_probability), replace=False).tolist()
for network_idx in mutated_networks:
num_genes_mutados = int(cromossome_size*mutation_rate)
network = networks[network_idx]
death_threshold = int(network.death_iteration*0.9)
genes_in_death_threshold = np.arange(cromossome_size)[death_threshold:]
genes_sorteados = rng.choice(genes_in_death_threshold, size=num_genes_mutados, replace=False)
for gene in genes_sorteados:
network.actions[gene] = np.random.randint(10)
mutated_networks_two = rng.choice(child3, size=int(len(child3)*mutation_probability), replace=False).tolist()
for network_idx in mutated_networks_two:
num_genes_mutados = int(cromossome_size*mutation_rate)
genes_sorteados = rng.choice(cromossome_size, size=num_genes_mutados, replace=False)
for gene in genes_sorteados:
network = networks[network_idx]
network.actions[gene] = np.random.randint(10)
else:
rng = default_rng()
indices_populacao = np.arange(population)[num_old_members:]
mutated_networks = rng.choice(indices_populacao, size=int(len(indices_populacao)*mutation_probability), replace=False).tolist()
for network_idx in mutated_networks:
num_genes_mutados = int(cromossome_size*mutation_rate)
genes_sorteados = rng.choice(cromossome_size, size=num_genes_mutados, replace=False)
for gene in genes_sorteados:
network = networks[network_idx]
network.actions[gene] = np.random.randint(10)
return networks
def run(iteration, run_name, population, generations, self_crossover, mutation_rate, mutation_probability, selection_percentage, cromossome_size, death_mutation, reduced_action):
print(f"Run {iteration}")
print("-"*10)
lucro_nets = []
best_lucro_nets = []
lucro_nets_media = []
networks = init_networks(population, cromossome_size, reduced_action)
writer = SummaryWriter(log_dir='runs/'+run_name)
t0=time.time()
for gen in range(generations):
#print (f'Generation {gen+1}')
#action
networks = fitness(networks, reduced_action)
network_lucro = []
for network in networks:
network.generation = gen
network_lucro.append(network.lucro)
lucro_nets.append(network.lucro)
#Genetic
networks = selection(networks, population, selection_percentage)
networks = crossover(networks, self_crossover, population, selection_percentage, cromossome_size, death_mutation, reduced_action)
networks = mutate(networks, mutation_rate, mutation_probability, population, selection_percentage, cromossome_size, death_mutation)
max_lucro = np.max(network_lucro)
media = np.average(network_lucro)
writer.add_scalar('Lucro/Máximo', max_lucro, gen+1)
writer.add_scalar('Lucro/Média', media, gen+1)
best_lucro_nets.append(max_lucro)
print (f"Best Fitness: {max_lucro}. Generation: {gen}")
lucro_nets_media.append(media)
#print (f"Average Fitness: {media}\n")
t1=time.time()
execution_time = np.round(t1-t0, 4)
grid_search_df = pd.DataFrame({'run_name': [run_name],
'population': [population],
'generations':[generations],
'self_crossover': [str(self_crossover)],
'mutation_rate': [mutation_rate],
'mutation_probability': [mutation_probability],
'selection_percentage': [selection_percentage],
'cromossome_size': [cromossome_size],
'best_result': [max_lucro],
'tempo': [execution_time]
})
if iteration==0:
grid_search_df.to_csv("grid_search.csv",index=False)
else:
file_df = pd.read_csv("grid_search.csv")
file_df = file_df.append(grid_search_df)
file_df.to_csv("grid_search.csv",index=False)
writer.close()
writer.flush()
try:
with open('genetic_best_network_mario.json') as json_file:
data = json.load(json_file)
lucro = int(data.get('lucro'))
except:
print('Error to load')
if lucro<networks[0].lucro:
best_net = {'actions': networks[0].get_actions(),'lucro':networks[0].lucro, 'generation':networks[0].generation, 'grid_search_iteration': iteration}
with open('genetic_best_network_mario.json', 'w') as json_file:
json.dump(best_net, json_file)
json_file.close()
def main():
population_values = [25] #50 10 -> mt pouco
generations_values = [10] #100
self_crossover_values = [False]
mutation_rate_values = [0.1, 0.05] #0.001 e 0.01 travou em ótimo local
mutation_probability_values = [1] # 0.1, 0 muito baixos, não chegou a mutacionar mt #falta 0.5 e False p/ 0.05 e 0.1 m_r
selection_percentage_values = [0.2] #porcentagem dos melhores membros da população que irão pra próxima geração
cromossome_size_values = [8000] #5000, 10000 #tamanho do cromossomo (numero de ações)
population = 25
generations = 40
self_crossover = False
mutation_rate = 0.05
mutation_probability = 0.5
selection_percentage = 0.2
cromossome_size = 8000
i=0
#death_mutation = True
#reduced_action_set = False
#run(i, run_name, population, generations, self_crossover, mutation_rate, mutation_probability, selection_percentage, cromossome_size, death_mutation, reduced_action_set)
#i+=1
#death_mutation = False
#reduced_action_set = True
#run_name = "run"+str(i)
#run(i, run_name, population, generations, self_crossover, mutation_rate, mutation_probability, selection_percentage, cromossome_size, death_mutation, reduced_action_set)
i=10
run_name = "its_the_final_countdown"
death_mutation = True
reduced_action_set = True
run(i, run_name, population, generations, self_crossover, mutation_rate, mutation_probability, selection_percentage, cromossome_size, death_mutation, reduced_action_set)
if __name__ == '__main__':
main()