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

Re: Scripting

Steve Baker wrote:

> If (for example) you want a script for a critter in your game, you'd
> probably want to write things (in scripting language) like:
>    while ( true )
>    {
>      walk_forwards ( 10 seconds )
>      if ( player within 10 meters )
>        turn_right ( 60 degrees )
>      else
>        turn_left ( 60 degrees )
>    }
> ...then have 50 copies of this script running for your 50 monsters.

This is not the approach that I would follow. The 'while' loop should not
be done in the script but in the main game driver. So the Python script
only does the part within the 'while' and this script is fired regularly
by the game engine. If you do it like you suggest above you are going
to need as many threads as you have creatures and that's rather
heavy I think. Or else you are going to have do implement threading
on your own (i.e. by multiplexing instructions like you suggest) which
means you cannot use any standard scripting language which is
a big disadvantage IMHO.

> The alternative is to require each script to process exactly one
> frame of decision-making and then return.  That's a fairly
> unnatural way of working - you have to think in terms of state-machines.

I don't think that's an unnatural way of working. Personally I think
it is more natural even.


Jorrit.Tyberghein@uz.kuleuven.ac.be, University Hospitals KU Leuven BELGIUM

Nanny Ogg quite liked cooking, provided there were other people around to
do things like chop up the vegetables and wash the dishes afterwards.
        -- Home Pragmatics
           (Terry Pratchett, Witches Abroad)