Created
December 23, 2015 20:40
-
-
Save pierrelux/ceefeacdd42533900037 to your computer and use it in GitHub Desktop.
Bare minimum to interface to ALE and display the screen with Matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib | |
matplotlib.use('TkAgg') | |
import matplotlib.pyplot as plt | |
from ale_python_interface import ale_python_interface as ALE | |
def display_ale(im, screen): | |
im.set_data(screen) | |
plt.draw() | |
ale = ALE.ALEInterface() | |
ale.setInt(b'random_seed', 1234) | |
ale.loadROM(b'breakout.bin') | |
plt.ion() | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
im = ax.imshow(ale.getScreenRGB()) | |
plt.draw() | |
legal_actions = ale.getMinimalActionSet() | |
while not ale.game_over(): | |
ale.act(np.random.choice(legal_actions)) | |
display_ale(im, ale.getScreenRGB()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment