glob2-devel
[Top][All Lists]
Advanced

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

Re: [glob2-devel] Embedded scripting language (again)


From: Matthew Marshall
Subject: Re: [glob2-devel] Embedded scripting language (again)
Date: Wed, 22 Feb 2006 00:08:09 -0300
User-agent: KMail/1.9.1

On Tue 21 Feb 2006 07:15, Stéphane Magnenat wrote:
> All this said, perhaps python is suitable. I just would like too see better
> how to implement checkpointability and our special multithreading.
> Arguments such as "this feature is not usefull" do not convince me.

Well, this would be easy to implement (from the example in the wiki):

from glob2 import *

squares = [Area(60, 0, 1), Area(31, 0, 1)]

@as_thread
def introduction():
    show("Get to the sand square in your apponents base.")
    yield 10
    hide()

def lose_condition(area, team):
    while area.occupied(team):
        yield 1
    lose(team)

register_thread(lose_condition, squares[0], 0)
register_thread(lose_condition, squares[1], 1)


Note that I am showing two ways of doing a thread: a) using a decorator and, 
b) manually registering (With paramaters to be passed.)  Also note that this 
technically does not used threads, but generators.  This makes it 
deterministic, and IMHO far less painful.

This is simply the first thing that came to mind as an answer to your request.  
There are quite a few other problems with using python that would need 
careful consideration...  Perhaps I'll write more tomarrow; I need to get to 
bed now.

MWM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]