Finite State Machines - Computer Science & Engineering

advertisement
Game Genres: First Quick Look
H. Muñoz-Avila
Disclaimer: I use these notes as a guide rather than a comprehensive coverage of the topic. They are neither a
substitute for attending the lectures nor for reading the assigned material
Most Popular Games Genres
• Adventure games:
– Solving puzzles
– Storyline arc is very important
– Finding clues
• E.g., through conversations with NPCs
– Classic: The Longest Journey
(http://www.youtube.com/watch?v=8XrkGztFr-0)
• Role Playing Games (RPG)
– Player assumes fictional roles through Avatars
– Avatar acquires skills by performing tasks/actions
– “Levels” indicate the progress of the avatar
• Classic: Diablo 2: http://www.youtube.com/watch?v=vl9C8RTu3Oc
Most Popular Games Genres (II)
• Strategy games:
– resource gathering, managing economy, technology research
– Real-Time Strategy (RTS)
• Rapid decision making (classic: Command & Conquer)
– Turn-based Games (TBS)
• Take turns (classic: Civilization II)
• Sport Games
– Simulation of actual sport games (classic: FIFA series)
• Games of chance
– Outcome highly influenced by a stochastic environment
• First-person shooter
– Controlling avatar in first-person camera view
(classic: Duke Nukem)
Most Popular Games Genres (III)
• And many sub-genres
– Combine and/or enhance main genres
• Massive Multiplayer Online RPG (MMORPG)
– RPGs with multiple other players in pervasive worlds
• Stealth FPS
– FPS emphasizing stealth over shooting
• RTS/RPG
– Combine both aspects (Warcraft III)
• RTS/FPS
– Combine both aspects (classic: Battlezone)
It is recommended for this course that you know at least one
video game very well.
“Programming” Games Without
Programming
(sort of)
H. Muñoz-Avila
Jarret Raim
Jonathan Martin
Thief 2: How to program NPC
behavior?
gameplay
Finite State Machines and
Games
• State: an activity performed by an avatar
• Event: something that happens in the
game world that makes the state change
Enemy on sight
Patrol
Attack
Let us build an FSM for a Thief
NPC
• States
Attack
~E
E
D
E
S
Wander
E
~S
Chase
D
~E
D
Spawn
S
– Attack
– Chase
– Spawn
– Wander
• Events
– E: see an
enemy
– S: hear a sound
– D: die
But it gets even easier (eventon-map)
If player walks
here then
Spawn
Mephisto
Put 3 orcs
here
Starting place
of player
Even at a Larger Scale
If player cross here
Then declare war
Ok Let Us Construct One Finite
State Machine
• Lets program High Priestess Mar'li
http://www.youtube.com/watch?v=I7DT0fMNu3k
http://www.youtube.com/watch?v=AGWBIMIDWhQ
• Step 1: list states and events
• Step 2: Construct the Finite State Machine
Homework (next class)
• Pick an existing game
– Select one or more NPCs in the game
– Create a Finite State Machine modeling the behavior
of the NPCs
• List states (at least 5)
• List events (at least 5)
• Draw a Finite State Machine
• Pick and existing game (can be same as before)
– Provide an example of an event-on-map
Computer Programs
-Program: sequence of instructions that the
computer can understand
read(x)
read(y)
zx+y
print(z)
- For controlling an NPC, we can create an
FSM and let someone else (or a program!)
translate it into a computerunderstandable instructions
Motivation: Scripting
Programming Languages
• The “Community Expansion Package”
is a game created by players, many
non-programmers
• It is build using a software tool called
Aurora which is included in the game
Neverwinter Nights
• In fact using Aurora, gamers create
thousands of their own games “mods”
– Most variants of the original game
– Others significant departures
Scripts
- Script: specialized program that uses
instructions that are based on game world
patrol()
if see-player then
attack(monster)
if hurt then
heal
A Finite State
Machine
Two Engines
• Adventure Game Studio
source:http://www.adventuregamestudio.co.uk/
Introduction: http://www.youtube.com/watch?v=1Ml_DR76Cl4
• RPG Maker
source: http://www.rpgmakerweb.com/
Introduction: http://www.youtube.com/watch?v=S2Y_W7kD8LU
Many Engines
• Many games have facilities that allow you to create “mods”
of the game
• Example: Aurora (Neverwinter Nigths)
http://nwn.wikia.com/wiki/Toolset
• Ranges from total conversion to art mod
Aurora Neverwinter Toolset
By: Nicholas Haines
Final Remarks
• Give some serious thought to doing the
optional assignment of creating a game
– Try one of the engines
• Last time some 80% of the class created
one
• Its fun and
• Some 90% of them got exempt from the
Final Exam
• The remaining 10% got extra credit
Download