forked from stengel/ecta2002
-
Notifications
You must be signed in to change notification settings - Fork 0
/
normform.h
91 lines (75 loc) · 2.6 KB
/
normform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* normform.h
* 27 Apr 2000
*/
/* #include before: "rat.h" "treedef.h" */
/* global variables for normal form */
/* nf payoffs [row][col] */
extern Payvec **nfpay;
/* number of pure strategies for each player
* set by gennf() via numstratsnfpre(pl)
*/
extern int nstrats[PLAYERS];
extern Move *movetuple[PLAYERS]; /* movetuple encoding pure strategy */
extern Rat *mixedstrat[PLAYERS]; /* mixed strategy (vector of probs) */
/* allocates normal form payoff matrix
* sets all nf payoffs to 0
* allocates movetuple[][]
* allocates mixedstrat[][]
* assumes nstrats[], nisets[] set
*/
void allocnf(void);
/* computes number of RNF pure strategies for player pl
* sets h->ncontin, h->prefact, c->ncompat, c->offset
*/
int numstratsnfpre(int pl);
/* fills list of pure strategies compatible with seq
* of player pl, returns length of list
* assumes list is allocated size nstrats[pl]
*/
int seqtostratlist (Move seq, int pl, int *list);
/* generate normal form
* sets nstrats[1..PLAYERS-1]
*/
void gennf(void);
/* LCP (M,q) for the normal form
* not the covering vector d
* generates nf, allocates LCP, fills LCP
*/
void nflcp(void);
/* converts pure strategy number strat of player pl
* to its tuple of moves (NULL = irrelevant)
* in movetuple[nisets[pl]], assumed allocated
* assumes numstratsnfpre(pl) has been called
*/
void strattomovetuple (int strat, int pl);
/* converts the behavior strategy of player pl given by
* moves[]->behavprob to a mixed strategy stored in mixedstrat[pl]
*/
void behavtomixed(int pl);
/* converts the mixed strategy mixed of player pl, e.g.
* mixed = mixedstrat[pl] to a realization plan rplan,
* typically rplan = realplan[pl]
*/
void mixedtorealplan(int pl, Rat *mixed, Rat *rplan);
/* converts movetuple[pl] to string s
* s must be long enough to contain result
* returns length of string
*/
int movetupletoa (int pl, char* s);
/* support size of the mixed strategy mixed, typically mixedstrat[pl],
* of player pl
*/
int supportsize(int pl, Rat *mixed);
/* gives the mixed strategy mixed of player pl to stdout,
* in one line, listing only the support
* bnewline: terminate with \n
*/
void outmixed(int pl, Rat *mixed, Bool bnewline);
/* gives the mixed strategy mixed, typically mixedstrat[pl],
* of player pl, to stdout, in two lines, listing only the support
*/
void twolineoutmixed(int pl, Rat *mixed);
/* output normal form */
void nfprint(void);
/* columns: sequences, row: pure strategies of player pl */
void compatstrats(int pl);