Priority¶
Priority Steering Behaviors
This module implements a class that holds a list of
KinematicSteeringBehaviors and applies them in order,
keeping only the first one that produces an output greater than a certain
treshold. This means that some behaviors which are considered more important
(like ObstacleAvoidance and
CollisionAvoidance) but are not always neccesary
to reach the character’s goal can be ignored when they don’t produce a
meaningful output, it also means that when they do produce a meaningful
output they will be the only ones in action.
This is a very simple form of decision making that involves only steering algorithms, and therefore it is classified as a steering behavior.
Derives from KinematicSteeringBehavior.
Example
This is how you would normally create your own PrioritySteering,
in this case we are making a behavior that will most of the time Pursue
a target, but will prioritize Avoiding Obstacles when that behavior
returns a steering greater than the treshold.
mybehavior = PrioritySteering(
behaviors = [
kinematic.ObstacleAvoidance(character, obstacles),
kinematic.Pursue(character, target),
],
)
PrioritySteering¶
-
class
steering.priority.PrioritySteering(behaviors, epsilon=0.1)[source]¶ -
draw_indicators(screen, offset=<function PrioritySteering.<lambda>>)[source]¶ Draws appropiate indicators for each
KinematicSteeringBehaviorParameters: - screen (pygame.Surface) – Surface in which to draw indicators, normally this would be the screen Surface
- offset (function, optional) –
Function that applies an offset to the object’s position
This is meant to be used together with scrolling cameras, leave empty if your game doesn’t implement one,it defaults to a linear function f(pos) -> pos
-