Sie sind auf Seite 1von 69

MSc Computer Science

Chapter 1
1.1 Introduction
Games have been an entertainment factor for human being from early ages, computer games
are the digital entertainment from recent years and are increasingly entertaining with more
and more realistic in nature as the technology and hardware capabilities are increasing day by
day. There are lot of techniques and new ideas which are being implemented in present
games; Artificial intelligence (AI) is one of such technique that helps to enhance the game
experience to its fullest. Elements of artificial intelligence used in computer games have come
a long way.
In the broadest sense, most of games incorporate some form of Artificial Intelligence (AI); it
has been a core module in the game development process. In the beginning, the developed
systems were based on set of rules written directly in the code of the game or on the
behaviour scripts interpreted by the code. Game developers have used AI for years to give
seemingly intelligent life to countless game characters. Fast technical progress and rapid
increase of processing power of home computers were also a catalyst for the development of
applications using artificial intelligence in computer games. The game which came in the
early time of gaming industry began the artificial intelligence algorithms had to settle for
limited capabilities of machines available at that time, with the processor frequencies no
higher than 2 MHz (Steve Rabin, 2002).
Prior to this revolution in game, the importance for AI in games is least considered. Game
developers used to perform a last minute rush job mostly implemented in the final two or
three months of development which results in poor and unsatisfying game output with lifeless characters in their games. A lot of commercial and successful game tends to ignore the
-importance of Non-Playing Character (NPC) mostly in Role-Playing Games (RPG) thereby
decreasing the overall feeling and realism in games. Most of the developers concentrate their
NPCs behaviour on static or un-realistic animation techniques for that particular situation
(Alex.J, 2003). Even this method of settle animation and low-level AI has been hardcoded,
and has been repeating in all the games. There are plenty of best sellers evolved over the time
and every game has been following the same basic state-machines rule and repetitive AI for
their NPCs character in the game. The game developers tend to think that amount of time
1

MSc Computer Science

spent by the player with the NPC character in the game is making the player unnoticed the
intelligence of that character and the behaviour of the character (Woodcock, S. 2000).
However the usage of game AI has been brewing, the past few years have witnessed game AI
vastly richer and more entertaining than the simplistic AI done in the past. Animation
techniques and 3D rendering hardware has been improved and the detailed quality of game
graphics is being more steering new heights in the visual representations. AI has increasingly
become one of the critical factors in a game success scale.
The main underlining point of this work is to draw out the importance of AI experience for a
game player, especially when the player is in non-combat situations and to enhance the
behavioural characteristics of an NPC in RPGs. Specifically in a leading game NeverWinter
Nights2(NWN2). So the game play would feel much more realistic in nature when interacted
with an NPC.

1.2 Aim of the project


The aim of the project is to improve realism in games by enhancing the behavioural
characteristics of a Non-playing Character (NPC). Especially in Role-Playing Games (RPG)
so that the player would feel the game play much more realistic in nature, and also the player
interaction with the NPC will be interesting every time he play the game

1.3 Objectives

Improve Artificial Intelligence of an NPC in RPGs to boost realism.


Find out the possible aspects whether Smart Terrain could really be implemented to
enrich the Artificial Intelligence (AI) skills of an NPC.

1.4 Deliverables

Improve realism in RPGs through enhancing the NPCs AI using Smart Terrain

technique.
Implementation of Smart Terrain using different event-handling scripts in NWscript,

which is a good scripting tool for NWN2.


Analysing the implementation by conducting questionnaires and evaluating the results
yielded from the users.
2

MSc Computer Science

1.5 Hypothesis
As far as the research done for this project, most of the successful games in the commercial
market tend to ignore the importance of AI for non-combat NPCs, those are not involved in
any kind of aggressive combat situations in the in-game mainly in case of an RPG games.
Keeping in mind the problems identified from the research, the hypothesis constructed is that
a higher sense of realistic behaviour in NPCs will contribute to a higher sense of realism in
game play. The project is to explore if Smart Terrain technique will be contributing factor in
this process.

1.6 Research Question


Basing on the hypothesis constructed the root question like measuring realistic behaviours is
evolved and also what part of the AI techniques can be used to fulfil this needs to bring out
the experience is also researched. The outcome of the research eventually led to the research
questions like

What is the measure for denominating the experience of a player?


What AI technologies are to be implemented in the existing models to improve the
effect of game play?

On advance research in to the realism of a games and Smart Terrain further sub divisions in
the research question has been deduced. Following are the research question for this project.

Can realistic behaviour of the NPCs in non-combat situations does really affect the

player experience?
Does an advanced AI technique like Smart Terrain really helps in enhancing the
experience?

The project report has been divided into various chapters and sub-divided into sections
explaining different elements involved in the AI techniques and the background research
based on these techniques.

MSc Computer Science

Chapter 2: Describes the literature review for this project and also the background
information required for the doing the research.
Chapter 3: Describes the methodological part involved in this project and also what
techniques that are being used to fulfil the research questions.
Chapter 4: Describes the implementation part of the methodology that been discussed in the
earlier chapter.
Chapter 5: Describes evaluation of the implementation and testing analysis.
Chapter6: Describes the result and outcome of the testing and analysis of the results using
statistical methods and graph charts.

1.7 Conclusion
This chapter merely described about the introduction part of the projects that is intended to do
and also the project aims and deliverables is also mentioned. It is important to outline the aims
and deliverables of the project before starting the project as this will help to achieve the goal
and results that is originally intended for this project.

MSc Computer Science

Chapter 2: Literature review


2.1 What is AI?
Over the time there are many definitions explained for different forms of AIs and AI
techniques depending on their usage, but when talked about the word intelligence the possible
explanation is that the word intelligence is described as a set of skills which allows humans to
solve problems with limited resources. Skills such as learning, abstract thought, planning,
imagination, and creativity cover the most important aspects of human intelligence (Alex.J,
2003). Given the generic definition of the word intelligence, the definition of AI takes its turn
in more technical and rather practical form of intelligence. Artificial intelligence is about
making computers able to perform the thinking tasks that humans and animals are capable of
(Millington.I, Funge.J, 2009).
Many intelligent programs have been evolved over the time for the computers to perform
superhuman abilities: arithmetic, sorting, searching, and so on, but one has to look up on a
game intelligence in a rather technical prospective which deals with entertainment and game
experience of a game player. Most of the game intelligence is shown in the form of an
intelligent agent that is created in the game to address this purpose of AI and to act upon a
player so that the player would feel the game much more realistic and more interesting
enough. An intelligent game agent is the one that acquire knowledge about the world and then
act on that knowledge. The quality and effectiveness of this action then become a question of
the game balance and design (Brain.S, 2004).
Many researchers have differentiated AI as two main domain categories, namely academic AI
and Game AI. Artificial intelligence takes academic approach when talked about creation of
new computer programmes which emulates acting and thinking like a human, as well as
acting and thinking rationally. In a general sense academic AI takes rather cognitive and
behavioural view of intelligence and includes rationality and humanity (Stuart.R, Peter,N,
2003) whereas on other hand game AI takes intelligent approach only in the games point of
view.

MSc Computer Science

2.1.1 Academic AI and Game AI


In academia, some AI researchers are motivated by philosophy: understanding the nature of
thought and the nature of intelligence and building software to model how thinking might
work. Some are motivated by psychology: understanding the mechanics of the human brain
and mental processes. Others are motivated by engineering: building algorithms to perform
humanlike tasks. This threefold distinction is at the heart of academic AI (Millington.I,
Funge.J, 2009). Stuart and Peter (2003, p.23) defines Academic AI as a creation of computer
programs that emulates four things: Thinking humanly, Thinking rationally, Acting humanly,
and Acting rationally. In academic world these are the basis of building intelligent programs.
In the case of game AI developers they are primarily interested in only the engineering side of
the theory; building algorithms that make game characters appear human or animal-like.

2.1.2 Computer game AI


The definition of game AI is rather broad and flexible, anything that gives the illusion of
intelligence to an appropriate level, thus making the game more immersive, challenging, and,
most importantly fun, can be considered game AI. Just like the use of real physics in games,
good AI adds to the immersiveness of the game, drawing players in and suspending their
reality for a time (David.M, Glenn.S, 2004). In very much simple sense a game AI is a code in
a game that makes a computer-controlled opponents appear to make smart decisions when the
game has multiple choice for a given situation, resulting in behaviour that are relevant
effective unpredictable and very much useful at that point in the game (Brain.S, 2004). For a
long time, the foremost indicator of a computer game's quality was the quality of threedimensional graphics it featured; however, a realisation soon came that nice graphics, sound,
and character animation is not everything. Recently, one of the most important elements of
computer games have been identified as artificial intelligence as the primary factor behind the
so-called playability of present-day video games.
Game world is primarily concerned with behaviourist wing of AI science. Game AI makes
intelligent decisions for play, it is more considered as a result of particular input, while the
intelligence

part

lies

in

extracting

appropriate

solutions/animations/paths for that particular input given.

behaviour

from

the

poll

of

MSc Computer Science

In the early stages game developers used cheating as a means of improving the skills of an
agent (Steve Rabin, 2002). In the context of artificial intelligence in video games, cheating
refers to the programmer giving agents access to information that is unavailable to the
player. In a simple example, if the agents want to know if the player is nearby they can either
be given complex, human-like sensors (seeing, hearing, etc.), or they can cheat by simply
asking the game engine for the player's position. The use of cheating in AI shows the
limitations of the "intelligence" achievable artificially; generally speaking, in games where
strategic creativity is important, humans could easily beat the AI after a minimum of trial and
error if it were not for this advantage. Cheating is often implemented for performance reasons
where in many cases it may be considered acceptable as long as the effect is not obvious to
the player. While cheating refers only to privileges given specifically to the AI, it does not
include the inhuman swiftness and precision natural to a computer, a player might call the
computer's inherent advantages "cheating" if they result in the agent acting unlike a human
player (Steve Rabin, 2002).
There are different methods that game developers will follow to extract the wow factor in a
game. There are a number of underlying principles behind video game AI, the major one
being that of having a rule based system whereby information and rules are entered into a
database, and when the video game AI is faced with a situation, it finds appropriate
information and acts on it according to the set of rules that apply to the situation. If the AI
database is large enough, then there is sufficient unpredictability in the database to produce a
simulation of human choice. Earlier game development used Finite state machine (FSM)
method in to describing the behaviour of computer-controlled enemies. A* is also used as a
best alternative to pathfinding problems of AI. Many of present day games are still using FSM
and A* algorithms as their basic algorithm and are creating new advanced algorithms.
The AI in most modern games addresses three basic needs: the ability to move characters,
ability to make decisions about where to move, and the ability to think tactically or
strategically (Millington.I, Funge.J, 2009).

MSc Computer Science

Figure 2 (a): Figure showing the AI Model (Millington.I, Funge.J, 2009).


Figure 2(a) illustrates AI model. The figure basically splits AI task into three sections:
movement, decision making, and strategy. The first two sections contain algorithms that work
on a character-by-character basis, and the last section operates on a whole team or side.
Around these three AI elements is a whole set of additional infrastructure. Not all game
applications require all levels of AI. Board games like Chess or Risk require only the strategy
level; the characters in the game (if they can even be called that) dont make their own
decisions and dont need to worry about how to move.

MSc Computer Science

2.2 AI Techniques
There are many AI techniques which are being used by developers to create life-like
characters in their games depending on the game genre. There is no specific algorithm or a
specific AI technique that are used for a particular genre, but instead using according to the
game requirement. Many computer game researchers have came up with different generic
algorithm which are been derived from basic AI and are being used as a game AI in the
present game.
AI techniques are primarily distilled in to two sections: Deterministic and Non-deterministic
(David.M, Glenn.S, 2004).

2.2.1 Deterministic AI
Deterministic behaviour or performance is specific and predictable, there is no uncertainty. An
example of deterministic behaviour is a simple chasing algorithm. This type of AI is explicitly
coded for a Non-Playing Character (NPC) to move from towards a target point by advancing
along the X and Y coordinates axes until the characters X and Y coordinates coincide with
the target location.

2.2.2 Non-deterministic AI
Non-deterministic behaviour has a degree of uncertainty and is somewhat unpredictable (the
degree of uncertainty depends on the AI method employed and how well that method is
understood). An example of nondeterministic behaviour is a NPC learning to adapt to the
fighting tactics of a player. Such learning could use a neural network, a Bayesian technique,
or genetic algorithms.
As for the present research is concerned, this project work is only going to consider
deterministic AI techniques as this techniques are more related to the work that is being done
in this research. There are many algorithms techniques and basic AI (Deterministic AI in case
of this project work) methods that are being implemented in the game development world.
The most common of them are chasing & evading, Rule-Based AI, pattern movement,
flocking, path finding and waypoint, A* algorithm, A-life algorithms (David.M, Glenn.S,
2004).
9

MSc Computer Science

Of all the AI techniques path-finding, A-life and A* algorithms are three most popular
techniques which are still being used in current games. Keeping in mind the requirements of
this project, these three techniques are proven to be the best alternative to the smart-terrain AI
implementation for the sake of this project. The details of the choice of these alternatives are
explained further in the document along with the benefits and flaws involved in each of those
techniques.

2.3 Basic Pathfinding


There are many types of pathfinding problems present. Unfortunately, no one solution is
appropriate to every type of pathfinding problem. The solution merely depends on the
specifics of the pathfinding requirements for any given game. Nevertheless the most basic
level of pathfinding is simply the process of moving the position of a game character from
one point (initial) to another point (destination). David.M and Glenn.S(2004, p96) has given
an example which can be used as a basic pathfinding algorithm.
Example pathfinding algorithm
if(positionX > destinationX)
positionX--;
else if(positionX < destinationX)
positionX++;
if(positionY > destinationY)
positionY--;
else if(positionY < destinationY)
positionY++;

10

MSc Computer Science

In the above example the position of the game characters is specified by positionX and
positionY variables. The positionX and positionY coordinates are either increased or
decreased so that the game character's position moves closer to the destinationX and
destinationY coordinates. This is a simple and fast solution to a basic pathfinding problem
(David.M, Glenn.S, 2004).

Figure 2(b): showing basic path movement of pathfinding algorithm (David.M,Glenn.S, 2004)
The figurative version of the algorithm is shown above for better understanding of the
algorithm. In the figure the game character moves diagonally toward the goal until it reaches
the point where it is on the same x- or y-axis as the destination position. It then moves in a
straight horizontal or vertical path until it reaches its destination. As mentioned earlier there
are many variations to the basic pathfinding algorithms, these variations are generated
depending upon the usage situations of the basic algorithm in a particular game. Nevertheless
it is very much important to specify the basic algorithm of pathfinding.
The later versions of pathfinding algorithm generated in the process of refinement includes
the game characters dealing with obstacles in the way of axis and line of sight path
movements. The algorithms proceeded which are adapted on basic pathfinding have effective
methods of obstacle avoidance and wall tracing. The problem of way finding from an initial
point to desired destination on a map is a key problem in almost all computer games.
Algorithms which come under this section as a refinement process belongs to lower level of
games AI, serving as a base for generating more constructive and complicated intelligent type
of behaviour. Algorithms which are designed as a solution for the pathfinding problems are
differentiated individually according to the approach that the algorithm is following. The
simplest approach of the problem is to ignore the obstacle until the game character bumps in
to another. Overshadowing all the algorithms that came as a solution for pathfinding problem
11

MSc Computer Science

A* comes out to the best algorithm. The A* algorithm continues to reign as the preferred
pathfinding algorithm, although everybody has their own variations and adaptations for their
particular project. Every developer present who had needed pathfinding in their game had
used some form of the A* algorithm. Most had also used influence maps, attractor-repulsor
systems, and flocking to one degree or another (Woodcock, S. 2000).

2.4 A* algorithm
Pathfinding is one of the basic problems of game AI, inadequate problem will leads to seem
the game character unintelligent and artificial. A better handling of pathfinding problem can
make the game more enjoyable and immersive for the player. A* is one algorithm that fulfils
all these requirements.
A* (Pronounced A-Star) is a best established algorithm for general searching of optimal
paths. The A* algorithm is a venerable technique which was originally applied to various
mathematical problems and was adapted to pathfinding during the early years of artificial
intelligence research (Bryan Stout, 1999). A* is best in handling varying terrain costs well and
it is the faster in most of graph searching algorithm.
The basic algorithm, when applied to a grid-based pathfinding problem, is as follows: Start at
the initial position (node) and place it on the Open list, along with its estimated cost to the
destination, which is determined by a heuristic. The heuristic is often just the geometric
distance between two nodes. Then perform the following loop while the Open list is
nonempty:

Pop the node off the Open list that has the lowest estimated cost to the destination.
If the node is the destination, we've successfully finished (quit).
Examine the node's eight neighbouring nodes.
For each of the nodes which are not blocked, calculate the estimated cost to the goal of
the path that goes through that node. (This is the actual cost to reach that node from

the origin, plus the heuristic cost to the destination.)


Push all those nonblocked surrounding nodes onto the Open list, and repeat loop.

12

MSc Computer Science

In the end, the nodes along the chosen path, including the starting and ending position, are
called the waypoints. The A* algorithm is guaranteed to find the best path from the origin to
the destination (Marco Pinter, 2001). The typical formula version if the heuristic search
algorithm is expressed in nodes to find the best route, this heuristic search ranks each node by
an estimate of the best route that goes through that node. The typical formula is expressed as:
f(n) = g(n) + h(n)
Where:
f(n)

is the score assigned to node n

g(n)

is the actual cheapest cost of arriving at n from the start

h(n)

is the heuristic estimate of the cost to the goal from n

One of the more difficult parts in solving A* is creating a good heuristic function to determine
h'(n). A heuristic function differs from an algorithm in that a heuristic is more of an estimate
and is not necessarily provably correct. An algorithm is a set of steps which can be proven to
halt on a particular given set of input, the heuristic function in A* is arbitrary, however the
better the heuristic function, the faster and more accurate the solution will become. There lays
the problem, deciding a good heuristic. Even with a shortest path example, the heuristic can
change depending on the implementation of the search and how easy or complicated the
heuristic function is going to be.

13

MSc Computer Science

Following is a proper A* algorithm, some node may be proceeded more than once for finding
better paths.
A* search algorithm
Priorityqueue Open
list

Closed

AStarSearch
s.g = 0

// s is the start node

s.h = GoalDistEstimate( s )
s.f = s.g + s.h
s.parent = null
push s on Open
while Open is not empty
pop node n from Open // n has the lowest f
if n is a goal node
construct path
return success
for each successor n' of n
newg = n.g + cost(n,n')
if n' is in Open or Closed,

14

MSc Computer Science

and n'.g &lt;= newg


skip
n'.parent = n
n'.g = newg
n'.h = GoalDistEstimate( n' )
n'.f = n'.g + n'.h
if n' is in Closed
remove it from Closed
if n' is not yet in Open
push n' on Open
push n onto Closed
return failure // if no path found
A* search algorithm (Bryan Stout, 1999)
A* has a couple of interesting properties. It is guaranteed to find the shortest path, as long as
the heuristic estimate, h (n), is admissible-that is, it is never greater than the true remaining
distance to the goal. It makes the most efficient use of the heuristic function: no search that
uses the same heuristic function h(n) and finds optimal paths will expand fewer nodes than
A*, not counting tie-breaking among nodes of equal cost (Bryan Stout, 1999).
2.4.1 Limitations of A*
There will be cases where A* might not be used for variety of reasons, if the game is dealing
with some type of special case scenario. For example, if a clear line of sight exists with no
obstacles between the starting point and ending point, the A* algorithm would be overkill. A
faster and more efficient line-of-sight movement algorithm would be better. It also probably
15

MSc Computer Science

wouldn't be the best alternative if CPU cycles are at a minimum. The A* algorithm is
efficient, but it still can consume quite a few CPU cycles, especially if you need to do
simultaneous pathfinding for a large number of game characters. The more or less real-time
requirements of games, plus the limitations of the available memory and processor time in
some of them, may make it hard even for A* to work well. A large map may require
thousands of entries in the Open and Closed list, and there may not be room enough for that.
Even if there is enough memory for them, the algorithms used for manipulating them may be
inefficient (Bryan Stout, 1999).
One of the failings of the A* algorithm is that it assumes the terrain over which it has
calculated a path doesn't change, this is a bad side effect should the bridge you were planning
to cross get blown up by an artillery round. To solve this problem, some developers were
using D*, a dynamic A* variant tuned to handle changeable terrain, but none were happy with
it due to the CPU hit required to recalculate paths.
The possibilities of whether A* can be used or not will be discussed in the later part of the
document, along with some more considerations for using of better AI Technique in the
module NeverWinter Nights 2(NWN2).

16

MSc Computer Science

2.5 Artificial Life (A-Life)


A-life is one of the AI technique which is commonly used in RPGs in particular, this
techniques gives the developer a platform to interact with NPCs to do all the dozens of
mundane jobs which are vital for player experience. A-Life is an algorithm that is derived
from classic AI, to create lifelike behaviour and synthesized creatures within a video game
using AI building blocks and A-Life theory to create more natural in-game behaviour models.
A-Life is perhaps the most used and obvious techniques in the game. From Maxis's The
Sims to CogniToy's Mind Rover, developers are finding that A-Life techniques provide them
with flexible ways to create realistic, lifelike behaviour in their game characters (Woodcock,
S. 2001).

2.5.1 Defining Artificial Life


A-life techniques are common in robotic applications, and developers have adapted and used
them with great success in video games. Basically, an A-life system is a synthetic system that
exhibits natural behaviours. These behaviours are emergent and develop as a result of the
combined effect of lower-level algorithms. On basis and synthesizing the character A-life is
differentiated in to two categories

Strong A-Life (truly alive, synthesized life), and


Weak A-Life (not truly alive, but modelling lifelike behaviour).

Strong A-Life is something which is related to academic part and always deals with the realtime applications within the science felid, but where as Weak A-life is purely used for video
games purpose. A weak A-Life is used for modelling the behaviour of life-like characters
rather than creating a real life in an artificial world. Strong A-life can make synthetic life
possible and that weak A-Life only models life like behaviour (Guy,W, Lecky,T. 2008). A-life
is a young discipline and is still under development, more and more advances are made in the
A-life day by day.

17

MSc Computer Science

2.5.2 Usage of A-Life


A-life is to be considered to be one of the best RPG AI in the recent times. Unfortunately the
usage of this technique hasnt made its mark outside the RPG and creature style games genre.
These are only a few of the established game AI techniques which include scripting, rulesbased systems, A* pathfinding and some artificial life (A-life) techniques, to name a few that
are being used in RPGs. A good A-Life AI can make whole hordes of monsters and NPCs
behave realistically with very little CPU overhead, which gives the player the feeling of being
a part of a living, breathing world.
However, some subsets of A-Life technology have found their way into various games.
Several of the recent first-person shooters have used flocking algorithms to one degree or
another to handle the movement of herds of monsters, birds, fish, and so on. Some RTS games
were also making use of flocking variants for group unit movement, and at least one
upcoming space combat game (Babylon 5 from Sierra Studios) plans to make use of flocking
algorithms to control the movement of enemy fighter wings and fleets of enemy capital ship
(Woodcock, S. 2001).
The simplicity of this approach combined with the amazing resultant behaviours has proved
irresistible to a number of developers over the last few years, and a number of games have
made use of this technique. The Sims is probably the best known of this. That game makes
use of a technique that Maxis co-founder and Sims designer Will Wright has dubbed "smart
terrain." In the game, all characters have various motivations and needs, and the terrain offers
various ways to satisfy those needs. Each piece of terrain broadcasts to nearby characters what
it has to offer. The character is guided from action to action realistically, driven only by
simple object-level programming using A-Life (Woodcock, S. 2001).

18

MSc Computer Science

2.5.3 Implementation styles of A-Life


Moving further in to the details as Guy W, Lecky-Thompson(2008,p42) explained in their
work, the A-life has to undergo certain elements of implementation styles prior for a game to
be made in to A-life medium. Such as

Modelling
Calculated A-Life
Synthesized A-Life
Granularity

2.5.4 Modelling through observation


Applied A-Life is based on models that are derived from observation; A-life application will
not attempt to create an entire model that is designed to evaluate all the possible chain of
events that might produce from decision tree. Rather it is a less prescribed approach that
provides a framework for building blocks, which are eventually combined to form a larger
and even complex format of the model.

2.5.5 Calculated A-Life


A-Life implementation in some games is driven by calculations. The result of these
calculation leads to AI models, which then become an embellished embodiment of those
calculations. A-Life in this case is used to enhance the visibility of calculated results that
reflect the true measure of the players success in the video game universe. The behaviour
itself is not causal to the outcome; it just provides an intelligent (natural) interface to the
information in order to guide the player. A game such as SimCity, for example, can be
modelled as a series of calculations, with the result of each feeding into others, and the
behaviour of the system derived from that (Guy.W,Lecky,T. 2008).

19

MSc Computer Science

2.5.6 Synthesized A-Life


Synthesized A-Life is different from but related to calculated A-Life in that the evolved
behaviour is based not on calculations, but on a sum of parts that create the behaviour in an
unrestricted fashion. In other words, we have to allow the building blocks of AI and A-Life to
take the behaviour of each system outside of its initial bounds, and within the rules of the
game universe, it evolves unconditionally. If the player chooses to influence the game
universe somehow, we have to allow it to react to that interaction from the ground up,
whatever the consequences. That is one facet, another is the fact that when using synthesized
A-Life, we model at a lower level and replace the calculations with a direct outcome by fuzzy
logic, which arrives at a weighted conclusion, rather than a yes/no answer.

2.5.7 Granularity
The term granularity here means the level at which we are going to model the processes that
give rise to A-Life (be it synthesized or calculated). Granularity really needs to be designed in
from the very beginning; it is not easy to start at one level and move up (coarser) or down
(finer) during the actual implementation. It is, though, possible to layer different levels of ALife granularity (grain) as well as allow them to occupy the same game space. Some facets of
the game universe will be based on coarse granularity, while others will have fine granularity.

2.5.8 A-Life in Game development


Depending on the four implementation styles the use if A-Life in games are done. In the
development process the first ground rules in to layout the implementation process to model
the characters and then for the techniques that the A-Life has to offer to embed those
techniques in to the game. A-Life is used in most phases of game development process like

AI-Life in Design phase


A-Life in Development phase
A-Life in Game testing
A-life in Post development.

20

MSc Computer Science

2.5.9 AI techniques in A-Life


A-Life problem is not a one entity which is being used, but there are many A-Life techniques
that are also used basing on the parent theory. As mentioned AI used in A-Life to provide
actual behaviour and to militate the effects of A-Life paradigms. Guy W. Lecky-Thompson
(2008, p40) describes the ways in which the A-Life can be applied

Windows Dressing : which has no functional purpose but to make game look pretty
Simulation: Which has an impact on the flow of events in the game behaviour

Both ads importance to the game experience, but windows dressing has very few
consequences. As for the simulation are concerned most of the game developers tend to use
this as because simulation requires very less resources or the CPU cycles. Windows dressing
demands lot of pre-allocated resources to start with (graphics chips, powerful CPU systems)
to share the load. Looking at todays technological advances of hardware developers are more
inclined towards the windows dressing concept. Nevertheless the importance of simulation
methods is always going to be the same with more and more advances are made within the
simulation techniques.
A-Life uses all kind of AI techniques as building block- such as neural nets, finite state
machines, fuzzy logic, and daemon organization. Daemon organization, in this case, means
allocating specific algorithms to specific entities (daemons), which manage their interaction
with each other and the game universe while they carry out other tasks that are predetermined.
One of them which are worth mentioning for the sake of this project consideration is
Flocking.

2.5.10 Flocking A-Life technique


Often in the computer games or in particular RPGs, NPC characters must move in cohesive
group rather than independently. Flocking algorithm does just that, in flocking algorithm each
individual character in the system is modelled in relation to its peers, each character knows
how far it should stay form its neighbour, how it should react to obstacles. The most important
point in this algorithm is the behaviour of the character, if a group of NPCs are moving in a
flock then the behaviour of the first NPC should alert the consecutive ones and the appropriate
21

MSc Computer Science

action has to be taken to make the game real. The flocking algorithm doesnt need the
hardcode method of developer for each individual character, instead the flock will modify
them self to fit to the situation.

2.6 Background of Role Playing Games (RPG)


2.6.1 Introduction to RPGs
Throughout this document RPG is referred as Role Playing Games in general, Role playing
games (RPGs) stem from the popular Dungeons & Dragons paper based games that originated
in the 1970s. Over the past two decades the computer versions of these games have
metamorphosed from being mostly text based to the beautifully rendered, hugely involved
games available today. RPGs in general follow simple realistic formula: start with nothing,
perform tasks for money and treasure and often time power by mostly killing monsters and
performing quests in the terrain, train the character skills and eventually build the character
into a powerful figure.
RPGs are fairly AI intensive, mostly because they are usually expansive games. With varying
types of game play and many hours of gaming experiences per title, as such, the intelligence
of the varying game elements has to be higher than most because the sheer amount of hours
spent by the game player in the game will make any behavioural repetition much more
obvious, as well as making small annoyances s in AI behaviour appear larger (Brain.S, 2004).

2.6.2 Architecture of Games


A computer game is a king of application which uses the features of windows components for
the driver of the program. Windows enables event-driven programming which saves a lot of
problem without manually keep tracking of the controls and input interrupts. Therefore it
provides an excellent platform to run any kind of application. Game platform tempts to apply
traditional win32 components instead of MFC components because of tempting to run the
game program in a high speed and great performance. For graphics implementation, games
normally apply either DirectX or OpenGL for the development; Better game architecture
supports better game management, below figure describes the global game architecture that is
been followed in as a windows architecture.

22

MSc Computer Science

Figure 2(c): Figure showing Global Game software architecture Chow,y (2006)
In the figure mentioned the definition file, commonly called as Game Data is the main
component and depending on which the behaviour of the game, it also acts as a game database
resource. It controls game status and triggers all the other components to work. With the
supplementary of physics engine, logic engine, even handler and other conflagration parts
linked to this game data core. The entire system will then handles the game play. Simulates
the works and responds to the users input. The request is then passed to the hardware
abstraction layer for the input, graphics and audio handler and finally processed the hardware.

2.7 AI Techniques used in RPGs


RPG uses different kinds of AI techniques to immerse the gamer in to them, now a days
developers are using all kinds of AI techniques, some of the techniques worth mentioning and
which are best used in RPGs are scripting, Finite state machines(FSM), pathfinding. Scripting
and FSM are the good AI techniques that are being frequently used in RPGs.

23

MSc Computer Science

2.7.1 Scripting
Most RPGs are heavily scripted because most of these games follow a very specific storyline.
Scripts are used for a verity of game constructs, including dialogues, game events flags,
specific enemy or NPC behaviour. How the player can interact with the environment and
many others. The main reason scripting is used in RPGs is because the linear pattern followed
by RPG game designs. This type of pattern always works well with the scripting methods.
The scripting is done almost as a part of the game to play out almost exactly as designed. The
check points and flags embedded in to the scripts so that the player are forced to follow from
point A to point B, even if the player first wandered over the points C,D,E and F in the
meantime. In a generic sense the scripting is somewhat data based way of hard coding the
assorted events that come up during the overall story (Brain.S, 2004).

2.7.2 Dynamic scripting


Dynamic scripting is one of the subgenre of the scripting techniques which is most comely
used in the game industry world. The point with dynamic scripting is to develop an AI that
adapts itself from its previous experiences, which makes it flexible and enables it to modify
itself to behave well in situations of very different nature. This is desirable since the human
eye is very keen at discovering repetitiveness and will easily learn a deterministic AI's
behaviour, and the agent will therefore be very predictable. With dynamic scripting
(spronck.p.2006) this will be prevented and the illusion of the agent actually being
intelligent becomes reality.
So how does dynamic scripting work? In general it consist of a set of pre-programmed rules,
all connected with a weight and a priority. Some of the rule has a specific condition that has to
be met for them to be useful as well. Each rule can consist of one to several actions. The
number of actions in each rule is up to the AI programmer to decide depending on what his AI
should be used for. Fewer actions will result in a larger set of rules which in turn increases the
time it takes for the AI to adapt it and start yielding satisfying results. If you instead reduce
the number of rules and use your own knowledge of the environment to put together good
combinations of actions in each rule, the period it takes for the agent to adapt is shorter. For
games in general, the agents don't have so much time for learning and relatively smart
behaviour is expected from the beginning by the player. This might pose a problem when

24

MSc Computer Science

having many sets of rules and with an untrained AI. However, it can be solved by training the
agents through a learning period before the release of the game so that a sufficiently
intelligent behaviour gets achieved. Based on the conditions, priorities and weights a set of
these rules is picked to be used to achieve the agents goals. When a goal has been reached, a
fitness function evaluates how well or bad the agent performed, and based on the result of this
function, the weights of the rules are adjusted. Higher weight if the rule resulted in good agent
behaviour and lower weight if the agent performed badly. The new weights for these rules will
therefore be picked more frequently when being higher and less often if they worked poorly
Bertil Jeppsson(2008).

2.7.3 Limitations of Dynamic Scripting


While the non-determinism dynamic scripting delivers to the behaviour would be something
beneficial for the NPCs, it seems to be best suited for combat AI. This is since a player will be
very watchful and aware of an enemy's actions in a fight because it very much affects the
player and the game-play. For a non-hostile NPC however, it's quite different since their
actions doesn't affect the player in such an obvious way. Another drawback is that complexity
of implementing a fitness function to evaluate realistic behaviour of the NPC agents would be
very difficult.

2.7.4 Finite state machines (FSM)


A finite state machine (FSM) is an abstract machine that can exist in one of several different
and predefined states. A FSM also can define a set of conditions that determine when the state
should change. The actual state determines how the state machine behaves (David.M,
Glenn.S, 2004).

Figure 2(d): Figure 4 showing the Generic finite state machine diagram (David.M, Glenn.S,
2004).
25

MSc Computer Science

In the figure each potential state is illustrated with a circle, and there are four possible states
{Si, S1, S2, S3}. Of course, every finite state machine also needs a means to move from one
state to another. In this case, the transition functions are illustrated as {t1, t2, t3, t4, t5}. The
finite state machine begins with the initial state Si. It remains is this state until the t1 transition
function provides a stimulus. Once the stimulus is provided, the state switches to S1. At this
point, it's easy for you to see which stimulus is needed to move from one state to another. In
some cases, such as with S1, only the stimulus provided by t5 can change the machine's state.
However, notice that in the case of S3 and S2 two possible stimuli result in a state change
(David.M, Glenn.S, 2004).
Finite state machines are useful in RPGs just as they are useful in any other game. By using
FSM the developers have an opportunity to spilt the game in to particular states so that it
becomes easy to manage each state rather than managing the entire game. Especially when
debugging. Each state has explicit characters and will perform differently and manage these
with discrete code blocks.

2.8 Conclusion
This chapter described about the basic AI and Ai techniques that are used in game and in what
genre of games in particular. The main reason of this chapter is to figure out the appropriate
AI technique for the implementation in to NWN2, because not all the AI techniques will
support the requirements that are put up for this research. This chapter helped the author to
elaborate the research in the AI techniques area where he can search for the better AI
technique to implement which suits better for the research.

26

MSc Computer Science

Chapter 3: Methodology
3.1 Introduction
This chapter will discuss about the methodology and techniques that this project is going to
use in depth. Most of the discussion is related to the particular methods and implementation
process about the prototype. Basic methodology and the testing is a purely experimental and
the implementation is done using the documentation provided my NWN2 community forums.
The details of background information of the game NWN2 can be found in this chapter, and
also the AI techniques that are previously implemented in this game is also discussed in detail
with more stress on the flaws of the default implementation in this game.
As NWN2 is a RPG game which is originated from famous Dungeon & Dragon (D&D)
settings. An introduction about D&D settings can be found in the first section, it is very much
important to know the details of background of the NWN2 game as most of the concept and
methodology used in the NWN2 is barrowed from the D&D framework with some changes in
the story line of the game.

3.2 Dungeons & Dragons (D&D)


Dungeons & Dragons is a fantasy RPG originally designed by GaryGygax and Dave Arneson,
and first published in 1974 by Tactical Studies Rules, Inc. D&D departs from traditional war
gaming and assigns each player a specific character to play instead of a military formation.
These characters embark upon imaginary adventures within a fantasy setting. A Dungeon
Master serves as the game's referee and storyteller, while also maintaining the setting in which
the adventures occur. The characters form a party that interacts with the setting's inhabitants
(and each other). Together they solve dilemmas, engage in battles and gather treasure and
knowledge. In the process the characters earn experience points to become increasingly
powerful over a series of sessions
A Typical D&D game consists of an adventure which is roughly equivalent to a single story.
These adventures are generally pre-made adventures/Modules form the makers of D&D or it
can be created by the player. A published adventure typically includes a background story,
illustrations, maps and goals for a player to achieve. A linked series of adventures is

27

MSc Computer Science

commonly known as a campaign and the location where the adventure occurs is called a
campaign setting or in more general terms simply a campaign. One such campaign setting is a
forgotten realms or in the developers terminology the realms. NWN uses such adventurous
settings as its game theme. Some of the popular settings of D&D include Greyjawk,
Dragonlance, Forgotten Realms, Mystra, Spellhammer, Ravenloft, DarkSun, Planescape
The Forgotten Realms is one campaign settings that is going to be used in this project as the
NWN2 game uses same campaign setting as its core and basic platform game setting. Most of
the game used forgotten realms as their core settings previously, but NWN game is the one
which has enhanced the capabilities of this setting.

3.3 Forgotten Realms


Forgotten Realms is a campaign setting created by ED Greenwood in late 1980s, and has
grown steadily in popularity ever since. There are many popular computer games in the
present market which uses forgotten realms as their game settings. Some of the game titles
which used these settings and is been considered for this research purpose are

Icewind Dale
Baldurs Gater
Pool of Radiance
Neverwinter Nights / Neverwinter Nights 2

3.4 Choice of Neverwinter Nights2


NWN2 is a game provided with full of functionalities and lots of options embedded to extend
and enhance the capabilities of the game with a room to create new modules and campaigns
within the game. A user can create and modify the settings, campaigns and can create a new
module within the game using the toolset that they have provided. The NWN2 toolset is used
to all kinds of purpose to help the enthusiastic game users to create their own modules using
scripting methods. NWN2 is with rich abundant resources for scripting any kind of situation
of character in the game. The syntax if the NWN2 script is lot similar to basic programming
language like C and C++ .This is the main reason to choose this game as a basic platform to
implement discussed AI techniques.

28

MSc Computer Science

3.5 Research limitations


Due to limitations in time for this project, AI implementation is been subjected to only a
limited part of an existing commercial game NWN2. The concentration of research is mostly
done on a single aspect of the game, which is NPCs AI and behaviour in non-combat
situations. No combat aspects or AI techniques used in the combat implementation.

3.6 Neverwinter Nights2 (NWN2)


Neverwinter Nights2 (NWN2) is one of the famous Dungeons & Dragons (D&D) fantasy
worlds campaign settings. It uses the Forgotten Realms campaign settings that consists of
huge virtual worlds with different types of characters involved in them.
NWN2 is developed by Obsidian entertainment and published by Atari. It is a sequel to the
famous Biowares Neverwinter Nights based on D&D campaign setting. A player can choose
from different character that the game has to offer or the player can create one if he like to
play with a custom made character. It has different characters and those characters are created
according to the D20 rule system of D&D. The player then can participate in adventures and
gain experience levels. The party (a player in RPG) is able to explore various cities and towns
that are set in Forgotten Realms, along with competing monsters and completing quests [Duke
Ferris, game spot game guide]. The developers have provided a scripting toolset called
NWscript to help the gamers develop any kind of characters and the player can modify the
behaviour of the character along with the intelligence. The syntax of the NWscript is lot
similar to basic programming language like C. The game was completely developed by using
Electron an enhanced version of the original game engine Aurora which is originally used to
develop NWN.
The AI for NPCs is very intense and rich with intelligence in the NWN2, the combat
situations are very well characterised with the NPC emerging with different skills at each
time. As far as research done on this game for the purpose of this project, it is been discovered
that the Non-combat situation as poorly choreographed and need improvement to make the
game much more realistic to the user. This research is mainly based on the non-combat
situation where the NPCs involve in terrain part of the game. The idea of this research is to
enhance the skill sets of the normal NPCs in the game. To further extend the research it is

29

MSc Computer Science

need to know the basic default AI implemented for AI in NWN2 game. This help to build
more facts about the default game and also to know what other parts of the game is in need of
enhancement.

3.6.1 NPCs AI in NWN2


Knowing the working spectrum of default NPCs AI for NWN2 is important as this will help
to figure out the actions and the better techniques to be implemented if there are any defaults
in the original one.
Many games in this market are using state-machines to control the NPC AI by triggering their
action using different scripts to act accordingly at the point in the game or situation. This
process is generally considered as event handling (Steve Rabin, 2002). Based on different
state that the NPCs are currently in, the basic scripting action is done. This action includes for
example walking a path of waypoint around the town block. Another example is that the NPC
stands still and playing talking animation with even intervals simulating a conversation. In
some cases the actions are dependent on the story line of the game. In most case the event
handling behaviour of the NPC is specified to that area where the NPC are in and the
implementation of those kinds of behaviours in an NPC is quite simple. It is ok for a kind of
player who spent very less time in adventuring the place and more involving in the combat
aspect of the game, but it certainly is annoying to those players who like to interact with Noncombat NPCs and excavating the terrain.

3.6.2 Problem Identification in default NWN2 NPC AI


Most of the RPG games in the market to my knowledge have a decent set of AI built within
them along with well-structured challenges in combat situations. Mainly the AI for the enemy
is much more advanced in combat situations, which makes the game interesting and playable
for any average player who is playing the game for the first time or even a minimal number of
times (Matt Barton, 2007). Yet there is always a second side of the situation when you take a
closer look at the game, there is another part of the game which can be bit disturbing and
annoying to the player sometimes, more precisely non-hostile NPC that inhabits within towns
and villages and in the terrain of the game landscape. Whose behaviour is rather still and
static and only responds to the trigger based events in the game (i.e. when a player triggers the

30

MSc Computer Science

situation involving those NPC). When compared with the other game genre where the NPCs
AI much more advanced, the NPCs in RPG has very less projection of AI within them.
NWN2 when looked at the non-combat NPCs AI prospective is a bit low to its quality
standards that the rest of the game has setup. This research project is mainly concerned with
the non-hostile and non-combat NPCs AI and to bring out realism in the game by
implementing the AI for the NPCs which are bound to terrain part of the game.

3.6.3 AI Techniques to implement in NWN2


AI techniques which are discussed earlier in chapter-2 are more related to general techniques
that are being used in game and most importantly RPG games, but those techniques represents
the broader sense of a game. To help the research and to enhance the NPCs AI, some of the
techniques which are being considered specifically to deal with the terrain part and noncombat situations are being looked in detail, and are closely distinguished basing on the
purpose to suit for this research. Some of the AI techniques that are considered to implement
in to NWN2 game are as follows.

3.6.4 Consideration of different AI techniques


Some of the considerations of AI techniques for this research are dynamic scripting, Terrain
analysis, path finding, decision tree, state machines, Dynamic Scripting, Smart Terrain, most
of these techniques are found to be individual technique for particular kind of genres. Terrain
analysis is a very much a kind of a tactical technique where it will summon and control the
behaviour of the object present in the categorised location of a map (William.V, 2001). This
method is mostly used in Real Time Strategy games (RTS), where in it is used to control the
check points and control units of a whole military army. After a thorough research this method
is proved to be insufficient for this project. Terrain analysis demands and apply more AI on to
the combat situations in game where the NPCs helping in combat situations but not suitable
for the limitations and the conditions that this project is working. Where as in other hand
decision tree is another popular technique used in most RPGs, the decision tree technique
depends on the state machines and will be triggered if only the event is called and is more like
hardcoded process (Paul Inventado, 2006).

31

MSc Computer Science

Dynamic scripting is one technique which came close to being implemented in to this project
because of the flexibility this technique is offering in modifying the behaviour of an NPC. The
much elaborated discussion of this technique was explained in the previous chapter of this
document. Yet the non-deterministic scripting technique fail to satisfy the need of the project
when comes to the non-combat situations. Dynamic scripting seems to be more of a combat
AI; the player will be very watchful and aware of an enemys action in a fight because it very
much affects the player and the game-play. For a non-combat NPC however, its quite
different since their action doesnt affect the player in such an obvious way. This is one of the
reasons of ruling out dynamic scripting. And the other reason is being its complexity in
implementing a fitness function to evaluate the realistic behaviour of the NPC agent would be
difficult. After conducting different types of research on choice of AI technique the smart
terrain is considered to be best and apt technique to implement.

3.7 Smart Terrain


Smart Terrain is the technique first implemented in the Sims, a popular AI game technique
developed by Will Wright (Maxis, 2000). Smart Terrain is a technique which belongs to the
AI categories to make the environment smarter rather than making the opponent smarter, in
this way the player would experience the realism of the game and will not be annoyed by the
traditional still animation implementation of the NPCs AI in the RPG game genre (Rabin,
Kirby, 2002). Smart terrain discards the character-oriented approach to reasoning using
artificial intelligence and embeds the behaviours and possible actions associated with a virtual
object within the object itself. Smart Terrain is used to perform navigation in complex tiled
worlds, like for instance in the game Sims what is happening beneath the surface is the
character have needs such as hunger, and objects in this world meet those needs for instance
a refrigerator with food. Clearly characters in this world should move to objects that meet
their needs. All a character has to do then is just follow the signal to the object, the main idea
of Smart Terrain is that instead of characters searching for objects that meet needs, objects
transmit a signal that says I meet this need. The Sims AI creation is really simple to work;
it is all dependent on the game programmer to develop a code about what the AI has to decide
on the players need and how to get the nearest object to satisfy the needs (Maxis, 2002).
This approach allows new objects which can be inserted into the game at any point, either as
an expansion pack by game designers or using content creation tools by players. Achieving
32

MSc Computer Science

adaptability using this approach, however, requires character behaviours to be explicitly


programmed in each new object. This requires development effort from game designers and,
while compelling for some gamers, is too difficult or simply uninteresting for others.
Expansion packs and content creation tools in general are approaches by which game
designers have attempted to extend the lifetime of games by extending or allowing players to
extend the original game through the addition of new content. Game in which open-ended
modification of the game world is allowed while the game is in progress has the potential for
a longer lifetime though the provision of more open-ended game play.
Implementing the Smart Terrain technique in to the RPG game, in this case NWN2 is a bit
lengthy process when considered the whole game, which is the reason I am focusing my work
only on modelling the NPC behaviour so that the game experience feels real to the game
player.

3.7.1 Analysing Smart terrain


On further research the consideration of implementing Smart terrain technique in NWN2 is
justified when looked at the NPCs prospective especially in non-combat situations. The
concept originally implemented in The Sims is very realistic and more appealing to the users
especially; smart terrain implemented in The Sims tends to be a major point in the success of
the game. On a whole according to the research done for this project smart terrain is
considered as the best when taken NPCs in to account. When it comes to implementation of
Smart Terrain in the NWN2 engine technically, the event handling feature of it is used, the
NWN2 engine provides the developer with an event handling system that can be used for
different purposes and at different instances of the game development. Entities in the game
worlds are instructed by a set of default events that they listen to. And as a developer one can
assign each of these events with a script that should be called if that specific event is
triggered. In addition to the default event a developer can also implement custom event types
with corresponding event-handling procedures among the entities that are intended to listen
for the specific events.

33

MSc Computer Science

3.8 Smart Terrain in NWN2


To make the NPCs act more realistic in nature the smart terrain in the one concept which can
be used, basically the idea of implementing the NPCs as follows

The NPCs in the terrain is provided with a set of basic need to be satisfied and these
needs will increase from time to time depending on the work that the NPC is

performing.
Let every NPC to fulfil its currently highest need by listening for ht events from
nearby objects in the terrain that offers services that helps that satisfies the specific

need.
The object which satisfies these needs of NPCs is called Smart Objects. And they are
responsible for broadcasting events to all NPCs in their corresponding area about what
need they it can satisfy.

Below Figure shows the picture format of the method that is going to be implemented.

34

MSc Computer Science

Figure 3(a): Figure showing the smart objects broadcasting to its nearest NPCs in the terrain.
As discussed each Smart object will broadcast to its nearest NPC about what needs that it can
satisfy. This is where the On-Spawn and On-Heartbeat event comes in to picture. On-Spawn
event is where the NPC generates starting values for its needs and desires. Now that every
NPC is provided with its basic needs, the needs also have to be updated and increased by
time. This is done by the On-heartbeat event handler and it also evaluates which one of them
is at highest priority.
When the NPC receives the smart object event broadcast. The NPC has to check whether the
broadcasted received can satisfy its highest match in their priority list. Once and event of
satisfying match is received then the NPC has to move to the location where the smart object
is situated to interact with the smart object and fulfil its needs and move on to the next task on
its priority list. Below figure will describe how the NPC will interact with the Smart Object.

Figure 3(b): Figure showing the interaction of NPC with Smart object
During this process of NPC interacting with the smart object. The NPC has to choose the best
path to find the smart object. When an NPC has found a smart object to satisfy its highest
need, it has to get there. Getting close to the destination is crucial if any interaction is to be
35

MSc Computer Science

made since the need can't be satisfied without interacting with the object. Note that normally
in games, this would just involve a pathfinding algorithm like A* mentioned earlier in chapter
2 to find the closest path to the destination. However, is that really the most realistic way for a
citizen to move to a location? Of course, taking long detours is not realistic, but if the closest
path to the destination involves walking across some, for the public forbidden area. Or
perhaps crossing a muddy and dirty path that none would cross unless the NPC really had to.
To appear realistic the NPC should follow the city's roads until it reaches the destination, so in
this approach it a bit different. The game engine used in this work is only providing a
pathfinding algorithm taking the shortest route to its destination without considering the fabric
of the ground beneath. Therefore using a combination of the pathfinding and waypoints to
mark out the roads of the city seemed like the best way to be able to simulate how a citizen in
a town moves between two locations realistically.

Figure 3(c): The figure showing how an NPC can achieve realistic movement through
waypoint consideration by reaching its destination through following the waypoint traces
which can be embedded in the script. Hear in the figure two NPCs heading towards different
goals. The line between the waypoint marks the path each of them will take. The black dot
mentioned in the figure depicts the waypoints.

36

MSc Computer Science

3.9 Event handling in NWN2


Event handling is most important part of NWN2 scriting. Using the methods that is been
developed in the default game engine a new module can be developed and to trigger this
methods at different points of the game an event handling procedure is used.
The Electron engine which is a default engine for NWN2 provides with an even handler
system that can be used to categorise different events that occur in the game design. Entities
in the game are possessed with a selection of specific events that they are called for. A
developer can assign each of these scripts to the events that they listen to when a particular
event is triggered. The kind of events the entities listens for depends on the type of entity. For
example a door has On-Open event which is specific to doors, while a creature has OnPerceive events which is based on their abilities to see and hear thin.
In addition to the default events built in to the engine. Custom event type within the
corresponding event-handling procedures among the entities that is intended to listen for that
specific event can also be developed. The most important event among the default event types
for the smart terrain AI implementation is the On_Heartbeat and On_Spawn events.

On-Spawn: On_Spawn event is an event sent when an entity is to be created.


On-Heartbeat: On_Heartbeat event is an event that is signalled to every object in the
game-world with constant interval. Except for those the AI that was implemented is
using custom made events for the different needs that NPCs has.

3.10 Waypoint implementation in pathfinding


The hybrid between waypoint and A* pathfinding is much beneficial in more ways as this
gives the option of optimizing the search space. Waypoint can be used to optimise the search
space and it can also breakdown one big search space in to a smaller one so the NPCs will
easily guided to Smart objects. Waypoint helps the NPCs to decrease the search space and
choose optimal path to the destination point. Below is the figure which represents the
pictographic form of the hybrid between waypoint and default A* pathfinding algorithm.

37

MSc Computer Science

Figure 3(d): Figure showing the decrease in search space using waypoints in combination
with pathfinding opposed to just pathfinding over the entire distance.

The black dots in the figure represent waypoints


A: Search space of pathfinding without waypoint
B: Search space of pathfinding with waypoints
The line connecting the black dots(waypoints) is the optimal path from the start to
destination

The combined effect of waypoint and A* will pull out the realistic features in the NPCs
behaviour. The final step is to make the Smart object fulfil the needs of a NPCs, the Smart
Terrain technique has rich in behavioural animations according to the situation.

3.11 Conclusion
As explained earlier in this chapter the procedure will be implemented in the game with the
help of NWN2toolset. This toolset is provided as a developer console from the original game
developers.

38

MSc Computer Science

Chapter 4: Implementation
4.1 Introduction
This chapter describes technical details of internal working of NWN2 toolset and
implementation of smart terrain in to NWN2. The implementation part for the methodology
that been discussed in chapter-2 will be explained. The basic scripting methods and handling
of script using NWN2 toolset will be discussed in detail. NWScript is main scripting tool
which is being used to develop this prototype.

4.2 Use of prototype instead of actual AI artefact


Further in the process of research it is been discovered that the total implementation of this
project with actual AI handling in the NWN2 game is lengthy and more complicated than
expected and the time scale given in the gantt chart for this project is not sufficient for
development of a complete artefact in this game. The main reason being the scripting methods
are very new and the functions that use these scripts are custom made from the NWN2
developers. There is no proper and enough documentation for the scripting methods as much
as the documentation present for handling of the toolset in the NWN2 forums. And to learn all
the pre-made methods and to implement takes long time and there is no enough time to
implantation part.
After through research on the implementation part of the game design and toolset it is decided
to be best to implement the prototype of the methodology that is being discussed previously.
The prototype implementation will contain all the features that are explained and the
methodology that is followed in this research, the main difference being the actual usage of
the AI technique in game scripting instead going with hardcode waypoint implementation. To
make the user understand the concept of the NPCs doing certain tasks in the terrain using
waypoint graphs which is used internally in the toolset to make the NPCs move and act more
naturally.

39

MSc Computer Science

It is been said previously in the document that the hardcode methods is not the best way to
implement the NPCs AI and doesnt really have much realistic behaviour, but for the sake of
this project it is too left no choice than hard coding the NPCs AI and explaining the process of
how the AI should be in NWN2 game and what effect will be there on the user after having
interacted with the prototype. As this project is mainly dependent on the users feel and
experience, the prototype is developed to extract the feel and to calculate the realistic effect of
user in how he felt about the NPCs being real in the game. The prototype will feature all the
factors that are needed to fulfil the methodology and the concept and will answer the research
questions that this project is working on.

4.3 Environment creation and editing


The prototype for this project is developed in NWN2 toolset which is default toolset given by
game developers along with the game to help enthusiastic game users to create and develop
new modules and campaign settings within the game. The interface will provide the basic
functionalities of create buildings, terrain, script encounters, write dialogues, create quests and
items which can be used within the environment. The Toolset is a graphical tool for
generating a computer role-playing adventure that can be played using the NWN2 game
engine. It is installed as a standard part of the game package and can be launched from the
game start up interface.
Version 1.0.1765.0 is utilized to develop the environment in the toolset and it is patched
version from bioware, with Windows 7 operating system as the system platform.
In the toolset a module is developed initially to position the entire game world and the
characters in to it, a completed game can range from a single module with a handful of areas
up to an extensive campaign spanning multiple modules and many areas. Each module
contains a set of interconnected areas that can be traversed by a party of characters, as well as
the various area contents, interactive creatures, visual and auditory effects, and the scripts and
triggers for processing events. The construction of an adventure requires understanding the
toolset's features and functions. For the purpose of this research an exterior (terrain) area is
created in a module This area is an exterior area which is developed in a plane terrain to make
the NPCs move comfortably and also to make the new users understand the game world

40

MSc Computer Science

perfectly at the first sight (see figure 4(a)). All the characters that are used in the toolset are
designed using character design plug-in which is one of the features of the toolset editor.

Fig 4(a): figure showing the initial game module that is created to incorporate all the
charterers in to the area.
An exterior area in a module generally comes with laid out grid surface with definite
dimensions that are set up during initialization. The surface of area is well edited with
textured terrain and tiles, various structures at places that is required to generate the feel of the
module. Exterior can generally have obstructing terrain features and obstacles that channel
movement, while interior area uses walls and doors to control flow within the game.
The area toolset is well equipped with the environment editing features that are helpful to
maintain the look and feel of the game. The appropriate music is selected for each and every
character in the game. The property of the area is properly selected to bring out the effect of
the terrain environment using the area editor. (See figure-4(b)/ Figure-4(c)). It is very much

41

MSc Computer Science

important to maintain the look and feel of the game using the environment, it environment
may not be a important factor for the player who have already played RPG games before but
as this research is also emphasising the result based on non-game player or first time game
player. It is very much needed to maintain the environment realistic in nature.

Figure 4(b): Figure showing the properties of the module that is created.

42

MSc Computer Science

Figure 4(c): Figure showing environment inside the game.


An area can contain various hidden triggers and waypoints that are used to control the special
aspects of the game flow this trigger is a region that activate certain events when the player
enter. Such as revelling new maps notes or spawning a group of creatures to do battle. Area
can also have carious audio and visual effects to provide a suitable atmosphere. Typically at
least one location in an area serves as a transition to a different area. These transition points
can be the door to a structure or a determined another location. This option is mostly used in
all the game. But as this module is only focusing on one single module and area this feature of
area teleportation is ignored.
The NPCs and the smart objects are created as discussed in the methodology as a part if
implementation. The properties of the smart objects are changed accordingly to suit the
implementations, because the default structures that the toolset provided wont support the
framework for smart terrain implementation. The main property of the smart object is to
signal the nearest NPC about the need it can fulfil so for this feature to execute the default
property of ON_Heartbeat is changed to suit the requirement to signal the nearest NPCs (See
figure 4(d))

43

MSc Computer Science

Figure 4(d): Figure showing the NPCs camp and the nearest Smart objects which can fulfil
the needs of NPCs.

4.4 Conversations
Once the environment is properly laid out to get the exterior feeling in the game the next step
is to make the NPCs interact with the player. The interaction is basically done using
conversation interface in the editor. A conversation consists of a branching tree of dialogue
strings that are used to perform social interactions with creatures or objects in the game. They
can be used to yield information to the players, to provide personalities to the various
inhabitants, initiate trade and to control the plot. Within the game, a conversation is typically
displayed using a cut-scene interface that shows the alternating speakers at varying camera
angles.
Most of this project made use of conversation script to explain to the user about the game and
the idea of NPCs interacting. As because of this implementation is a merely a prototype is it
decided to be beneficial to the whole implementation if the conversation scripting is used
whenever a NPCs is interacting with an object or whenever the player is interacting with the
NPCs.
44

MSc Computer Science

A conversation cut scene will pop up whenever a player interacts with the NPC that is mapped
with the conversation script; a cut scene can have a questioned version or just information that
is useful for the player. A conversation structure can be drawn within the conversation script
between the player and the NPCs in the area and specific actions and default conditions are
inserted in to the module (See Figure 4(e))

Figure 4(e): Figure showing the conversation script between Player and NPC

45

MSc Computer Science

Figure 4(f): Figure showing in-game conversation between the NPC and player
Question nodes format is utilised in the situations where there is a question node required, and
a specific animations and action nodes is selected at the particular instance where the NPCs
has to perform some action at the point of time in between conversation. Lip-sync is one of
the features in toolset where the player or NPCs will do lip-sync when the cut scenes are
playing. This functionality is also used in the conversation panel of this module.
In the game mode normally a player cannot see what is going on in the backend with the
NPCs, what are they doing at the point, or where are they going. To make the player
understand all this process involved in this research over head conversations are used (see fig4()). And also a message is displayed in the debug panel whenever an event is occurred like
for instance if the NPCs have found a smart object then it will give a message in the debug
panel. This functionality is done using the triggers in the area. The triggers are designed in the
area such that is the player enters one particular area that is flagged as a smart object area then
the NPCs has to send a message to the debug panel that they have found the smart object and
they are about to satisfy their needs(see figure 4(g) / 4(f)).

46

MSc Computer Science

Figure 4(g): Figure showing the debug message sent by the NPCs when they found the smart
object in the area and the needs have been satisfied.

Figure 4(h): Figure showing the debug message sent by the smart object when it is performing
the signalling task to the nearest NPCs in the area.
47

MSc Computer Science

Figure 4(i): Figure showing the NPCs overhead message about his need at that point of time.

4.5 Scripting custom events


Some custom made scripts are written to support the NPCs pathfinding and also to make the
smart object broadcast the needs that they can satisfy. All these custom made scripting is done
in scripting language. As explained earlier the toolset has a built-in programming language
that allows detailed customizing of a module by means of scripts. A script consists of a series
of commands, variables and programming logic that can perform various checks of the game
state, change the state of the game, or return a result. Scripts can be used in conversations to
check whether a particular condition is true and to make various modifications to the module
or campaign. Scripts are also used to process various events, and to control the behaviour of
creatures or objects during the game.
A sample script showing the trigger based event.
void main()
{
object oPC=GetEnteringObject();
FloatingTextStringOnCreature("Hello Welcome to BC", oPC);
}
48

MSc Computer Science

The above script will give a message when player is entered in to area. To make this script
work, it has to be linked to the scriptonenter event in the properties panel.
At first in the process of implementation the NPCs has to raise some basic needs that should
be fulfilled by smart objects. These needs should be updated at every instant depending upon
the rate at which the needs are fulfilled by smart objects after the NPCs interact with the smart
object. To do this the NPCs attributes are listed with some basic needs like hunger, energy,
and faith, these needs are updated by using a default repetitive attribute called heartbeat this
heartbeat attribute will raise the flag of each attribute at every 6 seconds or after one need is
fulfilled.
Next the smart object have been given some basic need flags(Hunger, energy, faith) that they
can satisfy and their objective is to broadcast those needs to the nearest NPCs that are present
in that area. To broadcast the needs from the smart objects at first the smart objects has to
locate them self in the area, locating the smart object will also helps the NPCs to find the path
quickly. This is explained in the next section in brief. When the Smart object signals their
particular needs, the NPCs have to listen that broadcast and find the shortest way to that smart
object which it had listened to. The NPCs basically doesnt have listening attributes by default
in their properties. Some speak triggers have been used for this purpose. Basically a trigger
acts as an ignition for any event that is linked to that action. In the next scenario the NPCs has
to choose the best path to go to the smart object which are called for. Some default waypoint
mapping is done in the area to guide the NPCs to the smart objects, it is also used to help the
NPCs to stay in the boundary of the region and to find shortest path within the waypoints
boundary.
As discussed earlier there are some areas in the module where it needs scripting and one of
them was at the point where the smart objects has to be found in the terrain and the NPCs has
to move to them to get their need satisfied (See appendix). Another script is also written for
the heartbeat event to broadcast the smart objects need to the nearby NPCs (See Appendix B).
Both the scripts are triggered using the triggering methods when the NPCs are spawned in the
terrain. Following are the some of the scripts that is been written for the purpose of this
project, the requirements that these scripts satisfies is also mentioned, for more information on
scripting refer appendix B.

49

MSc Computer Science

custom_area_enter.ncs: This script is written to locate the smart objects in that location/area
and storing the nearest waypoint for this smart object, so that it will be easy for the NPCs to
find the smart object rather than NPCs wandering around the terrain aimlessly. This script is
called when all the objects in the area is spawned for the first time. Once the nearest waypoint
is stored in, then its up to NPCs script to find the shortest route for the particular waypoint
that is been flagged as a nearest to the smart object.
custom_area_heartbeat.ncs: This script is written for the purpose of heartbeat event (a
default event in the NWN2, which will execute at every 6 seconds). The custom heartbeat
script is utilised to signal the events of the smart object in the area to the NPCs so that the
NPCs could satisfy their needs. This script is included in the OnSpawninscript event of the
default NWNscripts so that this script can be used to all instances of the smart objects if
created any in the area.

4.6 Conclusion
The implementation of the prototype was a successful with respect to the author. There are lot
of issues that was raised in between the implementation which are discussed in the critical
evaluation section of the document. Most of the implementation of the methodology was done
as a prototype and the will be explained to the tester before he/she test the implementation in
the form of texts in the game. This is because of lack of time and the short span for
implementation cycle, all necessary precautionary measures and taken before the
implementation is going to testing phase.

50

MSc Computer Science

Chapter 5: Evaluation and testing


5.1 Introduction
This chapter will explain the analysis and evaluation of the complete product and the testing
analysis of the implementation. At first a diagrammatic view of the analysis is shown for
better understanding of the implementation that is been done for this research. Later in the
section product and process evaluation is done. For the product evaluation the aims and
deliverables are reviewed. The strengths and limitations of the project are also discussed.
In process evaluation it is discussed how the deliverable has been made. This basically
includes the project planning and management, also explanation is given about what has been
done to find the solution of the research questions that ultimately leads to the achievement of
the main aims and objectives of the project. At the same time it is demonstrated how this
process of doing MSc project has given a thorough understanding of not only the main topic
of the project but also helped to acquire skill set personally.
In the next part of this chapter testing phase is explained, which involves the testing methods
and analysis of the questionnaire which is conducted for the sake of testing the
implementation that is developed. After analysing with the result the final verdict of the
project implementation is prepared.

51

MSc Computer Science

5.2 Analysis & Evaluation


The analysis of this system is depicted in a diagrammatical format shown in figure 5(a).

Figure 5(a): Figure showing the diagrammatical format of the analysis and implementation
done for this research.
The above design shows the main resource used (NWN2) for the development of the
prototype and also what are the techniques and tools that are used to produce the final
module/ area as output for the user to test the implementation.

5.2.1 Product evaluation


The main aim of this research is to enhance the realism in the RPG games by enhancing the
behaviours of an NPC using smart terrain. A prototype which is developed according to the
author is a better way to demonstrate the effect of realistic behaviour of NPCs though there
are many issues raised in the process of implementation which is discussed in the later section

52

MSc Computer Science

in detail, but on whole the implementation is a successful projection if AI of non-combat


NPCs. Although the complete result of the product is evaluated after testing of the
implementation by the user. As this research is depended on the user experience the results
evaluated from testing are the pointer to the success or failure of the research.
The deliverables which are set for this research are achieved with respect to the author
prospective with the little change in the implementation part, as told previously not the
complete AI implementation is done but a prototype is prepared to demonstrate the effect and
the user is informed about the changes and the tasks that the NPCs are doing by text form in
the game.

5.2.2 Process evaluation


This research is aimed to determine the effect of realistic NPCs in the non-combat situations
and the realistic behaviour of the NPCs is necessary to achieve the experience in the project.
Most the time spend on the research is consumed on the research about the AI techniques that
can be implemented in to the NWN2 Module, Because only NWN2 game provide the open
editing toolset where the player can edit the game characters and develop their own module.
And also the author on his research have observed that the NPCs in the non-combat situations
and the terrain part arent well equipped with the AI that they needed, the graphics and the AI
in the combat situations or when the player is participating in a fight is very good and there is
no need of the improvements in that area. To make a game successful and interesting to play
for the end-user the game has to provide the effect of perfectness in all respects and all angles
of the game
In the methodological section after evaluating all the current AI methods the author have
decided to go with smart terrain procedure as this is a well known procedure which is
implemented in the Sims, and also as The Sims game is pretty old game which is developed
long back as a result the author could find the sufficient documentation on the smart terrain
part and the ways and methods it is implemented. To be specific the complete methods of
smart terrain is not followed in this research, instead a part of the concept of smart terrain is
utilised like the concept of generating the needs for the NPCs at constant interval depending
on the work that the NPCs are performing at the point of time. Once the smart terrain concept
is finalised the methods of pathfinding is researched as the NPCs has to choose a path to

53

MSc Computer Science

follow and reach the smart objects in the area. Unfortunately by default the NWN2 toolset
fallows A* algorithm as its default pathfinding algorithm for the NPCs so, to make the NPCs
more intelligent the concept of waypoint finding is researched which is a part of basic
pathfinding algorithm. This method of waypoint finding will find the shortest path.
More time is spent in AI implementation and the procedure of the implementation in the
NWN2 and the custom made scripts that are need to achieve the deliverables of this research.
As because there are no enough documentation provided by the game developers on the
scripting methods and the NWN2 toolset the author have decided to go with the prototype in
which he explained about the effect of NPC behaviour by using the hardcode methods and
animation procedure. The author has to depend merely on the forums created by enthusiastic
game players to do the custom made scripts and the user generated forums are not always
worth depending for a project. The time factor effected the development of the
implementation as there is a very limited to research and learn the new scripting language.
The author has to learn all the custom made methods and events merely depending on the fan
forums.

5.3 Testing
In the final phase the working version of the smart terrain AI in a NWN2 module is tested.
Before going to testing a self-evaluation is done and the implementation is finally checked for
any functionality issues. A group of twelve people has been selected depending on their
experience of gaming and experience on RPG games in general from university of
Wolverhampton and international students at the university. However some of the people that
are selected have varying experience previously in RPG and NWN2, and some of them
havent got any experience in game. This is because as this research involves the user
experience measuring. It is been considered best to select a couple of non-game experience
persons, so that the results of the outcome will be precise to fulfil the aim of this research.
The layout of the test consists of five sections; all of them are well advised to the tester,

In the first section the tester gets an introduction about the NWN2 game and the
intension of this research to make the tester understand the purpose of the research and
to let them know of about what they are going to do and in what circumstances.

54

MSc Computer Science

In the second section the tester is informed of what part he is going to test in the game
specifically and what does he have to observe in the test, though there are some
questions related to the test at the end of the testing phase, but still it is the better

practice to let the tester know about what he is going to test in this module.
In the third section the tester is been given a quick tutorial to inform the tester how to
proceed between the different steps in the game and what are the game functionalities
and key combinations to navigate between the characters and the worlds that they are
dealing with, this will help the new players to know about the game architecture and
functionalities in the game so that they can test the module properly without hassles

with the game key combinations and camera angles.


In the fourth section the tester is dropped in a default module of NWN2, and is asked
to feel the games AI and notice the effect of NPCs AI in the non-combat mode. With
this the tester will get a better idea of what the default implementation is and he could
be able to compare the AI with the one which is developed for this research. Once he
has completed exploring the default module then the tester is handed over a
questionnaire set-1 to answer some questions relating to the experience that he/she has

in the default NWN2 module(see appendix B)


In the fifth and final section of the testing phase the tester is dropped in the developed
module/area. At first he is asked to feel the environment and then he will be asked to
observe the NPCs AI. If he is not satisfied with the work of NPCs then the tester will
be again sent to the default NWN2 module as a final check with his/ her consent. And
again he will be dropped in to the developed module to test it for final time.

Once the tester has completed testing the module, then he is handed over a final questionnaire
set-2 to answer some questions relating to the experience that he had in the developed
module. While this might limit the testers form answering the questions with their own exact
words. It makes it easier to draw conclusions from the results. Since the author of the research
was present during all of the rests, oral results for additional responses, alternatives has been
taken and added if needed at the time of testing.
One part of the questionnaire aims to first categorise the test subject depending on his/her
background with RPGs, and also to make the subject experience the effect of NPCs in the
default module. This is because background might have an impact on expectations as well as
impressions of realism and thereby might affect the results slightly. And also to make the

55

MSc Computer Science

subject get acquainted with the game if he/she hasnt got experiences with the game
previously.
The second part of the questionnaire will be rather direct and pointed to the experience of the
tester with the new module asking him/her the different aspects if the NPCs behaviour
compares to the original NWN2 NPCs. Finally the tester gets to say whether he/she fins the
smart terrain AI more realistic than the original campaign.

5.4 Result Analysis


With the final version of the Smart terrain AI implementation and the test could begin. The
total number of testers involved in this research is 12 people and all of them are selected from
university of Wolverhampton and international student. The choice of testers is such that six
of them havent got any experience and 6 of them have got moderate experience varying in
RPG genre in particular. Both the groups (six nongame players, six game players) are tested
individually for this research. Figure 5(b) shows the bar chart diagram of the players
experience differentiating between game players and non- game players. The y-axis represents
number of people involved.
In the figure the testers who have played the game before have showed the moderate interest
in the original game AI, and the testers who havent played the game before have showed a
high level of raise in the original game AI before having to look at the developed module for
this research.
In the second figure the pie chart (see figure 5(c)), the figures showing all the testers
expressing their uninterested over the original campaign of NWN2, about 75% of all the
testers agree that the original campaign lacks AI in NPCs. but where as in the other pie chart
in the same figure all the testers have agreed that the smart terrain has a better AI
representation of NPCs in the game. The number of test subjects however was relatively small
which can be the reason for those results. If a larger group of people was tested there might
have been a slight difference in the ratios figure 5(c).
To get better understanding of the test subjects exact impression of each of two version of Ai,
they were also asked to rate them with a score in the range of one to ten, after having seen

56

MSc Computer Science

both the versions they got to rare the original NWN AI as well as the smart terrain AI in that
order. The result of this is illustrated in the figure 5(d).

57

MSc Computer Science

Figure 5(b): Figure shows the bar chart of the results that obtained from questionnaire.

58

MSc Computer Science

Figure 5(c): Figure showing pie diagrams of all the testers on NPCs AI.

59

MSc Computer Science

Figure 5(d): Figure showing the AI comparison between both the AIs
The graph illustrates where the testers put their votes for the two version of the AI. The Y-axis
marks the number of testers, and the X-axis represents the score. The local maximum values
represents where most of the testers put their scores. It means to give an indication of the
average opinion of testers as a group.
In the above figure we can see how the smart terrain AI overall have been rated higher in
comparison to the original campaign one, the curves maximums represents in the average
score rating from the testers as a group for the two, and a clear difference can be read from it.
It appears from it.

60

MSc Computer Science

Chapter 6
6.1 Introduction
In this chapter the author is going to discuss the critical evaluation part of the research and
also the answers to the research questions that are set up for this research, the change of
research implementation is also mentioned backing up with the reason of development of a
prototype instead of an actual artefact. The time schedule changes are also discussed in this
section, thereafter concluding the research project.

6.2 Critical evaluation


Basically this project refers to improvement of AI in NPCs in particular and a module has
been developed to achieve that. Initially the aim of the research is to develop a fully fledged
artefact, but instead the author have decide to go with a prototype, because of the complexity
of implementation of scripting language that needed to be learned to complete the project
which cannot be done in the time scale that is mentioned in the Gantt chart for this project,
instead a prototype can be done in place of that which can show all the functionalities and
methodologies that is put up for this research. The scripting language which is used in NWN2
is a custom made scripting with syntax reference from C++, C. But all the default functions
which are used in the scripting are completely different. Due to changes in the original
implementation the results which extracted though testing might not be as accurate as the one
with actual implementation of artefact and is slightly varying. Nevertheless the outcome of
the tester is explained and the testers are more inclined to the realism in the game which is
proved.
To suit the new prototype that is developed in place of an artefact, the main research aims and
deliverables are changed a little bit keeping the research questions intact as they still can be
measured with a prototypes output. The main changes are made in the implementation
section which the author previously told that would be done using a NWN scripting. But later
after the literature review, it is been discovered that its complicated than expected to do

61

MSc Computer Science

complete scripting in scheduled time. The change in the implementation procedure is been
informed to the authors supervisor.
Original deliverables

Improve realism in RPGs through enhancing the NPCs AI using Smart Terrain

technique.
Implementation of Smart Terrain technique in NWscript, which is a good scripting
tool for NWN2.
Altered deliverables
The second part is mainly altered to suit the new implementation process. And the new
deliverable is

Implementation of Smart Terrain technique in NWN2 Toolset and demonstrate the


effect of NPCs AI in the game.
The author have also faced difficulty in finding the relevant AI techniques in the literature
review part, the research took very long time in deciding the relevant AI technique that can be
used in this module. The smart terrain is a concept which hasnt got enough documentation
for its own. The author has to take reference from many books and articles in which there
were only bits and pieces of the smart terrain concept. The game Sims which used this
concept as its basic AI platform techniques havent released and official documentation for
the AI technique. All the author can find was about the game and the game methodologies in
the official websites of the game developers (The Sims), but not about the AI techniques.
The provisional project management schedule was designed originally in the proposal
documentation; it was thought the project management would go according Gantt chart in
figure 6(a), but the literature review on AI possible AI techniques took a long time than
expected and because of this there was not enough time to learn the scripting language which
is a custom made for NWN2 game. The new Gantt chart can be seen in the figure 6(c).

62

MSc Computer Science

Figure 6(a): Figure showing provisional Gantt chart

Figure 6(b): Figure showing specifications of the provisional Gantt chart

63

MSc Computer Science

Following Gantt chart will explain the actual project management as it has gone through.

Figure 6(c): Figure showing the Actual Gantt chart

64

MSc Computer Science

Figure 6(d): Figure showing the tasks involved in the actual Gantt chart.

6.3 Research Question and Hypothesis testing


Research questions and the hypothesis are evaluated based on the test results below.

What is the measure for denominating the experience of a player?


Considering the test results the realistic behaviour of NPCs and the excellent architecture
of the game are the most important factors that contribute to likeness of a player. As far as
this research is concerned the author is only concerned about the realistic behaviour of
NPCs. So to measure the realistic behaviour in the subject world is something which is
responsive and realistic. The test takes place in a part if NWN2 module in the game world.
Its a question that leaves room for a lot of discussion. In the test a quite simple picture of
the NPCs daily routine was implemented. The important thing that was added is their
(NPCs) need to entertain and to survive them-self in the game (Hunger, faith, energy).

65

MSc Computer Science

What AI technologies are to be implemented in the existing models to improve the


effect of game play?
Many existing AI technique was researched prior to the smart terrain but smart terrain is
the one technique which proved to be the best to implement in to the module. The Smart
terrain technique was used to implement in to the existing NWN2 game. As it is said not
the complete technique of Smart terrain is implemented but a part of it. The Smart terrain
is used to broadcast from the smart objects to the NPCs about the needs that they can
fulfil. As well as handling the waypoint graph from the NPCs to Smart objects.

Can realistic behaviour of the NPCs does really affect the gamers experience?
This is a very difficult question to answer, with the results obtained. It can be said that it
will indeed improve it for most users. Its something that is opinion related and varies
from person to person. However the author can safely assume that none would feel that
the game feelings would suffer from the improved NPCs AI. Therefore judging by the test
results of the testers who felt it increased the realism. We could consider that answer Yes
for this question if we look at gamers as a group of people instead of individualistic
perspective.

What part of the game needs to be concentrated to improve the realism?

Basing on the research implementation, clearly it can be said that the NPCs part of the
game AI has to improve more to make the game successful in all respects. The testers who
participated in the test have expressed their feelings on the game on a whole as very good
in graphics and more rich visuals but lack the realistic behaviours of NPCs AI.

Does an advanced AI technique like Smart Terrain really helps in enhancing the

experience?
With the test results analysed and discussed. The author thinks by now it is very much safe
to say that the above statement is true. Smart terrain did improve the realism among the
NPCs in the NWN2 and would probably for the same for most of the RPGs.

66

MSc Computer Science

6.4 Discussion
In tests like this one, there are always lots of factors that can affect the outcome. Words like
realism and game-feeling is something that is interpreted in different ways by different
people. Their background and previous experiences affects what they expect from the game
and the AI, as well as what they find entertaining. In an attempt to minimize error margins
from these kinds of factors, some questions in the tests purpose was to categorize the different
test subjects by their previous experiences. Thereby patterns and conclusions can easier be
drawn from the results.

6.5 Conclusion
As said earlier all the main concepts of the testing and analysis of the testing is dicussed

67

MSc Computer Science

References & Bibliography


Steve Rabin (2002). AI Game Programming wisdom. USA: Charles river media,inc. p1-64
Alex J. Champandard (2003). AI Game Development: Synthetic Creatures with Learning and
Reactive Behaviours. USA: New Riders Publishing. p2-100.
Steven

Woodcock.

(2000). Game

AI:

The

State

of

the

Industry. Available:

http://www.gamasutra.com/view/feature/3570/game_ai_the_state_of_the_industry.php.

Last

accessed 24th aug 2010.


Ian Millington,John Funge (2009). Artificial intelligence for games. 2nd ed. USA: Elsevier
Inc. p20-300.
Brain Schwab (2004). AI Game Engine Programming. USA: Charles river media,inc. p3-28.
Stuart Russell and Peter Norvig (2003). Artificial Intelligence: A Modern Approach. USA:
Upper saddle river,inc. p1-29.
David M.Bourg & Glenn Seemann (2004). AI for Game Developers. USA: O'Reilly
Media,Inc. P1-76.
Bryan

Stout

(2001). Smart

Move:

Intelligent

Path-Finding. Available:

http://www.gamasutra.com/view/feature/3317/smart_move_intelligent_.php. Last accessed


25th Sep.
Marco

Pinter

(2001).Toward

More

Realistic

Pathfinding. Available:

http://www.gamasutra.com/view/feature/3096/toward_more_realistic_pathfinding.php.

Last

accessed 25th Sep.


GUY W. LECKY-THOMPSON (2008). AI and Artificial Life in Video Games. USA: Charles
river media,inc. p25-92

68

MSc Computer Science

Chow ying Kit Ricky (2006) AI Role Playing Game Development. BEng. Thesis, City
University of Hong Kong
Spronck, Pieter, (2006). Dynamic scripting. In: Steve rabin AI Game Programming wisdom
vol3. 3rd ed. USA: Charles river media,inc. P200-300.
Bertill jeppsson(2008) AI- Controlled life in Role-Playing Games. BEng. Thesis, Blenkinge
institute of technology.
Matt

Barron.

(2007). The

History

of

Computer

Role-Playing

Games. Available:

http://www.gamasutra.com/view/feature/1706/the_history_of_computer_.php>. Last accessed


30th aug.>
William van der Sterren. (2001). Terrain Reasoning for 3D Action Games. Available:
http://www.gamasutra.com/view/feature/3038/terrain_reasoning_for_3d_action_.php.

Last

accessed 2nd sep 2010.


Paul Inventado. Merlin .S et.al (2006). a Role-Playing Game with agent plan reformulation
and situational reassessment. ACM International Conference Proceeding Series archive
Proceedings of the 3rd Australasian conference on Interactive entertainment. 207 (3), p1-8
Electronic Arts and Maxis (2000), The Sims, Very popular every-day life Simulation game.
Documentation

for

NWscript.

[Online].[acceded

4th

sep

2010],

Available

at:

<www.nwnlexicon.com>.
Bioware,

Builder

Forum,

[online],[Acceded

4th

sep

2010]

Available

at

<http://nwn2forums.bioware.com/forums/>
Aadarsh, P. (2007) AI in games. [Online]. [Accessed on 4th sep 2010], Available at: <
http://www.slideshare.net/wuzziwug/ai-in-games>.
Kirby, N. (2002) Solving the Right Problem. In: Rabin, Steve AI Game Programming wisdom.
USA: Charles river media,inc. p21-40.

69

Das könnte Ihnen auch gefallen