Flirting with the Dark Side
description
Transcript of Flirting with the Dark Side
![Page 1: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/1.jpg)
FLIRTING WITH THE DARK SIDE
Scripting and AI
Damián Isla, Moonshot Games
![Page 2: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/2.jpg)
Scripting vs. Scripting
Distinguish between scripting as technology and scripting as filthy hackery.
![Page 3: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/3.jpg)
Scripting as Filthy Hackery
“Lazy devs faking it in script instead of doing it for real in code.”
Obviously absurd.
Code doesn’t make it more real. Script is code. It’s all fakery if you go down far enough.
![Page 4: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/4.jpg)
Faking it
Robust vs. brittle systems Orthogonal to questions of implementation language
Robust is always better
A Matter of Economics we don’t have time to do everything well it works most of the time
![Page 5: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/5.jpg)
The World is Lies
... so what we should be asking ourselves is not “how do we avoid faking it” but “what’s the best way to fake it?”
![Page 6: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/6.jpg)
The Most Important AI Technology Ever
if <X> then <Y> else <Z>
![Page 7: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/7.jpg)
But this sucks
if (ai.health < health_cover_threshold){
<Y> }else {
<Z>}
![Page 8: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/8.jpg)
Scripting as Architecture
LUA Compiled to bytecode Hot swapping Highly embeddable Highly customizable Dynamic typing
Months of dev time
saved
Kill me now
![Page 9: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/9.jpg)
Pros and Cons
We like Iteration times Expressivity Designer-accessibility
We don’t like Performance Designer-accessibility
![Page 10: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/10.jpg)
El Compromiso
Systems that are performance-sensitive are generally NOT the systems where designer-expressivity is important.
And vice versa.
![Page 11: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/11.jpg)
Our Strategy
Script as a pillar of the the Engine
Component object model Components can be
implemented in C++ Lua
Script is also the special sauce
Script is the glue
![Page 12: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/12.jpg)
The [Production] Goal
Lua can be used to create first-class systems from the ground up.
3 parts: component scripts system scripts data
![Page 13: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/13.jpg)
Components and Script
A B
C
D
![Page 14: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/14.jpg)
Components and Script
A B
![Page 15: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/15.jpg)
Components and Script
APath
This is where the fun lives
BAnimation
![Page 16: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/16.jpg)
![Page 17: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/17.jpg)
Component Soup
A*Perceptio
n/Ray-casting Target
selection
Behavior
Physics
Animation
playback
Animation control
Squad behavi
orRandom
Script
![Page 18: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/18.jpg)
Component Soup
A*Perceptio
n/Ray-casting Target
selection
Behavior
Physics
Animation
playback
Animation control
Squad behavi
orRandom
Script
Emit balloons from ears whenever player hits the
elephant with the frying pan
![Page 19: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/19.jpg)
Component Soup
A*Perceptio
n/Ray-casting Target
selection
Behavior
Physics
Animation
playback
Animation control
Squad behavi
orRandom
Script
![Page 20: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/20.jpg)
Component Soup
A*Perceptio
n/Ray-casting Target
selection
Behavior
Physics
Animation
playback
Animation control
Squad behavi
orRandom
Script
![Page 21: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/21.jpg)
Component Soup
A*Perceptio
n/Ray-casting Target
selection
Behavior
Physics
Animation
playback
Animation script
Squad behavi
orRandom
Script
Locomotion control
![Page 22: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/22.jpg)
Component Soup
emit_balloons
initialize()attach()update()detach()
![Page 23: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/23.jpg)
![Page 24: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/24.jpg)
System Soup
System script
![Page 25: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/25.jpg)
System Soup
Boids
![Page 26: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/26.jpg)
System Soup
![Page 27: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/27.jpg)
Data Need to be able to:
save out the state of the scripts drive the system with data define the structure for both
Lua can define structures define structures for engine-allocated data blocks engine controls the lifetime of these blocks
Lua reads and writes to the blocks is NEVER allowed to allocate it’s own dynamic memory we lock the global scope after creation
![Page 28: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/28.jpg)
System Soup
Parameters State
Parameters State
System script
![Page 29: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/29.jpg)
Script-based Systems
What it gets us
A fluid design environment avoid the “data-driven” code trap
A place to put our hacks (Embrace the hackery)
Continuity between prototyping and production
![Page 30: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/30.jpg)
Initial Framework (Engineer)
Implementation (Design)
Final implementation (Engineer)
Final buy-off (Design)
![Page 31: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/31.jpg)
Engineer makes it
work
Design makes it work well
Engineer makes it fast
Design makes sure it still works well
![Page 32: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/32.jpg)
Not so fast...
Doesn’t mean you don’t need to
Provide perf tools Think systemically about script Think seriously about interfaces between components Design all pieces as an architecture Help designers write good systems, not just good code
But does mean that the architecture can evolve more fluidly and in a more design-driven way.
![Page 33: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/33.jpg)
Concepts that don’t Exist (In code) Health / Death / Damage Weapons / Items / Equipment / Powers AI Behavior HUD / UI / Menus Missions / Levels / Objectives
![Page 34: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/34.jpg)
One more distinction
C++ high performance low (designer) expressivity game-agnostic
Script low performance high (designer) expressivity game-specific
The technology you keep
around for next timeThe stuff that makes this
game unique and awesome
![Page 35: Flirting with the Dark Side](https://reader036.fdocuments.net/reader036/viewer/2022081418/56816108550346895dd05180/html5/thumbnails/35.jpg)
Thanks!