A Python reimplementation of the famous dino game, thought for autonomous control
You can install it from pypi.
pip install dino-game
To try the game without any automation
python -m dinogame
You can use spacebar
to start running, jump, reset when dino dies, and key_down
to crouch.
This initializes the game
from dinogame import DinoGame
game = DinoGame()
To start the game's loop you can use play
method
game.play()
The library provides some callbacks to feed back the game
loop_callback
is called at each new framegameover_callback
is called when a gameover occurs
To subscribe to callback you can use callback's set
method.
The current instance of DinoGame
is given to the callback as argument.
def lp_cb(game: GameDino):
# do something
game.loop_callback.set(lp_cb)
The following actions are provided as methods:
jump
to jumpcrouch
to crouchstand_up
to stand upstart_running
to start to runreset
to reset the game
if the_cake_is_ready():
game.jump()
DinoGame
exposes the following useful properties:
load
the current load of the application. If it is more than1
it is a problem.score
the current score or that of the last session if the player dies.time_alive
the lifetime of the player.frame
the last game frame asnumpy.ndarray
.
if the_game_is_over():
print("My score is {}".format(game.score))
This project is realized with the following python's packages: