avaskys commited on
Commit
899afb5
·
verified ·
1 Parent(s): f0a1871

Upload folder using huggingface_hub

Browse files
interface/feature_spec.json ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.1.0",
3
+ "card_encoding": {
4
+ "description": "Card index mapping for all models",
5
+ "order": [
6
+ "CJ", "SJ", "HJ", "DJ",
7
+ "CA", "CT", "CK", "CQ", "C9", "C8", "C7",
8
+ "SA", "ST", "SK", "SQ", "S9", "S8", "S7",
9
+ "HA", "HT", "HK", "HQ", "H9", "H8", "H7",
10
+ "DA", "DT", "DK", "DQ", "D9", "D8", "D7"
11
+ ],
12
+ "pad_index": 32,
13
+ "num_cards": 32
14
+ },
15
+ "game_type_encoding": {
16
+ "description": "Game type index mapping",
17
+ "DIAMONDS": 0,
18
+ "HEARTS": 1,
19
+ "SPADES": 2,
20
+ "CLUBS": 3,
21
+ "GRAND": 4,
22
+ "NULL": 5
23
+ },
24
+ "position_encoding": {
25
+ "description": "Player position index mapping",
26
+ "FOREHAND": 0,
27
+ "MIDDLEHAND": 1,
28
+ "REARHAND": 2
29
+ },
30
+ "bid_values": {
31
+ "description": "Valid bid values in Skat, indexed 0-62",
32
+ "values": [
33
+ 18, 20, 22, 23, 24, 27, 30, 33, 35, 36, 40, 44, 45, 46, 48,
34
+ 50, 54, 55, 59, 60, 63, 66, 70, 72, 77, 80, 81, 84, 88, 90,
35
+ 96, 99, 100, 108, 110, 117, 120, 121, 126, 130, 132, 135,
36
+ 140, 143, 144, 150, 153, 154, 156, 160, 162, 165, 168, 170,
37
+ 176, 180, 187, 192, 198, 204, 216, 240, 264
38
+ ],
39
+ "num_levels": 63
40
+ },
41
+ "models": {
42
+ "bidding_dense": {
43
+ "description": "Pre-skat bidding evaluation (MLP). Predicts win probability at each bid level.",
44
+ "inputs": {
45
+ "features": {
46
+ "shape": ["batch", 35],
47
+ "dtype": "float32",
48
+ "description": "Concatenated one-hot vectors: 32 cards + 3 position"
49
+ }
50
+ },
51
+ "outputs": {
52
+ "pickup_probs": {
53
+ "shape": ["batch", 63],
54
+ "dtype": "float32",
55
+ "description": "Win probability at each bid level if picking up skat"
56
+ },
57
+ "hand_probs": {
58
+ "shape": ["batch", 63],
59
+ "dtype": "float32",
60
+ "description": "Win probability at each bid level for hand game"
61
+ }
62
+ }
63
+ },
64
+ "bidding_transformer": {
65
+ "description": "Pre-skat bidding evaluation (Transformer). Uses attention on card indices.",
66
+ "inputs": {
67
+ "hand_cards": {
68
+ "shape": ["batch", 10],
69
+ "dtype": "int64",
70
+ "description": "Card indices (0-31) for the 10 cards in hand"
71
+ },
72
+ "position": {
73
+ "shape": ["batch"],
74
+ "dtype": "int64",
75
+ "description": "Player position index (0-2)"
76
+ }
77
+ },
78
+ "outputs": {
79
+ "pickup_probs": {
80
+ "shape": ["batch", 63],
81
+ "dtype": "float32",
82
+ "description": "Win probability at each bid level if picking up skat"
83
+ },
84
+ "hand_probs": {
85
+ "shape": ["batch", 63],
86
+ "dtype": "float32",
87
+ "description": "Win probability at each bid level for hand game"
88
+ }
89
+ }
90
+ },
91
+ "game_eval_dense": {
92
+ "description": "Post-skat game evaluation (MLP). Predicts win probability for a game configuration.",
93
+ "inputs": {
94
+ "features": {
95
+ "shape": ["batch", 75],
96
+ "dtype": "float32",
97
+ "description": "Concatenated: 32 hand one-hot + 32 skat one-hot + 6 game type one-hot + 3 position one-hot + 1 hand flag + 1 normalized bid"
98
+ }
99
+ },
100
+ "outputs": {
101
+ "win_prob": {
102
+ "shape": ["batch"],
103
+ "dtype": "float32",
104
+ "description": "Probability of winning the game"
105
+ }
106
+ }
107
+ },
108
+ "game_eval_transformer": {
109
+ "description": "Post-skat game evaluation (Transformer). Uses attention on card indices.",
110
+ "inputs": {
111
+ "hand_cards": {
112
+ "shape": ["batch", 10],
113
+ "dtype": "int64",
114
+ "description": "Card indices (0-31) for the 10 cards in hand"
115
+ },
116
+ "skat_cards": {
117
+ "shape": ["batch", 2],
118
+ "dtype": "int64",
119
+ "description": "Card indices for skat cards, padded with 32"
120
+ },
121
+ "skat_len": {
122
+ "shape": ["batch"],
123
+ "dtype": "int64",
124
+ "description": "Actual number of skat cards (0, 1, or 2)"
125
+ },
126
+ "game_type": {
127
+ "shape": ["batch"],
128
+ "dtype": "int64",
129
+ "description": "Game type index (0-5)"
130
+ },
131
+ "position": {
132
+ "shape": ["batch"],
133
+ "dtype": "int64",
134
+ "description": "Player position index (0-2)"
135
+ },
136
+ "is_hand": {
137
+ "shape": ["batch"],
138
+ "dtype": "int64",
139
+ "description": "0 = pickup game, 1 = hand game"
140
+ },
141
+ "bid": {
142
+ "shape": ["batch"],
143
+ "dtype": "float32",
144
+ "description": "Normalized bid value (0-1 range, divide by 264)"
145
+ }
146
+ },
147
+ "outputs": {
148
+ "win_prob": {
149
+ "shape": ["batch"],
150
+ "dtype": "float32",
151
+ "description": "Probability of winning the game"
152
+ }
153
+ }
154
+ },
155
+ "card_play_dense": {
156
+ "description": "Card play policy (MLP). Predicts which card to play.",
157
+ "inputs": {
158
+ "features": {
159
+ "shape": ["batch", 268],
160
+ "dtype": "float32",
161
+ "description": "Full gameplay context vector (see card_play_dense_features for breakdown)"
162
+ }
163
+ },
164
+ "outputs": {
165
+ "logits": {
166
+ "shape": ["batch", 32],
167
+ "dtype": "float32",
168
+ "description": "Unnormalized scores for each card. Apply softmax and mask illegal cards."
169
+ }
170
+ }
171
+ },
172
+ "card_play_transformer": {
173
+ "description": "Card play policy (Transformer). Uses attention on game history.",
174
+ "inputs": {
175
+ "game_type": {
176
+ "shape": ["batch"],
177
+ "dtype": "int64",
178
+ "description": "Game type index (0-5)"
179
+ },
180
+ "declarer": {
181
+ "shape": ["batch"],
182
+ "dtype": "int64",
183
+ "description": "Relative declarer position: 0=me, 1=left opponent, 2=right opponent"
184
+ },
185
+ "is_ouvert": {
186
+ "shape": ["batch"],
187
+ "dtype": "int64",
188
+ "description": "0 = not ouvert, 1 = ouvert game"
189
+ },
190
+ "hand": {
191
+ "shape": ["batch", 10],
192
+ "dtype": "int64",
193
+ "description": "Card indices in hand, padded with 32"
194
+ },
195
+ "hand_len": {
196
+ "shape": ["batch"],
197
+ "dtype": "int64",
198
+ "description": "Actual number of cards in hand"
199
+ },
200
+ "ouvert_hand": {
201
+ "shape": ["batch", 10],
202
+ "dtype": "int64",
203
+ "description": "Declarer's visible cards in ouvert games, padded with 32"
204
+ },
205
+ "ouvert_hand_len": {
206
+ "shape": ["batch"],
207
+ "dtype": "int64",
208
+ "description": "Actual number of visible ouvert cards (0 if not applicable)"
209
+ },
210
+ "history": {
211
+ "shape": ["batch", 27, 2],
212
+ "dtype": "int64",
213
+ "description": "Previous moves as [player_index, card_index] pairs, padded"
214
+ },
215
+ "history_len": {
216
+ "shape": ["batch"],
217
+ "dtype": "int64",
218
+ "description": "Actual number of history entries"
219
+ },
220
+ "trick": {
221
+ "shape": ["batch", 2, 2],
222
+ "dtype": "int64",
223
+ "description": "Current trick as [player_index, card_index] pairs, padded"
224
+ },
225
+ "trick_len": {
226
+ "shape": ["batch"],
227
+ "dtype": "int64",
228
+ "description": "Number of cards in current trick (0-2)"
229
+ },
230
+ "legal_mask": {
231
+ "shape": ["batch", 32],
232
+ "dtype": "bool",
233
+ "description": "True for cards that are legal to play, following Skat suit rules: when following, must play led suit (jacks are trump in suit/grand games) if able; otherwise any card in hand is legal"
234
+ }
235
+ },
236
+ "outputs": {
237
+ "logits": {
238
+ "shape": ["batch", 32],
239
+ "dtype": "float32",
240
+ "description": "Scores for each card. Illegal cards are masked to -inf."
241
+ }
242
+ }
243
+ }
244
+ },
245
+ "card_play_dense_features": {
246
+ "description": "Breakdown of the 268-dimensional input vector for card_play_dense",
247
+ "layout": [
248
+ {"name": "hand", "start": 0, "end": 32, "description": "One-hot encoded hand (32 cards)"},
249
+ {"name": "skat", "start": 32, "end": 64, "description": "One-hot encoded skat (32 cards)"},
250
+ {"name": "history_me", "start": 64, "end": 96, "description": "Cards I have played (32 cards)"},
251
+ {"name": "history_left", "start": 96, "end": 128, "description": "Cards left opponent has played (32 cards)"},
252
+ {"name": "history_right", "start": 128, "end": 160, "description": "Cards right opponent has played (32 cards)"},
253
+ {"name": "trick_card_1", "start": 160, "end": 192, "description": "First card in current trick (32 cards)"},
254
+ {"name": "trick_card_2", "start": 192, "end": 224, "description": "Second card in current trick (32 cards)"},
255
+ {"name": "trick_leader", "start": 224, "end": 227, "description": "Who led this trick (3 positions)"},
256
+ {"name": "trick_len", "start": 227, "end": 229, "description": "Number of cards in trick (one-hot 0/1/2)"},
257
+ {"name": "game_type", "start": 229, "end": 235, "description": "Game type one-hot (6 types)"},
258
+ {"name": "is_ouvert", "start": 235, "end": 236, "description": "Is this an ouvert game?"},
259
+ {"name": "visible_hand", "start": 236, "end": 268, "description": "Declarer's visible hand in ouvert (32 cards)"}
260
+ ]
261
+ }
262
+ }
interface/test_vectors.json ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "description": "Reference inputs and expected outputs for validating implementations",
4
+ "test_cases": {
5
+ "card_encoding": [
6
+ {
7
+ "description": "First card (Club Jack)",
8
+ "card": "CJ",
9
+ "expected_index": 0
10
+ },
11
+ {
12
+ "description": "Last card (Diamond 7)",
13
+ "card": "D7",
14
+ "expected_index": 31
15
+ },
16
+ {
17
+ "description": "Spade Jack",
18
+ "card": "SJ",
19
+ "expected_index": 1
20
+ },
21
+ {
22
+ "description": "Club Ace",
23
+ "card": "CA",
24
+ "expected_index": 4
25
+ },
26
+ {
27
+ "description": "Heart 10",
28
+ "card": "HT",
29
+ "expected_index": 19
30
+ }
31
+ ],
32
+ "game_type_encoding": [
33
+ {
34
+ "game_type": "DIAMONDS",
35
+ "expected_index": 0
36
+ },
37
+ {
38
+ "game_type": "GRAND",
39
+ "expected_index": 4
40
+ },
41
+ {
42
+ "game_type": "NULL",
43
+ "expected_index": 5
44
+ }
45
+ ],
46
+ "position_encoding": [
47
+ {
48
+ "position": "FOREHAND",
49
+ "expected_index": 0
50
+ },
51
+ {
52
+ "position": "MIDDLEHAND",
53
+ "expected_index": 1
54
+ },
55
+ {
56
+ "position": "REARHAND",
57
+ "expected_index": 2
58
+ }
59
+ ],
60
+ "bidding_transformer": [
61
+ {
62
+ "description": "Strong Grand hand - all 4 Jacks + Aces",
63
+ "input": {
64
+ "hand_cards": ["CJ", "SJ", "HJ", "DJ", "CA", "SA", "HA", "DA", "CT", "ST"],
65
+ "position": "FOREHAND"
66
+ },
67
+ "expected": {
68
+ "description": "Should have high win probability at Grand bid levels",
69
+ "pickup_prob_at_bid_18_min": 0.9,
70
+ "hand_prob_at_bid_18_min": 0.85
71
+ }
72
+ },
73
+ {
74
+ "description": "Weak hand - no Jacks, scattered low cards",
75
+ "input": {
76
+ "hand_cards": ["C7", "C8", "S7", "S8", "H7", "H8", "D7", "D8", "C9", "S9"],
77
+ "position": "REARHAND"
78
+ },
79
+ "expected": {
80
+ "description": "Should have low win probability at most bid levels",
81
+ "pickup_prob_at_bid_18_max": 0.3,
82
+ "hand_prob_at_bid_18_max": 0.2
83
+ }
84
+ }
85
+ ],
86
+ "game_eval_transformer": [
87
+ {
88
+ "description": "Strong Clubs hand after skat pickup",
89
+ "input": {
90
+ "hand_cards": ["CJ", "SJ", "CA", "CT", "CK", "CQ", "C9", "C8", "SA", "ST"],
91
+ "skat_cards": ["C7", "D7"],
92
+ "skat_len": 2,
93
+ "game_type": "CLUBS",
94
+ "position": "FOREHAND",
95
+ "is_hand": 0,
96
+ "bid": 0.068
97
+ },
98
+ "expected": {
99
+ "description": "Should predict high win probability for Clubs",
100
+ "win_prob_min": 0.8
101
+ }
102
+ }
103
+ ],
104
+ "card_play_transformer": [
105
+ {
106
+ "description": "Opening lead in Clubs game as declarer with strong trumps",
107
+ "input": {
108
+ "game_type": "CLUBS",
109
+ "declarer": 0,
110
+ "is_ouvert": 0,
111
+ "hand": ["CJ", "SJ", "CA", "CT", "CK", "SA", "ST", "HA", "DA", "D7"],
112
+ "hand_len": 10,
113
+ "ouvert_hand": [],
114
+ "ouvert_hand_len": 0,
115
+ "history": [],
116
+ "history_len": 0,
117
+ "trick": [],
118
+ "trick_len": 0,
119
+ "legal_mask_cards": ["CJ", "SJ", "CA", "CT", "CK", "SA", "ST", "HA", "DA", "D7"]
120
+ },
121
+ "expected": {
122
+ "description": "Should prefer leading a Jack to draw trumps",
123
+ "top_cards": ["CJ", "SJ"],
124
+ "top_prob_min": 0.3
125
+ }
126
+ }
127
+ ]
128
+ },
129
+ "notes": {
130
+ "bid_normalization": "Normalize bid values by dividing by 264 (max bid)",
131
+ "card_indices": "Convert card names to indices using card_encoding.order",
132
+ "legal_mask": "Create boolean array of size 32, True for cards in hand that are legal to play",
133
+ "padding": "Use pad_index (32) for empty slots in variable-length sequences"
134
+ }
135
+ }