PyRatPlayerException¶
- class PyRatPlayerException[source]¶
Bases:
PyRatException(This class inherits from
PyRatException).The exception raised by PyRat when a player causes an error during a game. Typical causes are a player that crashes during
preprocessing(...),turn(...)orpostprocessing(...)(including when it uses the library incorrectly), or a player whoseturn(...)method returns something that is not an action. The error of the player itself is printed when it happens, and the game stops with this exception, unless the game was created withcontinue_on_error=True.Here is an example of how to catch it:
from pyrat import Game, PyRatPlayerException game = Game() game.add_player(MyPlayer()) try: stats = game.start() except PyRatPlayerException as error: print("A player caused an error:", error)