<jupyter_start><jupyter_text>4.3. The Pacman Gym Environment that we are going to use  Pacman environment exploration<jupyter_code>import gym # pip install gym, pip install gym[atari]
from IPython import display
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

env = gym.make('MsPacman-v0')
env.reset()
env.P # {state: {action: [(probability, next state, reward, done)]}}
img = plt.imshow(env.render(mode='rgb_array')) # only call this once
for _ in range(5000):
    img.set_data(env.render(mode='rgb_array')) # just update the data
    display.display(plt.gcf())
    display.clear_output(wait=True)
    action = env.action_space.sample()
    env.step(action)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11971830985915492, 'fraction_numerical': 0.009859154929577466, 'mean_word_length': 5.463636363636364, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '530247', 'license': 'MIT', 'n_tokens_mistral': 244, 'n_tokens_neox': 238, 'n_words': 63, 'path': 'Section 4/Video 4.3.ipynb', 'repo_name': 'PacktPublishing/Machine-Learning-Projects-with-TensorFlow-2.0', 'size': '710'}