APOCALYX is a...

free Game Engine based on OpenGL (MAIL) (SITE) (FORUM) (BLOG)

Tuesday, April 15, 2008

The Lua sandbox

In a game like GUN TACTYX, where the players write directly the AI code that manages the behavior of their team of bots, it's important to verify that no malicious code is possible (or no player will load other players' code on his computer).
It's a situation similar to the execution of JAVA applets in a browser: we don't want that any applet can write arbitrary data to our hard disk (e.g. a virus), so applets are confined in a so called sandbox.
Another requirement is the complete control over the code execution, so a scheduler can share correctly the time among different teams, and also the control over the memory allocation, so no team can use too much memory.
In the old version of GUN TACTYX, all these requirements were realized in the interpreter of SMALL scripts, but that language had several disadvantages. In the next release instead, the language that controls the bots is our beloved Lua. In fact, I have created a LuaScript class: it implements a Lua interpreter that includes a memory allocation manager and an execution scheduler.
Imagine two platoons of a dozen soldiers each, controlled by their own AI script written by the players: that is going to be GUN TACTYX 2.

No comments: