Beispiel #1
0
OUT_OF_BOUNDS_PENALTY = 200
OBSTACLE_HIT_PENALTY = 300
EPS_DECAY = 0.9999
LEARNING_RATE = 0.1
DISCOUNT = 0.95
Q_TABLE_SIZE = (SCREEN_WIDTH // BLOCK_SIZE[0] + 2,
                SCREEN_HEIGHT // BLOCK_SIZE[1] + 2, 4)
epsilon = 0.5
q_table = np.zeros(Q_TABLE_SIZE)

screen = pygame.display.set_mode(SCREEN_SIZE)
clock = pygame.time.Clock()
font = pygame.font.Font(None, font_size)

goal = Goal(SCREEN_WIDTH, SCREEN_HEIGHT, GREEN)
goal_rect = goal.get_rect()
obstacle_rects = [
    pygame.Rect((random.randrange(0, SCREEN_WIDTH, BLOCK_SIZE[0]),
                 random.randrange(0, SCREEN_HEIGHT, BLOCK_SIZE[1])),
                BLOCK_SIZE) for i in range(NUM_OBSTACLES)
]
while goal_rect in obstacle_rects:
    goal.change_pos(SCREEN_WIDTH, SCREEN_HEIGHT)
    goal_rect = goal.get_rect()


def gameInit():
    global player
    global player_rect
    global goal_reached
    global out_of_bounds