Beispiel #1
0
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

    player = Player(SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
    player_rect = player.get_rect()
    goal_reached = False
    out_of_bounds = False