31 lines
601 B
Python
31 lines
601 B
Python
import matplotlib.pyplot as plt
|
|
|
|
from game import run_game
|
|
from util import initial_q_fill
|
|
|
|
|
|
AMOUNT_RUNS = 5000
|
|
EPSILON = 0.1
|
|
ALPHA = 0.1
|
|
GAMMA = 0.9
|
|
|
|
|
|
"""
|
|
state: (x_distance_to_ghost, y_distance_to_ghost, next_cookie_Direction)
|
|
action: Direction
|
|
q_value: (state, action)
|
|
"""
|
|
q_values = {}
|
|
initial_q_fill(q_values)
|
|
|
|
cookies_per_run = []
|
|
# Amount of single runs
|
|
for x in range(AMOUNT_RUNS):
|
|
amount_cookies_ate = run_game(q_values, EPSILON, ALPHA, GAMMA)
|
|
cookies_per_run.append(amount_cookies_ate)
|
|
print(f"Run {x}: {amount_cookies_ate} cookies ate\n")
|
|
|
|
|
|
plt.plot(cookies_per_run)
|
|
plt.show()
|