lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, 2005-01-05 at 10:16, wrote:

> Is there any reason that I shouldn't just launch a new embedded lua
> interpreter for each "team" that uses a lua-based AI, to avoid
> all the possible scoping issues and such?  

Yes. You can't avoid the issues no matter what. The agents
are not playing independently -- there must be some
common data structures (eg a map, board or whatever) that
they're playing ON.

If you use separate threads of control, you have to
provide some API for the agents to act on the playing surface.
This is a very good idea IMHO because it is easily adapted
to a client/server model allowing networked play to
be transparent to the game engine.

However that API is an extra design burden and costs
in performance. It is probably easier to use a single
Lua interpreter and shedule agent actions with
coroutines. This is certainly the kind of model
you'd prefer for low level graphics entities,
eg sprites, which are intrinsically local and require
high performance.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language