[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gambit-users] a simple question
From: |
Ted Turocy |
Subject: |
Re: [Gambit-users] a simple question |
Date: |
Sun, 8 Sep 2002 12:42:01 -0500 |
On 2002.09.07 19:28 "John Mathis John Mathis" wrote:
Just to make life difficult for myself, I'm attempting to do exercise
3.6 of _Games_of_Strategy_ using GCL. I've sucessfully built an
extended form game that displays ok with the following commands.
<snip>
This was not too difficult, but I want to assign payoffs by evaluating
the actions that led to each terminal node. The idea is that the
players are voting on whether or not to reinstate the death penalty.
Reinstatement requires a bill to pass with a strict majority. There
are four possible outcomes for any particular player:
1. bill passes, player voted for it (pf)
2. bill passes, player voted against it (pa)
3. bill fails, player voted for it (ff)
4. bill fails, player voted agains it (fa)
A's preferences, from most to least desireable, are respectively:
pf,ff,pa,fa.
B's and C's preferences are: ff,fa,pf,pa.
D's preferences are: fa,pa,ff,fa.
<snip again>
Now, how can I set payoff values for each of the players, at each of
the terminal nodes, with GCL, using the method described above?
Hope this question isn't to basic for the list - I've read the online
documentation quite a bit, but the solution remains opaque.
Heck, this is a lot closer to too advanced rather than too basic! :)
What you're missing -- because it's missing from the online
documentation, for the simple reason of the sheer tedium involved in
converting the older documentation to the new format -- is a couple
convenience functions, which are in stdudfs.gcl in the distribution.
I'll stick 'em here, since they're real short:
NewFunction[TerminalNodes[efg->EFG]=:LIST(NODE),
Filter[d:=Nodes[efg],NumChildren[d]=0]
]
This function returns all the terminal nodes in a game. You'll need
this so you can create one outcome for each node, and attach the
outcome to them. Something like:
terminals := TerminalNodes[e]
For[i := 1, i <= Length[terminals], i := i + 1,
SetOutcome[terminals[i], NewOutcome[e]]
]
Once you've done that, you can use this History[] function to identify
all the actions which were played prior to a node:
NewFunction[History[n->NODE]=:LIST(ACTION),
If[IsRoot[n],{},Flatten[{History[Parent[n]]}&{PriorAction[n]}]]
]
You can use the list of actions this returns, then, to figure out
whether or not each terminal node corresponds to pass/fail, and whether
or not each player individually voted for or against it.
There are a bunch of useful functions like this described in the old
(0.96.3) version of the command language manual. They all are still
valid; as I wrote above, it's just plain tedious to convert the old
documentation to new, so these haven't made it over yet.
This question gives me an entree to ask something I was going to ask
here shortly anyway.
In the longer term, part of the plan is to develop interfaces to Gambit
from various languages
other than C++. I'm currently working on a Python module, an early
version of which should be available in the 0.97.1.z series, for
example. If this
works out well -- and I think it will -- we're considering deprecating
the command language in favor of using, say, Python. We see some
advantages to this: on our end, it will substantially cut into the code
we have to maintain, so we can focus more of our resources on doing
game theory instead of language implementation; on the user end, it
means you won't have to learn a separate language with its own grammar
and syntax. On the other hand, of course, it means any existing
programs in the GCL will have to be ported over.
We'd like to hear comments or suggestions in this regard, either
on-list or off.
Ted
--
address@hidden -- Assistant Professor, Economics, Texas A&M