Skip to content
Snippets Groups Projects
Commit 16c4d997 authored by MIRANDA GONZALES Marcelo's avatar MIRANDA GONZALES Marcelo
Browse files

Delete visualize_Random1.ipynb

parent a737a8fd
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
<h1 style="background-color: gray;
color: black;
padding: 20px;
text-align: center;">INFO</h1>
In this script, we run player `Random1` in a maze, to visualize its behavior.
%% Cell type:markdown id: tags:
<h1 style="background-color: gray;
color: black;
padding: 20px;
text-align: center;">IMPORTS</h1>
%% Cell type:code id: tags:
``` python
# External imports
import sys
import os
import pprint
# Add needed directories to the path
sys.path.append(os.path.join("..", "players"))
# PyRat imports
from pyrat import Game
from Random1 import Random1
```
%% Cell type:markdown id: tags:
<h1 style="background-color: gray;
color: black;
padding: 20px;
text-align: center;">CONSTANTS</h1>
Let's configure the game with a dictionary.
%% Cell type:code id: tags:
``` python
# Customize the game elements
CONFIG = {"mud_percentage": 0.0,
"nb_cheese": 1,
"random_seed": 42,
"trace_length": 1000}
```
%% Cell type:markdown id: tags:
<h1 style="background-color: gray;
color: black;
padding: 20px;
text-align: center;">RUN THE GAME</h1>
%% Cell type:markdown id: tags:
We perform a single game with the configuration defined above.
%% Cell type:code id: tags:
``` python
# Instantiate a game with specified arguments
game = Game(**CONFIG)
# Instantiate a player and add it to the game
player = Random1()
game.add_player(player)
# Start the game and
stats = game.start()
```
%% Output
Traceback (most recent call last):
File "C:\Users\gauti\AppData\Roaming\Python\Python310\site-packages\pyrat\src\Game.py", line 531, in start
time.sleep(sleep_time)
KeyboardInterrupt
%% Cell type:markdown id: tags:
We visualize results using a pretty printer.
%% Cell type:code id: tags:
``` python
# Show statistics
pprint.pprint(stats)
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment