-
Notifications
You must be signed in to change notification settings - Fork 1
/
14-ai-in-shooters.txt
195 lines (160 loc) · 12.4 KB
/
14-ai-in-shooters.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
## Asset Info ##
Asset Origins:
treasure-chest.png - via <a href="https://www.goodfreephotos.com/">Good Free Photos</a>
newfoundland-smoky.jpg - via DanDee Shots https://en.wikipedia.org/wiki/Newfoundland_(dog)#/media/File:Newfoundland_dog_Smoky.jpg
trophy.png - via Charlesvonrosenberg https://en.wikipedia.org/wiki/File:Williamsburg_International_FC_Doylie_Derby_Trophy.png
lightbulb.png - via https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwia5LmVwrrPAhWCTT4KHeyCA1wQjhwIBQ&url=https%3A%2F%2Fpixabay.com%2Fen%2Flight-bulb-lighting-electric-341059%2F&bvm=bv.134495766,d.dmo&psig=AFQjCNGVMR9uikrOXMhNiZPubg7B_FcOkg&ust=1475442474422903
truth-values.png - via https://en.wikipedia.org/wiki/Fuzzy_control_system#/media/File:Fuzzy_control_-_centroid_defuzzification_using_max-min_inferencing.png
hairless-dog.jpg - via Wiki.awal https://commons.wikimedia.org/wiki/File:Chinese_crested_dog_picture.jpg
Sauce Making:
silhouette guy(s)
- smack into wall
- hump wall
- lift gun up
- point gun down
gordon freeman-esque
headcrab (totes adorbs version)
winding road (bezier curve)
ASSETS (art, img, anim, text):
X X art: 3 different 'enemies' (images/chars/botfighter-handa), (char/mongoose-shooter) (char/aswang)
X X anim: knock each one down as if shot "pew pew pew"
X X img: treasure
X X art: brute bot (images/chars/brutebot)
X X img: glasses
X X anim: throw glasses on brute bot "that code got smarter"
(Intro)
X X art: pseudo code of FPS AI (see script for example)
X X art: npc
X X img: wall
X X anim: npc running face first into wall
X X re: 2 of 'enemies' from intro
X X anim: one chases other off the screen
X X img: lightbulb
X X re: 1 'enemy'
X X anim: light bulb shows up over enemies head "strategically figure out what to do"
X X img: map (w/X marks the spot)
X X img: no symbol (images/props/no-symbol)
X X re: enemy smacking into wall
X X anim: no symbol over monster smacking into wall
X X art: gordon freeman-esque char
X X art: ripped paper with writing "Available States"
X X anim: states are 'written' on paper as I say them "patrol for enemy", "run at enemy", etc
X X art: 'zombie' version of a character
X X art: head crab (can this be adorable?)
X X re: gordon freeman-esque char
X X anim: gordon walks past the head crab
X X anim: decision tree (I'll build this from the freeman/headcrab assets)
X X img: some sort of adorable, fuzzy animal
X X art: silhouette soldier gun up/gun down
X X anim: pointing gun/soldier w gun down
X X img: fuzzy logic truth values
X X img: trophy "greatest game of all time"
X X img/anim: non-diverging pathway OR anim bezier curve (sauce!)
X X img: thumb
X X anim: sub and ada and border around thumb
## Script ##
Back in the day, enemies in Wolfenstein 3D didn't stand a chance against me. I'd burst into the room (like a boss) and guards would come running at me. Pew! Pew! Pew! They're done. And I was free to wander around Castle Wolfenstein, pressing spacebar against every wall, looking for treasure.
Nowadays though? My FPS skills are no match for those bot masters. Did I get worse in my old age? No! That code got smarter.
[INTRO]
Welcome to CompChomp...the only show on the internets where we always set our bots to aggressive.
In the beginning was the FPS NPC...and his code was simple.
##### SHOW SOMETHING LIKE THIS ON THE SCREEN ####
if(player.detected()) {
until (self.dies() || player.dies()) {
player.run_directly_at();
player.fire_directly_at();
}
}
#### END ####
If you detect the player...run directly at her while firing in her direction until she's dead or you are!
That was pretty much it.
The code was so simple, in fact, that many a poor NPC ended up running face-first into the wall, not realizing that "straight at the enemy" wasn't _quite_ going to work.
In those early days, you could even get the NPCs to fight each other. Doom was famous for the 'monster infighting'. Stand in juuuuuust the right spot between two groups of monsters, get one of them to accidently hit another monster while firing at you, then stand back and watch the primitive ai attack itself.
We've got high expectations of our modern day shooters though. The NPCs have to strategically decide what to do, they need to figure out where to go on the map to do it, AND, we definitely don't want to see them smacking into walls on their way there.
In the late 90's Valve gifted us with Half-Life a game that brought FPS AI into the modern era. We played through the harrowing tale of Dr. Gordon Freeman as he defended the human race against an experiment gone horribly wrong. Compared to the early wall-humping monsters, the NPCs in Half-Life seemed like Ph.D. candidates.
Valve achieved this using a combination of Finite State Machines, Decision Trees and fuzzy logic.
With Finite State Machines, each NPC has a fixed number of states they can be in. For instance, a basic NPC might have the following:
Patrol for enemies
Attack enemies
Look for health
Die
Each state comes along with a set of behaviors the NPC does while in that state. And, an NPC can only be in a single state at a time. No dying AND patrolling for players....this isn't Left for Dead.
Decision trees are how an AI figures out which state it should be in. Let's say I'm a sweet, little headcrab just going about my day when Dr. Freeman strolls by. Did I detect him? No - then I stay in my current state and continue minding my own business. But if the answer is yes, I need to know if that nasty doctor is nearby. No - then I crawl quickly in his direction. Yes - I leap forward and feast on his delicious brains!
The final piece, the one that ties everything together, is logic. And game devs like our logic the same way we like our animals....fuzzy. With traditional, boolean logic, your options are true or false....a 0 or a 1. Either you're close enough for the combine soldier to shoot at you or you're not. With this kind of system, you end up with some very unnatural behavior.
You see me! You don't. You see me! You don't.
In a fuzzy logic system, you get to have ranges. No more near or far. You can have multiple truth values! And, you can be a member of more than one category at the same time. Let's say your current position in comparison to the combine soldier puts you at .2 near, .8 medium and 0 far. Apply some magic defuzzification math and boom it turns out you're close enough for the soldier to continue shooting at you...even when you back off a tiny bit. The gradual changes enabled by fuzzy logic allows for a much more human-like AI.
Aaaaaaaaad, that's how Valve created the greatest game of all time. In fact, many FPS-lovers think the AI in more recent shooters is much worse than Half-Life's. That's because Valve had one more secret. Since Half-Life was a more linear, story-based game, they could carefully guide the player down certain paths which limited the decisions an NPC had to make. When you limit how a player can interact with an NPC, it's a lot easier to make that interaction seem intelligent.
The advanced players at the time, those guys realized there was a limitation....they wanted more...what could it be?!?!? A new video perhaps?
## Sources ##
- good research and examples http://www.cs.unm.edu/~pdevineni/papers/Yeruva.pdf
## Notes ##
Very simple, initially
- move toward the player
- shoot
* stop when you die or player dies
Use rules based systems or finite state machines (as of 2003)
Computer controlled enemies stay at a particular skill level and generally stick to a fixed series of rules throughout the game
- human players are constantly learning from fighting previous battles & their characters are usually leveling up
Playing with actual AI in an FPS
- machine learning to teach a bot how to play a shooter
- reinforcement learning so a bot learns which moves are better under given circumstances
AI used to be entirely offensive or defensive if a player entered a given area
Now
- AI 'hunts'
* reacts to signs of the player's existence (e.g. sound of footsteps or a footprint in the dirt)
- AI has 'survival instinct'
* hides if he's out of bullets and needs to reload
* looks for cover in area before attacking player
"Monster Infighting"
- popularized with Doom
- monsters reacted to being attacked
- if you get a monster to 'friendly fire' another monster when trying to attack you, the two sets of monsters will start fighting
The AI in most modern games addresses three basic needs:
- the ability to move characters
- the ability to make decisions about where to move
- the ability to think tactically or strategically
"Behavior Tree" technology (popularized Halo 2) very popular in FPS industry
F.E.A.R. First Encounter Assault Recon
- AI uses a planner to generate context-sensitive behaviors, the first time in a mainstream game
- This technology used as a reference for many studios still today.
Pong is an early example of computer AI
- can't pre-script the pattern the computer opponent follows
- has to react to game situation as it unfolds
- simple calculation, but still had to be done 'on the fly'
Half-Life
- praised for quality of it's ai
- Finite State Machines (FSM)
- Decision Trees
- Fuzzy Logic
Quake
- reaper bot would follow path of human player and shoot with deadly accuracy
- standing still would confuse it
A bot is only aware of a very small set of coordinates defining the most critical points on the map, often just his own location and the location of his enemy, the player. A simple line-of-sight function determines if the line between these two points is unobstructed, while another algorithm lets the bot know how close he is to a wall. Since the bot has no representation of the layout of the map, he has no way of knowing that the correct path to the enemy might be to take the first left and then make a right at the fork in the road. Other behaviors common to all but the earliest games include reaction to sound (e.g. gunfire), which is usually done in a crude-but-effective manner similar to line-of-sight, and patrolling, which is simply instructing a bot to walk back and forth between two given points.
Pathfinding
- can add pathfinding nodes that give weights to certain paths (e.g. you can hop up here but it's difficult, there's no cover here)
- allows computers to be more creative with how bots get from pt 1 to pt 2
- bots working together as a group (no longer oblivious to each other)
TODAY
- percentage of CPU cycles left to process game AI is still limited
Doom (1993)
- ai either runs toward player and attacks or walks around
Halo
- simulated world, characters and their code are isolated from the world
- ai has simulated senses (vision and hearing) to discover the player
- The Covenant will be here on top of the building. If the player kills three of them, then the Covenant goes to a set of points that are inside the building. What's really happening is the Covenant is following quite simple rules that the player perceives ... as the flow of battle. It seems like the Covenant thinks they have been weakened, so they retreat to a more defensive position. In fact, they are actually just following quite specific rules that have been laid out for them in that space.
- simple if/then statements ("Elite I was with was killed, I'll run away") can seem like emotional responses ("fear")
* The character uses its AI "senses" to perceive the world -- to detect what's going on around it.
* The AI takes the raw information that it gets based on its perception and interprets the data.
* The AI turns that interpreted data into more processed information
* The AI makes decisions about what its actions should be based on that information.
* Then the AI figures out how it can best perform those actions to achieve the desired result based on the physical state of the world around it.
- four states of the combat cycle
* Idle
* Guard/Patrol
* Attack/Defend
* Retreat
- Not necessarily looking for unpredictability. Sneaking up behind a certain character type to make them run should work consistently in a game.
- Pathfinding, objects are tagged, ai knows it can run through small objects but must go around larger ones / larger players know they can go through larger items
- cover tag is attached to an object, not to a space so if object is destroyed, ai won't try to take cover there any more
Call of Duty: Ghosts
- set them to Veteran level and they take more shots to kill