How do you control your NPCs?

I’m just starting to think about NPC movement. My present feeling is that an NPC should first explore an area and ‘remember’ the location of key features/areas. Sorta look around first and ‘say’ “oh, there’s a door over there and a window over here.” Identify areas of danger and areas of safety. And NPCs should be doing something, task/goal driven. I hate how, in some RPGs, the NPCs are always in the same spot doing the same thing. Its a little different in Oblivion, the NPCs seem to follow a time table. But I killed a shop/bar owner once and the waitress just kept moving around and even walked over the corpse. That doesn’t seem right. I noticed in some games, the patrols will notice a change. If a door, once closed, is now open or if a light is broken they will comment/act on it.

I hope this can be a broad discussion. Maybe compile a list of ways that NPCs can be controlled and site games that use that method. I’m new to this. I know some buzzwords like scripting, pathfinding, and waypoints but no real code to support it. How were the bots in Pac Man controlled? Does anyone have python code for this?

And maybe we can list websites that give sample code and such. I found a paper earlier tonight that presents an interesting take on NPC perception. www.kynogon.com/images-blog/ Documents/WPG1Perception.pdf

I’m interested in doing this as well. I have begun coding these sorts of things and I think the best thing would be to use Event Handlers:
www.panda3d.org/manual/index.php/Event_Handlers

This way when a light bulb breaks it could send a message out saying it’s broke so all other objects in the world could react to it. You could also set a task to have the message get sent out so many seconds or minutes so that other NPCs will notice it.

I came across an intereting website.

http://www.memeticai.org/index.html

The Suffering: A Game AI Case Study
www.simbionic.com/gameai/papers/AAAI04-WS4-Alt.pdf

Working Group on Rule-based Systems
igda.org/ai/report-2004/rbs.html

Generation of Emotional Behavior for Non-Player Characters
– Development of EmoBot for Quake II –

http://penguin.ewu.edu/~ainoue/EmoBot/docs/abstract.pdf

Just wanted to say thanks to Brian et al for posting these links. Good reading!

Efficient, Realistic NPC Control Systems using Behavior-Based …

www.cs.northwestern.edu/~khoo/downloads … lexbot.pdf

For more information on FlexBot, including a download of the latest
version, see cs.northwestern.edu/~gdunham/fle … nloads.htm

An Introduction to Game AI
generation5.org/content/2000/app_game.asp

“…games like MechWarrior. They use goal-based engines - each entity within the game is assigned a certain goal, be it ‘protect base’, ‘attack bridge’, ‘fly in circles’. As the game world changes, so do the goals of the various entities.”

Simple Board Game AI
generation5.org/content/2000/boardai.asp
Influence Mapping

Finite State Machine Tutorial
generation5.org/content/2003 … torial.asp

“the purpose behind states is to replace the need for IF/THEN statements with events.”

This article actually includes some code (working code), but its in C++. The FSM code has also been ported to both Java and Rebol.

How To Get Started with Gaming AI
generation5.org/content/2001/howto00.asp

Memory in Games
generation5.org/content/2000/game01.asp
“…instead of covering each move combination or pattern (and have about 20 page of code), we could use an algorithm that would use memory of previous game so it wouldn’t make the same mistakes over and over again (and use about 20 lines of code).”

Smart Moves: Intelligent Path-Finding
gamasutra.com/features/19990212/sm_01.htm
" To demonstrate the workings of the algorithms visually, I have developed a program in Delphi 2.0 called “PathDemo.” It is available for readers to download. "

Also contains sample code for Breadth-first search, Dijkstra’s algorithm, and A*. See Listings 1-3 in the article.

I’d like to dive deeper into the quake code and look at the AI portion to get some ideas.

Quake source code released under the GPL, links for engine and game code:

* Engine Code: [ftp://ftp.idsoftware.com/idstuff/source/q1source.zip](ftp://ftp.idsoftware.com/idstuff/source/q1source.zip)
* Game & Tool Code: [ftp://ftp.idsoftware.com/idstuff/source/q1tools_gpl.tgz](ftp://ftp.idsoftware.com/idstuff/source/q1tools_gpl.tgz)

Very interesting information about AI:
www-cs-students.stanford.edu/~am … eprog.html - Amit’s Game Programming Information
aigamedev.com/ - Game AI for Developers

Alive! is a sandbox for learning AI and game programming. It’s a simple IDE inspired by Self and Squeak but written in Python.
alive.sourceforge.net/

Analyzing the AI Bot Library from the Quake 3 Source Code
aigamedev.com/source/quake3-engine

Area Awareness System
Routing With Caching
Stack-Based Goal Architecture
Main AI Routine

An Overview of the AI Architecture Inside the F.E.A.R. SDK
aigamedev.com/source/fear-sdk

“The codebase is in C++, like the rest of the AAA games industry, but the code is written in a style that should provide valuable insights for the developers among you using C# or Java.”

“Download the AI source code from the SDK in this thread of the forum.”

Examining the AI Scripts in Call of Duty 4’s Developer Tools
aigamedev.com/source/call-of-duty-4-tools

“one of the best examples of scripted level design.”

“…205,718 lines of level scripts (not including the automatically generated configuration files”