You are on page 1of 3

Lab 2 Creating Reactive NPCs

Please Note:
This lab is intended to give you an opportunity to experiment with behaviour based
scripting. You should use the environment you created in the previous lab, there is n
report section to this lab, you should use it to begin creating your AI characters. We
have provided you with some resources to help you develop your first reactive scrip
As soon as you have completed this lab you may move onto the next (steering
behaviours).
In this lab the objective is to create an NPC (non player character),
which reacts to one or more items within the environment. In the
green boxs there are four different tasks which you can attempt,
you only need to pick one, but you can implement as many as you
like. The tasks are designed to go from easy (1) to hardest (4), you
will need to demonstrate at least one of these in your game. Higher
marks are reserved for the more complex behaviours
This will first involve populating your environment with some basic
characters. If you are undertaking this task in netlogo then you can
use the basic turtle agent, however, if you are using unity we advise
you use a capsule or sphere game object as a placeholder for an
animated character.

1. Attract
Create an NPC that is attracted toward a specific location or item within your
environment. To make it obvious what your NPC is being attracted too it is advised
that you either use a specific colour of patch (netlogo) or a game object (unity). The
attract behaviour involves turning towards the attractor and moving towards it.

Bonus How can you modify the simple turn and move behaviour to make it appear
more realistic.
2. Avoid
Create an NPC that is repelled from a specific location or item within
your environment. The avoid behaviour involves turning away the
repulsor and moving away from it.
Bonus Can you modify the behaviour so that the agent is repelled
from other agents? When the NPC is moving (walking/running) it
should have a larger turning-circle based on how quickly it is
moving, can you represent that in you algorithm?

3. Parameterised Behaviours
Remember the ghosts in pacman? Each type of ghost had its own personality which
affected their personality ( see http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior

Create different types of NPC each with their own personality and behavioural rules.
You could start with two NPC types, attractors and avoiders (1 and 2).
Bonus What other behavioural rules other than attractors and avoiders could you
add? How else could you modify the behaviour of the NPCs to represent different
personalities?
4. Conditional Behaviour Switch
An attractor could also be called a predator and an avoider could
also be called a prey. However, few creatures in nature are just one
or another. While a dog will chase a cat, it will run away from a
lion. This change of behaviour is called a conditional behaviour
switch, switching from an attract to an avoid behaviour. If you have
selected this task create an NPC which will change its behaviour
based on a specific condition, such as the proximity of another
agent or a specific time-step.
Bonus Create 4 different conditional behaviours for your NPC.
Hints:

Unity If you are using unity you will need to be able to identify other game objects
as targets. You will need to consider whether you do this in the setup or update
functions.

Netlogo If you are Netlogo you will need to understand how to use the vision cone,
and get the positions of specific patches and agents.
Unity Resources:
C# vs Js:
http://unity3d.com/learn/tutorials/modules/beginner/scripting/csharp-vs-javascript-syntax
If Statements:
http://unity3d.com/learn/tutorials/modules/beginner/scripting/ifstatements
Translate and Rotate:
http://unity3d.com/learn/tutorials/modules/beginner/scripting/transla
te-and-rotate
Look At:
http://unity3d.com/learn/tutorials/modules/beginner/scripting/look-at
Moving Game Objects (Video Tutorial)
https://www.youtube.com/watch?v=OMnFmnKJwWk
Netlogo Resources:
Procedures:
http://ccl.northwestern.edu/netlogo/docs/programming.html#proced
ures
Breeds:
http://ccl.northwestern.edu/netlogo/docs/programming.html#breeds

Tutorials:
http://ccl.northwestern.edu/netlogo/docs/

You might also like