Download presentation
Presentation is loading. Please wait.
Published byMiles Pearson Modified over 8 years ago
1
Mafia II Bringing city to life Martin Brandstätter Jan Kratochvíl
2
Content Ideas for creating living city Filling city with elements Basics of artificial intelligence Specific examples: –Pedestrians –Traffic cars
3
Living city Full of life Variability No restrictions for player Seamless streaming
4
Filling city with elements Static geometry Grass, garbage, etc Translocated objects Pedestrians Cars
5
Empty street
6
Translocated objects Translocator Many types of objects –Lamps, chairs, benches –Billboards, neons, traffic signs, semaphores –Trees, shrubs –Action points, and more
7
Translocator Multiple grids Storing only GUID, position, rotation & scale High & Low range Spawn is not optional
8
Street with translocated objects
9
Pedestrian spawning Where to spawn? –Position –Visibility –Usability Spawn points –Kynapse nodes
10
Kynapse visualization
11
Pedestrian despawn When to despawn a Pedestrian? –Is too far away –Is not visible for too long –Is not in any action Line of death
12
Car Spawn Little bit more complicated Data from roadmap Three types –“Translocated” –Parked –Moving
13
Spawn in black area Annulus P
14
Egg P
15
Advanced Egg P
16
Spawn points example
17
Car despawn Reasons to get despawned: –Not visible and not moving towards player –Be too far away and out of sight Visible cars are never despawned Police has special rules
18
Empty street
19
Street with translocated objects
20
Final Street
21
ActionPoints Sidewalk graph with crossings Actionpoints Destructible Objects with ActionPoints
22
Basics of artificial intelligence Brain Hierarchy Black Board Messaging Basic Behaviours Behaviour tree Ai and Script Comunication
23
Brain Hierarchy Small Brain Base Brain Single Brain Human Brain Car Brain Boat Brain Train Brain Team Brain
24
Basic Behaviours brain object small parallel selector composite team behaviour
25
More Behaviours Desire Desire Commander Desire Composite Slave and mapping factory
26
selector commander Composite commander commander commander Parallel Slave Action 0 Action 1
27
Ai and Script Communication Designers demands –script running in parallel with AI –script running without AI –script running with some parts of AI
28
Script Configuration Alive Parallel ScriptParallel Action 0 Action 1 Main Selector Desire Script AI Desire 0 AI Desire 1
29
Script commands Lua Script Message New Command Move,Turn,Anim,.. Desire Script Parallel Script
30
Script wants Exclusive Control Lua Script Message Script Control TRUE Desire Script Parallel Script
31
Script Gains Exclusive Control Lua Script Message Script Control TRUE Desire Script
32
Script Returns Control to AI Lua Script Message Script Control FALSE Desire Script Parallel Script
33
AI Gains Exclusive Control Lua Script Message Script Control FALSE Desire Script
34
AI wants Exclusive Control Lua Script Message AI Control - Reason Selector Script
35
Civilian Archetype Archetype configuration Behavior sub-tree wander Action-Point scripts
37
Wander Configuration Wander Parallel Wander Selector Crossing AP Scan Get In car Special Desire Wander Around Wander Slave Wander Style
38
Driving Roadmap Wandering driver Hunter – police, gangster, … Escaper – taxi, gangster, mission car
39
Roadmap Catmull-Rom splines Whole city roadmap is about 400Kb –Including all necessary meta information No 3 rd party library Crossroads are defined using splines as well
40
Catmull-Rom spline Special case of cubic Hermit spline Relatively easy to compute Spline is going through its interpolation points Tangents are continuous over multiple segments
41
Roadmap
42
Basic driving 1.Interpolate some position before you 2.Set wheels to point at this position 3.Set speed to something 4.You are done
43
Speed Desired speed is influenced by –Behavior – traffic lights, crossings, follower, … –Obstacle –Curve Every “desire” can only lower the desired speed
44
Curve speed Iterative algorithm Input –Preferred deceleration –Centripetal acceleration –Expected braking distance –Max speed
45
Curve speed ca – centripetal acceleration cr – curve radius L – segment length
46
Behavior speed Example: stop before crossing d – distance to crossing a – preferred deceleration of car
47
Obstacle speed Obstacle detection –Subdivision queries – no static scene Detection ahead on desired path Avoid obstacle if possible and desirable Adjust speed to obstacle speed Aggressiveness playing its role
48
Navigation point Interpolation on spline Shift to fit correct lane Random shift Obstacle shift
49
Navigation points
50
Crossroad Team AI Priority for each car Main roads Traffic lights Aggression & green wave
51
Crossroad
52
Hunter Police & gangsters Need to go off roadmap Player drops info behind him Need of collision scene tests
53
Escaper Special case of wandering car May be aggressive Crossroad trespassing is not random Has to ensure that he will reach its destination
54
Special behaviors Avoiding special cars Jam detector Collision detector Horn reaction …
55
Q&A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.