-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver.xh
45 lines (38 loc) · 1.42 KB
/
driver.xh
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
#include <unification.xh>
#include <list.xh>
#include <map.xh>
#include <prolog_utils.xh>
#include <string.xh>
#include <vector.xh>
#include <state.xh>
#include <stdio.h>
#include <stdlib.h>
#ifndef _DRIVER_XH
#define _DRIVER_XH
struct TurnInfo {
PlayerId player, dealer;
unsigned handNum;
PlayerId startingPlayer;
unsigned turnNum;
};
typedef struct TurnInfo TurnInfo;
TurnInfo nextTurn(TurnInfo turn, unsigned numPlayers, _Bool redeal, _Bool newDeck);
typedef closure<(State s, const Hand h, const Hand hands[], const Hand discard, const unsigned handSizes[],
TurnInfo turn, vector<Action> actions) -> unsigned> PlayerCallback;
struct Player {
const char *name;
PlayerCallback getAction;
closure<(State s, TurnInfo turn, Action action) -> void> notifyAction;
};
typedef struct Player Player;
PlayerId playGame(
unsigned numPlayers, _Bool partners, _Bool openHands, Player players[numPlayers],
closure<(PlayerId) -> void> updateTurn,
closure<(PlayerId, Hand) -> void> updateHand,
closure<(State) -> void> updateState,
closure<(PlayerId, unsigned) -> void> handleDeal,
closure<(PlayerId, Action) -> void> handleAction,
closure<(PlayerId) -> void> handleWin);
PlayerId playQuietGame(unsigned numPlayers, _Bool partners, _Bool openHands, Player players[numPlayers]);
PlayerId playConsoleGame(unsigned numPlayers, _Bool partners, _Bool openHands, Player players[numPlayers], FILE *out);
#endif