Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
La purge estivale des projets de gitlab-df sera réalisée jeudi 10 juillet vers 10h.
Show more breadcrumbs
MIRANDA GONZALES Marcelo
SAE
Commits
37750470
Commit
37750470
authored
1 month ago
by
MIRANDA GONZALES Marcelo
Browse files
Options
Downloads
Patches
Plain Diff
Delete visualize_Random4.ipynb
parent
23a8ea8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
games/visualize_Random4.ipynb
+0
-158
0 additions, 158 deletions
games/visualize_Random4.ipynb
with
0 additions
and
158 deletions
games/visualize_Random4.ipynb
deleted
100644 → 0
+
0
−
158
View file @
23a8ea8f
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1 style=\"background-color: gray;\n",
" color: black;\n",
" padding: 20px;\n",
" text-align: center;\">INFO</h1>\n",
"\n",
"In this script, we run player `Random4` in a maze, to visualize its behavior."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1 style=\"background-color: gray;\n",
" color: black;\n",
" padding: 20px;\n",
" text-align: center;\">IMPORTS</h1>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# External imports\n",
"import sys\n",
"import os\n",
"import pprint\n",
"\n",
"# Add needed directories to the path\n",
"sys.path.append(os.path.join(\"..\", \"players\"))\n",
"\n",
"# PyRat imports\n",
"from pyrat import Game\n",
"from Random4 import Random4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1 style=\"background-color: gray;\n",
" color: black;\n",
" padding: 20px;\n",
" text-align: center;\">CONSTANTS</h1>\n",
"\n",
"Let's configure the game with a dictionary."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Customize the game elements\n",
"CONFIG = {\"mud_percentage\": 0.0,\n",
" \"nb_cheese\": 1,\n",
" \"random_seed\": 42,\n",
" \"trace_length\": 1000}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We perform a single game with the configuration defined above."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Instantiate a game with specified arguments\n",
"game = Game(**CONFIG)\n",
"\n",
"# Instantiate a player and add it to the game\n",
"player = Random4()\n",
"game.add_player(player)\n",
"\n",
"# Start the game and\n",
"stats = game.start()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'players': {'Random4': {'actions': {'east': 3,\n",
" 'error': 0,\n",
" 'miss': 0,\n",
" 'mud': 0,\n",
" 'north': 0,\n",
" 'nothing': 0,\n",
" 'south': 4,\n",
" 'wall': 0,\n",
" 'west': 7},\n",
" 'preprocessing_duration': 0.0,\n",
" 'score': 1.0,\n",
" 'turn_durations': [0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0,\n",
" 0.0]}},\n",
" 'turns': 14}\n"
]
}
],
"source": [
"# Show statistics\n",
"pprint.pprint(stats)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% 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
`Random4`
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
Random4
import
Random4
```
%% 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:
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
=
Random4
()
game
.
add_player
(
player
)
# Start the game and
stats
=
game
.
start
()
```
%% Cell type:code id: tags:
```
python
# Show statistics
pprint
.
pprint
(
stats
)
```
%% Output
{'players': {'Random4': {'actions': {'east': 3,
'error': 0,
'miss': 0,
'mud': 0,
'north': 0,
'nothing': 0,
'south': 4,
'wall': 0,
'west': 7},
'preprocessing_duration': 0.0,
'score': 1.0,
'turn_durations': [0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0]}},
'turns': 14}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment