~ubuntu-branches/ubuntu/natty/dealer/natty

« back to all changes in this revision

Viewing changes to tree.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2005-09-07 23:32:20 UTC
  • Revision ID: james.westby@ubuntu.com-20050907233220-e7bsghnrwg1ncye4
Tags: upstream-0.20040530
ImportĀ upstreamĀ versionĀ 0.20040530

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef TREE_H
 
2
#define TREE_H
 
3
/*
 
4
 * decision tree and other expression stuff
 
5
 */
 
6
 
 
7
struct tree {
 
8
        int             tr_type;
 
9
        struct tree     *tr_leaf1, *tr_leaf2;
 
10
        int             tr_int1;
 
11
        int             tr_int2;
 
12
        int             tr_int3;
 
13
};
 
14
 
 
15
struct expr {
 
16
        struct tree*    ex_tr;
 
17
        char*               ex_ch;
 
18
        struct expr*    next;
 
19
};
 
20
 
 
21
#define NIL     ((struct tree *) 0)
 
22
 
 
23
#define SUIT_CLUB       0
 
24
#define SUIT_DIAMOND    1
 
25
#define SUIT_HEART      2
 
26
#define SUIT_SPADE      3
 
27
#define SUIT_NT         4
 
28
#define NSUITS          4
 
29
 
 
30
#define MAKECARD(suit, rank)    ((card)(((suit)<<6)|(rank)))
 
31
 
 
32
#define MAKECONTRACT(suit, tricks) (tricks*5+suit)
 
33
#define C_SUIT(c)               ((c)>>6)
 
34
#define C_RANK(c)               ((c)&0x3F)
 
35
#define NO_CARD                 0xFF
 
36
 
 
37
#define COMPASS_NORTH   0
 
38
#define COMPASS_EAST    1
 
39
#define COMPASS_SOUTH   2
 
40
#define COMPASS_WEST    3
 
41
 
 
42
#define VULNERABLE_NONE 0
 
43
#define VULNERABLE_NS   1
 
44
#define VULNERABLE_EW   2
 
45
#define VULNERABLE_ALL  3
 
46
 
 
47
#define NON_VUL 0
 
48
#define VUL     1
 
49
 
 
50
#define TRT_NUMBER      0
 
51
#define TRT_AND2        1
 
52
#define TRT_OR2         2
 
53
#define TRT_CMPEQ       3
 
54
#define TRT_CMPNE       4
 
55
#define TRT_CMPLT       5
 
56
#define TRT_CMPLE       6
 
57
#define TRT_CMPGT       7
 
58
#define TRT_CMPGE       8
 
59
#define TRT_LENGTH      9
 
60
#define TRT_ARPLUS      10
 
61
#define TRT_ARMINUS     11
 
62
#define TRT_ARTIMES     12
 
63
#define TRT_ARDIVIDE    13
 
64
#define TRT_ARMOD       14
 
65
#define TRT_HCPTOTAL    15
 
66
#define TRT_HCP         16
 
67
#define TRT_SHAPE       17
 
68
#define TRT_NOT         18
 
69
#define TRT_HASCARD     19
 
70
#define TRT_IF          20
 
71
#define TRT_THENELSE    21
 
72
#define TRT_LOSERTOTAL  22
 
73
#define TRT_LOSER       23
 
74
#define TRT_TRICKS      24
 
75
#define TRT_RND          25
 
76
#define TRT_CONTROL     26
 
77
#define TRT_CONTROLTOTAL        27
 
78
#define TRT_SCORE       28
 
79
#define TRT_IMPS        29
 
80
#define TRT_CCCC        30
 
81
#define TRT_QUALITY     31
 
82
#define TRT_PT0TOTAL    32
 
83
#define TRT_PT0         33
 
84
#define TRT_PT1TOTAL    34
 
85
#define TRT_PT1         35
 
86
#define TRT_PT2TOTAL    36
 
87
#define TRT_PT2         37
 
88
#define TRT_PT3TOTAL    38
 
89
#define TRT_PT3         39
 
90
#define TRT_PT4TOTAL    40
 
91
#define TRT_PT4         41
 
92
#define TRT_PT5TOTAL    42
 
93
#define TRT_PT5         43
 
94
#define TRT_PT6TOTAL    44
 
95
#define TRT_PT6         45
 
96
#define TRT_PT7TOTAL    46
 
97
#define TRT_PT7         47
 
98
#define TRT_PT8TOTAL    48
 
99
#define TRT_PT8         49
 
100
#define TRT_PT9TOTAL    50
 
101
#define TRT_PT9         51
 
102
 
 
103
/*
 
104
 * Actions to be taken
 
105
 */
 
106
struct acuft{
 
107
  long acuf_lowbnd;
 
108
  long acuf_highbnd;
 
109
  long acuf_uflow;
 
110
  long acuf_oflow;
 
111
  long*acuf_freqs;
 
112
};
 
113
 
 
114
struct acuft2d{
 
115
  long acuf_lowbnd_expr1;
 
116
  long acuf_highbnd_expr1;
 
117
  long acuf_lowbnd_expr2;
 
118
  long acuf_highbnd_expr2;
 
119
  long*acuf_freqs;
 
120
};
 
121
 
 
122
 
 
123
 
 
124
 
 
125
struct action {
 
126
        struct action   *ac_next;
 
127
        int             ac_type;
 
128
        struct tree     *ac_expr1;
 
129
        struct tree *ac_expr2;
 
130
        int             ac_int1;
 
131
        char            *ac_str1;
 
132
        union {
 
133
                struct acuft acu_f;
 
134
        struct acuft2d acu_f2d;
 
135
        } ac_u;
 
136
};
 
137
 
 
138
 
 
139
#define ACT_PRINTALL    0
 
140
#define ACT_PRINT       1
 
141
#define ACT_AVERAGE     2
 
142
#define ACT_FREQUENCY   3
 
143
#define ACT_PRINTCOMPACT 4
 
144
#define ACT_EVALCONTRACT 5
 
145
#define ACT_PRINTPBN 6
 
146
#define ACT_PRINTEW 7
 
147
#define ACT_FREQUENCY2D 8
 
148
#define ACT_PRINTONELINE 9
 
149
#define ACT_PRINTES 10
 
150
 
 
151
/* Constants for CCCC and Quality */
 
152
 
 
153
#define RK_ACE          12
 
154
#define RK_KING         11
 
155
#define RK_QUEEN        10
 
156
#define RK_JACK          9
 
157
#define RK_TEN           8
 
158
#define RK_NINE          7
 
159
#define RK_EIGHT     6
 
160
 
 
161
#ifdef WIN32
 
162
#define bcopy(s,t,size) memcpy(t,s,size)
 
163
#endif
 
164
 
 
165
#endif /* TREE_H */