Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyrat
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
Show more breadcrumbs
OUAGAGUE Loqman
pyrat
Commits
02072585
Commit
02072585
authored
3 months ago
by
OUAGAGUE Loqman
Browse files
Options
Downloads
Patches
Plain Diff
cleaninig up
parent
0171e6a1
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
players/TemplatePlayer.py
+0
-140
0 additions, 140 deletions
players/TemplatePlayer.py
with
0 additions
and
140 deletions
players/TemplatePlayer.py
deleted
100644 → 0
+
0
−
140
View file @
0171e6a1
#####################################################################################################################################################
######################################################################## INFO #######################################################################
#####################################################################################################################################################
"""
This file contains useful elements to define a particular player.
In order to use this player, you need to instanciate it and add it to a game.
Please refer to example games to see how to do it properly.
"""
#####################################################################################################################################################
###################################################################### IMPORTS ######################################################################
#####################################################################################################################################################
# External imports
from
typing
import
*
from
typing_extensions
import
*
from
numbers
import
*
# PyRat imports
from
pyrat
import
Player
,
Maze
,
GameState
,
Action
#####################################################################################################################################################
###################################################################### CLASSES ######################################################################
#####################################################################################################################################################
class
TemplatePlayer
(
Player
):
"""
This player is basically a player that does nothing except printing the phase of the game.
It is meant to be used as a template to create new players.
Methods
"
preprocessing
"
and
"
postprocessing
"
are optional.
Method
"
turn
"
is mandatory.
"""
#############################################################################################################################################
# CONSTRUCTOR #
#############################################################################################################################################
def
__init__
(
self
:
Self
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
Self
:
"""
This function is the constructor of the class.
When an object is instantiated, this method is called to initialize the object.
This is where you should define the attributes of the object and set their initial values.
Arguments *args and **kwargs are used to pass arguments to the parent constructor.
This is useful not to declare again all the parent
'
s attributes in the child class.
In:
* self: Reference to the current object.
* args: Arguments to pass to the parent constructor.
* kwargs: Keyword arguments to pass to the parent constructor.
Out:
* A new instance of the class.
"""
# Inherit from parent class
super
().
__init__
(
*
args
,
**
kwargs
)
# Print phase of the game
print
(
"
Constructor
"
)
#############################################################################################################################################
# PYRAT METHODS #
#############################################################################################################################################
@override
def
preprocessing
(
self
:
Self
,
maze
:
Maze
,
game_state
:
GameState
,
)
->
None
:
"""
This method redefines the method of the parent class.
It is called once at the beginning of the game.
In:
* self: Reference to the current object.
* maze: An object representing the maze in which the player plays.
* game_state: An object representing the state of the game.
Out:
* None.
"""
# Print phase of the game
print
(
"
Preprocessing
"
)
#############################################################################################################################################
@override
def
turn
(
self
:
Self
,
maze
:
Maze
,
game_state
:
GameState
,
)
->
Action
:
"""
This method redefines the abstract method of the parent class.
It is called at each turn of the game.
It returns an action to perform among the possible actions, defined in the Action enumeration.
In:
* self: Reference to the current object.
* maze: An object representing the maze in which the player plays.
* game_state: An object representing the state of the game.
Out:
* action: One of the possible actions.
"""
# Print phase of the game
print
(
"
Turn
"
,
game_state
.
turn
)
# Return an action
return
Action
.
NOTHING
#############################################################################################################################################
@override
def
postprocessing
(
self
:
Self
,
maze
:
Maze
,
game_state
:
GameState
,
stats
:
Dict
[
str
,
Any
],
)
->
None
:
"""
This method redefines the method of the parent class.
It is called once at the end of the game.
In:
* self: Reference to the current object.
* maze: An object representing the maze in which the player plays.
* game_state: An object representing the state of the game.
* stats: Statistics about the game.
Out:
* None.
"""
# Print phase of the game
print
(
"
Postprocessing
"
)
#####################################################################################################################################################
#####################################################################################################################################################
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