The AI Systems of Left 4 Dead

There's no PL content per se in this presentation, but a PL weenie will surely think of a DSL for almost every slide, so I hope posting this is warranted.

Tim Sweeney has written previously on the programming challenges raised by game development (The Next Mainstream Programming Languages: A Game Developer's Perspective), and I think this presentation is another showcase of the huge problems that need solving in game development.

Finally, I wonder why anyone would use a language that doesn't allow quick and simple syntax extension for driving a game engine? Seriously, the possibilities for ad-hoc DSLs seem endless.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Finally, I wonder why

Finally, I wonder why anyone would use a language that doesn't allow quick and simple syntax extension for driving a game engine? Seriously, the possibilities for ad-hoc DSLs seem endless.

I'm going to go out on a limb here and suggest that the value of metalinguistic abstraction goes down as the expressive power of your other abstraction mechanisms goes up. At least that's been my experience in shifting from being a Lisp programmer to being an OCaml/Scala developer. Although it's perhaps worth pointing out that, technically, OCaml is every bit as homoiconic as Lisp is, and there are some impressive examples to show off.

Naughty Dog used a

Naughty Dog used a custom-developed Lisp dialect for a few games in the Jak and Daxter series (according to Wikipedia, at least), but I'm not sure how much macro support was implemented. Lua is a popular embedding language in games, but its syntax extension support is pretty limited, unless one starts hacking on the Lua compiler code.

I'll admit my game development experience is woefully light, but I would doubt that most scripting tasks would require extensive syntax changes from a basic imperative language like Lua. Most event-triggers invoke simple changes in the game state, and the primitives would be nothing more than exposed C-bindings already implemented in the game engine.

Macros for Lua

http://metalua.luaforge.net

This is not an endorsement; I've not looked at it carefully. It does appear to be functional though.

Just to be clear

Many game companies are looking to move away from scripting languages like Lua and instead use C# (or F#) and the Mono VM. Dynamic interpretation without byte code caching is horrifically bad for performance and will result in your AI scripts slowing down your frame rates, by bad design. It doesn't matter how good your rendering or raytracing is or whatever, if you spend too much time calculating some agent's behavior.

Edit: THe downside is that a VM is usually bloated, even when designed for a compact framework. Newer VMs like NekoVM have more potential here to saite game developers.

Naughty Dog still uses

Naughty Dog still uses Scheme PLT for their more recent Unchartered games. For more information on their approach, see their GDC presentation "State-Based Scripting in UNCHARTED: DRAKE'S FORTUNE and UNCHARTED 2: AMONG THIEVES".

It is available from the GDC vault: http://www.gdcvault.com/showConference.php?category=free&conference=234&sort_by=title_desc

If you have any thoughts on their approach, I'd be very interested in hearing them.

my $0.02 since i work in the game / media industry

and, pessimistically, i get the impression that most people are not remotely PLT at all, nor do they have enough interest in improving software engineering to realize languages could help. it drives me kinda nuts. so GOAL and Mr. Sweeney and Vendetta Online are exceptions to the rule. i think the "country AND western" is "C++ with Boost" and "Java with, if you are (un)lucky, Groovy thrown in".

(on the other slightly less pessimistic hand maybe people say "yeah we'd love to use other languages, but the PS3/whatever tool chain doesn't support it, and we won't be able to hire devs easily enough" -- which in my mind is still kinda lame.)

p.s. know any angels with $ to fund me to write games in better languages? ;-)

Same situation with computer

Same situation with computer graphics researchers. Though hopefully that would change if we can show them that they can have their cake (performance, flexibility) and eat it to (high level languages).

Things are changing

GPUs are sufficiently nasty to program that people are warming up to alternatives.

I recently saw a talk by Pat Hanrahan about using DSLs and Scala to provide both flexibility and performance in heterogeneous architectures (clusters of CPUs+GPUs, for example). Interestingly, he thinks that optimizing compilers of low-level languages (fortran, c) for these architectures "have lost the game": the only way to get good performance is to raise the level of abstraction in which you program and pushing the architecture details down to the intermediate layers (libraries or DSLs). He uses OpenGL as an example of a successful abstraction, having survived many radical implementation changes of the underlying hardware while keeping the programming model mostly intact.

Slides here: Domain-Specific Languages for Heterogeneous GPU Computing

Awesome link! Bling does

Awesome link! Bling does this as well: it allows you to write rendering code in a C#-based embedded DSL (EDSL), and then does a dependency analysis on the resulting expression trees to determine what parts of the rendering code need to run on the CPU, what needs to run in the vertex shader, and finally what needs to run in the pixel shader. Seems like Pat is doing something similar in Scala, which isn't surprising because my C# EDSL was learned from when I was working on Scala.

PS3 and goal....

GOAL's exact model might be difficult to do on the PS3...

You may be interested in Jason Hise's thesis on a PS3 Compiler based on a variant of Linda.

Sony employs quite a few gcc hackers, by the way.

Even OOP is too much

Seems like for some even OO maybe too much of an abstraction(well, at least for rendering). Pitfalls of Object Oriented Programming[PDF].

Rendering is math

Logic programming is really the end-game winner here.

Ed Kirwan had some nice comments on this slideshow on usenet://comp.object. Highly recommended for others to read Ed's thoughts.

Edit: to be fair to OO, functional programming concepts like partial evaluation provide no great benefit to a compiler writer, either, when referring to this problem domain.