snake.game_io module¶
-
class
GameIO
(game, speed=0.1, player_name='player', score_file='scores')[source]¶ Bases:
object
Controls the game’s input and output.
This class should simply be initialized, it won’t return until the
SnakeGame
has finished, see example below.Examples
game = SnakeGame( board_size=(25, 25), walls=(), random_seed=12, ) # Take over IO and run the game. GameIO(game)
-
__init__
(self, game, speed=0.1, player_name='player', score_file='scores')[source]¶ Initialize an instance of
GameIO
.Parameters: - game (
SnakeGame
) – An instance of the snake game for which the io is being controlled. - speed (
float
) – The time between game steps. - player_name (
str
, optional) – The name of the player, used to write the name into the_score_file
. - score_file (
str
, optional) – The path to a file which keeps track of scores.
- game (
-