Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Game Programming By Example

You're reading from   Python Game Programming By Example A pragmatic guide for developing your own games with Python

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785281532
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Implementing steering behaviors

The strategies that we will cover here have been taken from Craig Reynolds's paper Steering Behaviors for Autonomous Characters, written in 1999. It has become a well-known reference for implementing autonomous motion in an easy manner for non-playable characters.

You can check out the online version at http://www.red3d.com/cwr/steer/gdc99/. In this section, you will learn how to implement the following kinds of behavior:

  • Seek and flee
  • Arrival
  • Pursuit and evade
  • Wander
  • Obstacle avoidance

Seek and flee

The seek behavior moves the character towards a specific position in the space. This behavior is based on the combination of two forces: the character's velocity and the steering force. This force is calculated as the difference between the desired velocity (the direction from the character to the target) and the character's current velocity.

Note that this is not a force in the strict physics definition; it is just another velocity vector. You can think...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime