Game Devs Unleash Artificial Intelligence: Flocking Agents

Artificial Intelligence for Game Devs in Unity to understand & implement the beautiful bird's natural Flocking Behavior
4.7 (33 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
635 students enrolled
$19
$40
52% off
Take This Course
  • Lectures 26
  • Length 2.5 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2015 English

Course Description

Learn how to create Artificial Intelligent Agents that have Flocking Behavior and apply them to your projects in games or movies. You have seen Flocking behavior in nature, in games, in movies and in architectural simulations but you might have missed it.

The course is project based with the best teach-apply loop:

  • a theoretical pseudocode (game engine agnostic) implementation
  • followed immediately by a practical implementation and application in Unity 3d

Both pseudocode and Unity C# lectures complement each other giving you a full perspective.

Best video quality 1080p full HD.

You will have access to the course forum where you can discuss each topic with like-minded, A.I. passionate, students like yourself.

With the help of this course you will be able to understand a piece of nature and replicate it, essentially reverse engineer a piece of nature. Invest in yourself and add Flocking to your A.I. skill set! Follow this Unleash A.I. series.

Still unsure? Dive in and learn, and if you are not satisfied you get a 30 day money back guarantee! No questions asked.

What are the requirements?

  • You should already have basic Computer Science skills (minimum 6 months experience)
  • You should already be familiar with any game engine (minimum 3 months experience)
  • Have Unity 3D game engine installed or your own favorite game engine
  • Understand Pseudocode or C# or Java

What am I going to get from this course?

  • Analyze, Decompose and Implement custom Flocking Agents for your own game or movie or personal simulation project
  • Understand and Create Emergence: simple rules that interfere to give rise to complexity
  • Appreciate emergent behaviors in nature around you
  • Gain problem solving skills
  • Understand and use Vectors and Vector Operations successfully in a Game Engine

What is the target audience?

  • The course is best suited to programmers who want to add realistic bird flocking or fish schooling or other emergent behaviors to their games, movies or simulations.
  • The course is best suited to programmers looking to improve their skills on working with Vectors inside the Unity 3d game engine
  • The couse if partially suited for students who want to learn emergent behaviour but do not have prior programming experience. The must have at least basic math or physics skills.
  • The course is partially suited for students who already know about emergence. They can use it as a refresher.
  • The course is not suited for students who do not have basic math or physics skills.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction
01:51

Hi, Razvan Pistolea

What are Artificial Intelligence Agents with Flocking Behavior

Applications of Flocking Behavior in Games, Movies, Engineering and Architectural Simulation

Journey of exploration and implementation

00:59

Understand how Flocking Behavior appears in nature

Discover the mechanics and equations of Flocking

Implement Flocking


Funny scenario about a Big Movie Producer wanting a flock of sci-fi birds and a big money reward for you if you do it fast and believable

Section 2: Insights
08:21

Carefully and analytically observe our Earthly flocking birds in their natural habitat

Homework: You must write at least 6 observations

  1. They repeatedly separate and combine...like quicksilver
  2. They move like a wave or a fluid
05:07

Questions Answers Insights

Why do you think some birds fly together?

Their movement seems orchestrated somewhat. Does each bird have a sheet music telling it where to go?

Does this behavior seem completely random or do some patterns exist?

Can you think of other animals that are not birds but still "flock" as well?


Relevant questions for our hypothesis:

Does a bird look at all the other birds or just at a few of its nearby neighbors?

Do birds bump into each when they fly or are they separated?

Do birds in the same group or cluster fly in the same direction and with an approximately same speed?

04:01

Scientific method:

  1. Have a Problem
  2. Gather Relevant Data
  3. Formulate Hypothesis
  4. Empirically Test

Ideas:
  1. Neighborhood radius = abstraction of vision / interest radius
  2. Cohesion Behavior = form a whole
  3. Separation Behavior = avoid collisions
  4. Alignment Behavior = match heading and speed to stay in the flock
  5. Combine all Behaviors in different proportions
Section 3: Implement Basic Flocking in Pseudocode and Unity
07:27

Structure our Project in a simple text file using Pseudocode


class Agent{

  1. position vector2 or vector3
  2. rotation vector or quaternion
  3. velocity
  4. acceleration
  5. world reference


  • void update(float t)
  • void render()
  • Vector cohesion() // cohesion behavior
  • Vector separation()
  • Vector alignment()
  • Vector combine() // combine behaviors

}

class World{

  1. List<Agent> agents
  • void init(int n)
  • void update(float t)
  • List<Agent> getNeighbors(Agent agent, float radius)// neighbors of agent inside radius

}

class AgentConfig{

  1. float maxV// maximum velocity
  2. float maxA
  3. float Rc, Rs, Ra
  4. float Kc, Ks, Ka

}

05:05

Create a new project in Unity

Write a simple Move script

Add script statically or dynamically to object

Prefabs in Unity = template, blue print

09:21

Agent

World

AgentConfig

Spawn Function

05:21

Equations of motion

time

acceleration

velocity

position


trucate acceleration

trucate velocity


Euler forward integration

Rocket science

Stable integration methods, Runge-Kutta

02:49

Unity uses the metric system


04:50

Go towards the center of mass of all nearby neighbors

04:55

Vector cohesion(){

  1. // cohesion behavior
  2. // return a vector that will steer our curent velocity
  3. // towards the center of mass of all nearby neighbors
  4. // get all my nearby neighbors inside radius Rc of this current agent
  5. // no neighbors means no cohesion desire
  6. // find the center of mass of all neighbors
  7. // steer our velocity towards the COM
  8. // make r have the length 1

}

04:26

Individual separation forces combine to give the resultant force


Vector separation(){

  1. // separation behavior
  2. // steer in the opposite direction from each of our nearby neigbhors
  3. // get all my neighbors
  4. // no neighbors no separation desire
  5. // add the contribution of each neighbor towards me
  6. // force contribution will vary inversly proportional
  7. // to distance or even the square of the distance

}


Separation Behavior in Unity
03:59
02:59

Match heading and speed in order to stay withing the flock

06:53

Update Prefab

Warning!

Tokyo Drift

LookAt function


Vector alignment(){

  1. // alignment behavior
  2. // steer agent to match the direction and speed of neighbors
  3. // get all neigbhors
  4. // no neighbors means no one to align to
  5. // match direction and speed == match velocity
  6. // do this for all neighbors

}

03:35

Combine all forces at the same time in different proportions

08:14

Wrap around to keep inside the view

10:07

Structure problem

Update loop, Euler integration

Pseudocode + Unity = perfect match, best learning

Cohesion, Separation, Alignment

Tweek Parameters

Ideas=Lines of Code=Simulation

Think it! Build it!

Emergence, split, merge, dance

Complex->Pieces->Recombine

Playground to experiment aspects of Flocking



Section 4: Refinements for Advanced Flocking Behavior In Pseudocode and Unity
05:01

360 degrees default

180 degrees realistic

angle between 2 vectors

add the refinement to all behaviors

04:19

They move closely together

They are moving like a wave

08:50

A solo creature or a small flock that wanders purposefully on the map

Jitter vs Smooth = Dumb vs Purpose

Generate a small random target that moves on a circle in from of the agent

Project the target from local space to world space

11:41

Update prefab to have a Default Transform

Warning ! the transform scale influences the projection from local space to world space

09:32

Extend the Agent Class to make a Predator Class

Avoid Enemies Behavior

Flee Behavior

GetPredators Function


Section 5: Conclusion
Student Projects
Article
What's next
Article

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Razvan Pistolea, Source Code Painter

I am a Machine Learning Engineer, Deep Learning Engineer and even an Indie Game Developer with a Major in Compilers and a Master's degree in Artificial Intelligence from University Politehnica of Bucharest.

I am passionate about Games and Artificial Intelligence. I love to give life to A.I. agents in my project or my friend's projects and I want to teach you too.

Ready to start learning?
Take This Course