features.h 12.2 KB
Newer Older
1
/* tarot implements the rules of the tarot game
2
 * Copyright (C) 2019, 2020  Vivien Kraus
3
 *
4
5
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, version 3 of the License.
7
8
9
10
11
12
13
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 */

#ifndef H_TAROT_FEATURES_INCLUDED
#define H_TAROT_FEATURES_INCLUDED

#include <stddef.h>
#include <tarot/bid.h>
#include <tarot/cards.h>

#ifdef __cplusplus
extern "C"
{
#endif

  struct TarotGame;
30
31

  struct TarotGameEvent;
32
33
34
35
36

  /* General-purpose features */

  /**
   * tarot_features_variant:
Vivien Kraus's avatar
Vivien Kraus committed
37
   * @game: (type TarotGame):
38
39
40
   * @n_players: (out):
   * @with_call: (type boolean) (out):
   */
Vivien Kraus's avatar
Vivien Kraus committed
41
42
  void tarot_features_variant (const struct TarotGame *game,
                               size_t *n_players, int *with_call);
43
44
45

  /**
   * tarot_features_position:
Vivien Kraus's avatar
Vivien Kraus committed
46
   * @game: (type TarotGame):
47
48
49
50
   * @i_trick: (out): the number of tricks played so far
   * @position: (out): the number of players that play before me (for
   * bids, decls, or for the current trick)
   */
Vivien Kraus's avatar
Vivien Kraus committed
51
52
  void tarot_features_position (const struct TarotGame *game, size_t *i_trick,
                                size_t *position);
53
54
55

  /**
   * tarot_features_partner_known:
Vivien Kraus's avatar
Vivien Kraus committed
56
   * @game: (type TarotGame):
57
58
   * @known: (out) (type boolean):
   */
Vivien Kraus's avatar
Vivien Kraus committed
59
60
  void tarot_features_partner_known (const struct TarotGame *game,
                                     int *known);
61
62
63
64
65

  /* Features specific to bidding */

  /**
   * tarot_features_bid_minimum:
Vivien Kraus's avatar
Vivien Kraus committed
66
   * @game: (type TarotGame):
67
68
   * @minimum: (out):
   */
Vivien Kraus's avatar
Vivien Kraus committed
69
70
  void tarot_features_bid_minimum (const struct TarotGame *game,
                                   TarotBid * minimum);
71
72
73

  /**
   * tarot_features_count_faces:
Vivien Kraus's avatar
Vivien Kraus committed
74
   * @game: (type TarotGame):
75
76
77
78
79
80
   * @n_kings: (out):
   * @n_marriages: (out):
   * @n_extended_marriages: (out):
   * @n_queens: (out):
   * @n_knights: (out):
   */
81
  void tarot_features_count_faces (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
82
83
84
85
                                   size_t *n_kings,
                                   size_t *n_marriages,
                                   size_t *n_extended_marriages,
                                   size_t *n_queens, size_t *n_knights);
86
87
88

  /**
   * tarot_features_count_minor:
Vivien Kraus's avatar
Vivien Kraus committed
89
   * @game: (type TarotGame):
90
91
92
93
94
   * @n_shortest: (out):
   * @n_second_shortest: (out):
   * @n_second_longest: (out):
   * @n_longest: (out):
   */
95
  void tarot_features_count_minor (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
96
97
98
99
100
                                   size_t *n_shortest,
                                   size_t *n_second_shortest,
                                   size_t *n_second_longest,
                                   size_t *n_longest);

101
102
  /**
   * tarot_features_count_oudlers:
Vivien Kraus's avatar
Vivien Kraus committed
103
   * @game: (type TarotGame):
104
105
106
107
   * @has_petit: (out) (type boolean):
   * @has_excuse: (out) (type boolean):
   * @has_twentyone: (out) (type boolean):
   */
108
  void tarot_features_count_oudlers (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
109
110
                                     int *has_petit,
                                     int *has_excuse, int *has_twentyone);
111
112
113

  /**
   * tarot_features_count_trumps:
Vivien Kraus's avatar
Vivien Kraus committed
114
   * @game: (type TarotGame):
115
116
117
118
119
120
121
   * @n_trumps: (out):
   * @max_trump: (out):
   * @min_trump: (out):
   * @q1_trumps: (out):
   * @q3_trumps: (out):
   * @median_trumps: (out):
   */
122
  void tarot_features_count_trumps (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
123
124
125
126
127
128
                                    size_t *n_trumps,
                                    TarotNumber * max_trump,
                                    TarotNumber * min_trump,
                                    TarotNumber * q1_trumps,
                                    TarotNumber * q3_trumps,
                                    TarotNumber * median_trumps);
129
130
131

  /**
   * tarot_strategy_bid:
Vivien Kraus's avatar
Vivien Kraus committed
132
133
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
134
   * @bid: (out):
135
   */
136
  void tarot_strategy_bid (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
137
138
                           const struct TarotGameEvent *event,
                           TarotBid * bid);
139
140
141

  /**
   * tarot_strategy_outbid:
Vivien Kraus's avatar
Vivien Kraus committed
142
143
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
144
145
   * @outbid: (out):
   */
146
  void tarot_strategy_outbid (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
147
148
                              const struct TarotGameEvent *event,
                              int *outbid);
149
150
151

  /**
   * tarot_strategy_call_by_length:
Vivien Kraus's avatar
Vivien Kraus committed
152
153
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
154
155
156
157
158
   * @shortest: (out) (type boolean):
   * @second_shortest: (out) (type boolean):
   * @second_longest: (out) (type boolean):
   * @longest: (out) (type boolean):
   */
159
  void tarot_strategy_call_by_length (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
160
161
162
163
                                      const struct TarotGameEvent *event,
                                      int *shortest,
                                      int *second_shortest,
                                      int *second_longest, int *longest);
164
165
166

  /**
   * tarot_strategy_call_myself:
Vivien Kraus's avatar
Vivien Kraus committed
167
168
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
169
170
   * @myself: (out) (type boolean):
   */
171
  void tarot_strategy_call_myself (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
172
173
                                   const struct TarotGameEvent *event,
                                   int *myself);
174
175
176

  /**
   * tarot_strategy_call_marriage:
Vivien Kraus's avatar
Vivien Kraus committed
177
178
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
179
180
   * @will_own_marriage: (out) (type boolean):
   */
181
  void tarot_strategy_call_marriage (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
182
183
                                     const struct TarotGameEvent *event,
                                     int *will_own_marriage);
184
185
186

  /**
   * tarot_strategy_discard_save:
Vivien Kraus's avatar
Vivien Kraus committed
187
188
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
189
190
191
192
   * @n_queens_saved: (out): number of queens for which we don't plan to own the king
   * @n_knights_saved: (out):
   * @n_jacks_saved: (out):
   */
193
  void tarot_strategy_discard_save (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
194
195
196
197
                                    const struct TarotGameEvent *event,
                                    size_t *n_queens_saved,
                                    size_t *n_knights_saved,
                                    size_t *n_jacks_saved);
198
199
200

  /**
   * tarot_strategy_discard_junk:
Vivien Kraus's avatar
Vivien Kraus committed
201
202
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
203
204
   * @n_lesser_cards_left_behind: (out):
   */
205
  void tarot_strategy_discard_junk (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
206
207
                                    const struct TarotGameEvent *event,
                                    size_t *n_lesser_cards_left_behind);
208
209
210

  /**
   * tarot_strategy_discard_by_length:
Vivien Kraus's avatar
Vivien Kraus committed
211
212
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
213
214
215
216
217
   * @from_shortest: (out): number of cards discarded from the shortest suit with the dog
   * @from_second_shortest: (out):
   * @from_second_longest: (out):
   * @from_longest: (out):
   */
218
  void tarot_strategy_discard_by_length (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
219
220
221
222
223
                                         const struct TarotGameEvent *event,
                                         size_t *from_shortest,
                                         size_t *from_second_shortest,
                                         size_t *from_second_longest,
                                         size_t *from_longest);
224
225
226

  /**
   * tarot_features_team:
Vivien Kraus's avatar
Vivien Kraus committed
227
   * @game: (type TarotGame):
228
229
230
   * @attack: (out) (type boolean): whether we may be an attacker
   * @defence: (out) (type boolean): whether we may be a defendent
   */
231
  void tarot_features_team (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
232
                            int *attack, int *defence);
233
234
235

  /**
   * tarot_features_trick_players:
Vivien Kraus's avatar
Vivien Kraus committed
236
   * @game: (type TarotGame):
237
238
239
   * @n_already_played: (out):
   * @n_allies_after_last_opponent: (out):
   */
240
  void tarot_features_trick_players (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
241
242
                                     size_t *n_already_played,
                                     size_t *n_allies_after_last_opponent);
243
244
245

  /**
   * tarot_features_minor_suit:
Vivien Kraus's avatar
Vivien Kraus committed
246
   * @game: (type TarotGame):
247
248
249
250
251
252
253
254
255
256
257
258
259
   * @ally_may_be_master: (out) (type boolean): whether noone can play
   * a stronger card of the minor suit than the current taker and the
   * current taker is an ally, or whether an ally who has still not
   * played yet may play the master card of the minor suit.  Same for
   * trumps, but we don't consider the possibility that someone
   * trumps.  That's why we have counted how many cards of the suit 
   * are remaining.
   * @ennemy_may_be_master: (out) (type boolean):
   * @called_suit: (out) (type boolean):
   * @n_times_lead: (out):
   * @n_remaining_cards: (out):
   * @n_remaining_points: (out):
   */
260
  void tarot_features_minor_suit (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
261
262
263
264
265
266
                                  int *called_suit,
                                  size_t *n_times_lead,
                                  size_t *n_remaining_cards,
                                  size_t *n_remaining_points,
                                  int *ally_may_be_master,
                                  int *ennemy_may_be_master);
267
268
269

  /**
   * tarot_features_trump:
Vivien Kraus's avatar
Vivien Kraus committed
270
   * @game: (type TarotGame):
271
272
273
274
   * @n_remaining: (out):
   * @ally_may_be_master: (out) (type boolean):
   * @ennemy_may_be_master: (out) (type boolean):
   */
275
  void tarot_features_trump (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
276
277
278
                             size_t *n_remaining,
                             int *ally_may_be_master,
                             int *ennemy_may_be_master);
279
280
281

  /**
   * tarot_features_points:
Vivien Kraus's avatar
Vivien Kraus committed
282
   * @game: (type TarotGame):
283
284
285
   * @n_halfpoints: (out):
   * @n_oudlers: (out):
   */
286
  void tarot_features_points (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
287
                              size_t *n_halfpoints, size_t *n_oudlers);
288
289
290

  /**
   * tarot_strategy_lead:
Vivien Kraus's avatar
Vivien Kraus committed
291
292
   * @game: (type TarotGame):
   * @card: (type TarotGameEvent):
293
294
295
296
297
   * @called_suit: (out) (type boolean):
   * @suit_length: (out):
   * @n_times_lead: (out):
   * @trumps: (out) (type boolean):
   */
298
  void tarot_strategy_lead (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
299
300
301
302
                            const struct TarotGameEvent *card,
                            int *called_suit,
                            size_t *suit_length,
                            size_t *n_times_lead, int *trumps);
303
304
305

  /**
   * tarot_strategy_purity:
Vivien Kraus's avatar
Vivien Kraus committed
306
307
   * @game: (type TarotGame):
   * @event: (type TarotGameEvent):
308
309
310
311
312
   * @n_smaller_kept: (out):
   * @n_greater_nonface_kept: (out):
   * @n_points_kept: (out):
   * @n_greater_kept: (out):
   */
313
  void tarot_strategy_purity (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
314
315
316
317
                              const struct TarotGameEvent *event,
                              size_t *n_smaller_kept,
                              size_t *n_greater_nonface_kept,
                              size_t *n_points_kept, size_t *n_greater_kept);
318
319
320

  /**
   * tarot_strategy_excuse:
Vivien Kraus's avatar
Vivien Kraus committed
321
322
   * @game: (type TarotGame):
   * @card: (type TarotGameEvent):
323
324
   * @excuse: (out) (type boolean):
   */
325
  void tarot_strategy_excuse (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
326
                              const struct TarotGameEvent *card, int *excuse);
327
328
329

  /**
   * tarot_strategy_trump_master:
Vivien Kraus's avatar
Vivien Kraus committed
330
331
   * @game: (type TarotGame):
   * @card: (type TarotGameEvent):
332
333
334
   * @actually_master: (out) (type boolean):
   * @obvious_master: (out) (type boolean):
   */
335
  void tarot_strategy_trump_master (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
336
337
338
                                    const struct TarotGameEvent *card,
                                    int *actually_master,
                                    int *obvious_master);
339
340
341

  /**
   * tarot_strategy_play_points:
Vivien Kraus's avatar
Vivien Kraus committed
342
343
   * @game: (type TarotGame):
   * @card: (type TarotGameEvent):
344
345
346
   * @n_halfpoints: (out):
   * @oudler: (out) (type bool):
   */
347
  void tarot_strategy_play_points (const struct TarotGame *game,
Vivien Kraus's avatar
Vivien Kraus committed
348
349
                                   const struct TarotGameEvent *card,
                                   size_t *n_halfpoints, int *oudler);
350
351
352

#ifdef __cplusplus
}
Vivien Kraus's avatar
Vivien Kraus committed
353
#endif                          /* __cplusplus */
354

Vivien Kraus's avatar
Vivien Kraus committed
355
#endif                          /* not H_TAROT_FEATURES_INCLUDED */