Behavioral

class pygamelib.actuators.Behavioral(parent)

Bases: pygamelib.actuators.Actuator

The behavioral actuator is inheriting from Actuator and is adding a next_action() method. The actual actions are left to the actuator that implements Behavioral.

Parameters:parent – the item parent.
__init__(parent)

The constructor simply construct an Actuator. It takes on positional paraneter: the parent object.

Methods

__init__(parent) The constructor simply construct an Actuator.
load(data) Load serialized data, create and returns a new actuator out of these data.
next_action() That method needs to be implemented by all behavioral actuators or a NotImplementedError exception will be raised.
next_move() That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.
pause() Set the actuator state to PAUSED.
serialize() Serializes the actuator and returns it as a dict.
start() Set the actuator state to RUNNING.
stop() Set the actuator state to STOPPED.
load(data: dict = None)

Load serialized data, create and returns a new actuator out of these data.

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
next_action()

That method needs to be implemented by all behavioral actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
next_move()

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
pause()

Set the actuator state to PAUSED.

Example:

mygame.pause()
serialize()

Serializes the actuator and returns it as a dict.

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
start()

Set the actuator state to RUNNING.

If the actuator state is not RUNNING, actuators’ next_move() function (and all derivatives) should not return anything.

Example:

mygame.start()
stop()

Set the actuator state to STOPPED.

Example:

mygame.stop()