[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: multiple embedded interpreters?
- From: skaller <skaller@...>
- Date: 05 Jan 2005 12:48:19 +1100
On Wed, 2005-01-05 at 10:16, email@example.com 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
John Skaller, mailto:firstname.lastname@example.org
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net