Ejemplo n.º 1
0
)  # use "fancy" for full background, random bird color and random pipe color, use "fixed" (default) for black background and constant bird and pipe colors.
p = PLE(game,
        fps=30,
        frame_skip=1,
        num_steps=1,
        force_fps=True,
        display_screen=True)
# Note: if you want to see you agent act in real time, set force_fps to False. But don't use this setting for learning, just for display purposes.

p.init()
reward = 0.0

nb_games = 10
cumulated = np.zeros((nb_games))

for i in range(nb_games):
    p.reset_game()

    while (not p.game_over()):
        state = game.getGameState()
        action = FlappyPolicy(state,
                              None)  ### Your job is to define this function.

        reward = p.act(action)
        cumulated[i] = cumulated[i] + reward

average_score = np.mean(cumulated)
max_score = np.max(cumulated)

print(f"average_score: {average_score}")
print(f"max_score: {max_score}")
Ejemplo n.º 2
0
        fps=30,
        frame_skip=1,
        num_steps=1,
        force_fps=True,
        display_screen=True)
# Note: if you want to see you agent act in real time, set force_fps to False. But don't use this setting for learning, just for display purposes.

p.init()
reward = 0.0

nb_games = 10
cumulated = np.zeros((nb_games))

for i in range(nb_games):
    p.reset_game()

    while (not p.game_over()):
        state = game.getGameState()
        screen = p.getScreenRGB()
        action = FlappyPolicy(state,
                              screen)  ### Your job is to define this function.

        reward = p.act(action)
        cumulated[i] = cumulated[i] + reward

average_score = np.mean(cumulated)
max_score = np.max(cumulated)

print(average_score)
print(max_score)
Ejemplo n.º 3
0
p = PLE(game,
        fps=30,
        frame_skip=1,
        num_steps=1,
        force_fps=False,
        display_screen=True)
# Note: if you want to see you agent act in real time, set force_fps to False. But don't use this setting for learning, just for display purposes.

p.init()
reward = 0.0
nb_games = 20
cumulated = np.zeros((nb_games))

for i in range(nb_games):
    p.reset_game()

    while (not p.game_over()):
        state = game.getGameState()
        screen = p.getScreenRGB()
        action = FlappyPolicy(state, screen)

        reward = p.act(action)
        cumulated[i] = cumulated[i] + reward

    print("Game {} over, score : {}".format(i + 1, cumulated[i]))

average_score = np.mean(cumulated)
max_score = np.max(cumulated)
print("average_score : {}".format(average_score))
print("max_score {}".format(max_score))