Skip to content

Instantly share code, notes, and snippets.

@pierrelux
Created December 23, 2015 20:40
Show Gist options
  • Save pierrelux/ceefeacdd42533900037 to your computer and use it in GitHub Desktop.
Save pierrelux/ceefeacdd42533900037 to your computer and use it in GitHub Desktop.
Bare minimum to interface to ALE and display the screen with Matplotlib
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