Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] Re: using OR in requirements
Home

[Freeciv-Dev] Re: using OR in requirements

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jdorje@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: using OR in requirements
From: Marek "Baczek" Baczyński <imbaczek@xxxxxxxxx>
Date: Mon, 5 Dec 2005 16:18:42 +0100

2005/12/5, Jason Dorje Short <jdorje@xxxxxxxxxxxx>:
> We cannot easily use Lua because the AI and helptext both require that
> the effects logic be invertible; e.g., it needs to know what it has to
> do to acquire an effect.  This would mean lots of lua functions for each
> effect - one for each query type, basically.

Here's my rough preprocessor concept. It doesn't understand ruleset
files, but it can output them from Python dicts. You probably need
Python 2.4 to run this. Here's an example:

# input
rules_1 = {
    'effect_martial_law_each': {
        'name': 'Martial_Law_Each',
        'value': 1,
        'reqs': OR(dict(type='Gov', name='Anarchy', range='Player'),
                    dict(type='Gov', name='Despotism', range='Player'),
                    dict(type='Gov', name='Monarchy', range='Player'))
    }
}

freeciv_formatter(expand_rules(rules_1))

# output

[effect_martial_law_each_000]
name = Martial_Law_Each
reqs = { "range", "type", "name"
        "Player", "Gov", "Anarchy"
}
value = 1

[effect_martial_law_each_001]
name = Martial_Law_Each
reqs = { "range", "type", "name"
        "Player", "Gov", "Despotism"
}
value = 1

[effect_martial_law_each_002]
name = Martial_Law_Each
reqs = { "range", "type", "name"
        "Player", "Gov", "Monarchy"
}
value = 1

--
{ Marek Baczyński :: UIN 57114871 :: GG 161671 :: JID imbaczek@xxxxxxxxxxxxx  }
{ http://www.vlo.ids.gda.pl/ | imbaczek at poczta fm | http://www.promode.org }
.. .. .. .. ... ... ...... evolve or face extinction ...... ... ... .. .. .. ..

Attachment: or_processor.py
Description: Text Data


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