Scripting and ai
Download
1 / 35

Flirting with the Dark Side - PowerPoint PPT Presentation


  • 126 Views
  • Uploaded on

Scripting and AI. Flirting with the Dark Side. Damián Isla, Moonshot Games. Scripting vs. Scripting. Distinguish between scripting as technology and scripting as filthy hackery . Scripting as Filthy Hackery. “Lazy devs faking it in script instead of doing it for real in code.”

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Flirting with the Dark Side' - zonta


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Scripting and ai

Scripting and AI

Flirting with the Dark Side

Damián Isla, Moonshot Games


Scripting vs scripting
Scripting vs. Scripting

Distinguish between scripting as technology and scripting as filthy hackery.


Scripting as filthy hackery
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.


Faking it
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


The world is lies
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?”


The most important ai technology ever
The Most Important AI Technology Ever

if <X> then <Y> else <Z>


But this sucks
But this sucks

if (ai.health < health_cover_threshold)

{

<Y>

}

else

{

<Z>

}


Scripting as architecture
Scripting as Architecture

LUA

  • Compiled to bytecode

  • Hot swapping

  • Highly embeddable

  • Highly customizable

  • Dynamic typing

Months of dev time saved

Kill me now


Pros and cons
Pros and Cons

We like

  • Iteration times

  • Expressivity

  • Designer-accessibility

    We don’t like

  • Performance

  • Designer-accessibility


El compromiso
El Compromiso

Systems that are performance-sensitive are generally NOT the systems where designer-expressivity is important.

And vice versa.


Our strategy
Our Strategy

  • Script as a pillar of the theEngine

  • Component object model

  • Components can be implemented in

    • C++

    • Lua

  • Script is also the special sauce

  • Script is the glue


The production goal
The [Production] Goal

Lua can be used to create first-class systems from the ground up.

3 parts:

  • component scripts

  • system scripts

  • data




Components and script2
Components and Script

A

B

Path

Animation

This is where the fun lives


Component soup
Component Soup

Perception/Ray-casting

Behavior

A*

Target selection

Squad behavior

Animation control

Random

Script

Animation playback

Physics


Component soup1
Component Soup

Emit balloons from ears whenever player hits the elephant with the frying pan

Perception/Ray-casting

Behavior

A*

Target selection

Squad behavior

Animation control

Random

Script

Animation playback

Physics


Component soup2
Component Soup

Perception/Ray-casting

Behavior

A*

Target selection

Squad behavior

Animation control

Random

Script

Animation playback

Physics


Component soup3
Component Soup

Perception/Ray-casting

Behavior

A*

Target selection

Squad behavior

Animation control

Random

Script

Animation playback

Physics


Component soup4
Component Soup

Perception/Ray-casting

Behavior

A*

Target selection

Squad behavior

Locomotion control

Animation script

Random

Script

Animation playback

Physics


Component soup5
Component Soup

emit_balloons

initialize()

attach()

update()

detach()


System soup
System Soup

System script




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


System soup3
System Soup

System script

Parameters

State

Parameters

State


Script based systems
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


Initial Framework (Engineer)

Implementation (Design)

Final implementation (Engineer)

Final buy-off (Design)


Engineer makes it work

Design makes it work well

Engineer makes it fast

Design makes sure it still works well


Not so fast
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.


Concepts that don t exist in code
Concepts that don’t Exist (In code)

  • Health / Death / Damage

  • Weapons / Items / Equipment / Powers

  • AI

  • Behavior

  • HUD / UI / Menus

  • Missions / Levels / Objectives


One more distinction
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 time

The stuff that makes this game unique and awesome



ad