kaggle-environments 1.23.6__py3-none-any.whl → 1.23.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kaggle-environments might be problematic. Click here for more details.
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/getRepeatedPokerStateForStep.js +7 -210
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/repeated_poker_renderer.js +2 -0
- {kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/METADATA +1 -1
- {kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/RECORD +7 -7
- {kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/WHEEL +0 -0
- {kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/entry_points.txt +0 -0
- {kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { getActionStringsFromACPC } from "@kaggle-environments/core";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const moves = [];
|
|
5
|
-
const streets = bettingString.split('/');
|
|
6
|
-
for (let streetIndex = 0; streetIndex < streets.length; streetIndex++) {
|
|
7
|
-
const streetAction = streets[streetIndex];
|
|
8
|
-
let i = 0;
|
|
9
|
-
while (i < streetAction.length) {
|
|
10
|
-
const char = streetAction[i];
|
|
11
|
-
if (char === 'r') {
|
|
12
|
-
let amount = '';
|
|
13
|
-
i++;
|
|
14
|
-
while (i < streetAction.length && streetAction[i] >= '0' && streetAction[i] <= '9') {
|
|
15
|
-
amount += streetAction[i];
|
|
16
|
-
i++;
|
|
17
|
-
}
|
|
18
|
-
moves.push(`r${amount}`);
|
|
19
|
-
} else {
|
|
20
|
-
moves.push(char);
|
|
21
|
-
i++;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const lastMove = moves.length > 0 ? moves[moves.length - 1] : null;
|
|
27
|
-
const actionStrings = Array(numPlayers).fill('');
|
|
28
|
-
|
|
29
|
-
if (lastMove) {
|
|
30
|
-
if (typeof nextPlayerIndex === 'number' && nextPlayerIndex >= 0) {
|
|
31
|
-
const lastActor = (nextPlayerIndex + numPlayers - 1) % numPlayers;
|
|
32
|
-
actionStrings[lastActor] = lastMove;
|
|
33
|
-
} else {
|
|
34
|
-
const inferredActor = (moves.length - 1) % numPlayers;
|
|
35
|
-
actionStrings[inferredActor] = lastMove;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return actionStrings;
|
|
40
|
-
}
|
|
3
|
+
const PLACEHOLDER_CARD = '2c';
|
|
41
4
|
|
|
42
5
|
function _parseStepHistoryData(universalPokerJSON, nextPlayerIndex, numPlayers = 2) {
|
|
43
6
|
const result = {
|
|
@@ -96,7 +59,7 @@ function _parseStepHistoryData(universalPokerJSON, nextPlayerIndex, numPlayers =
|
|
|
96
59
|
|
|
97
60
|
const bettingString = stateParts.slice(2, stateParts.length - 1).join(':');
|
|
98
61
|
if (bettingString) {
|
|
99
|
-
result.playerActionStrings =
|
|
62
|
+
result.playerActionStrings = getActionStringsFromACPC(
|
|
100
63
|
bettingString,
|
|
101
64
|
nextPlayerIndex,
|
|
102
65
|
numPlayers
|
|
@@ -133,47 +96,7 @@ function sanitizeCardList(cards) {
|
|
|
133
96
|
return (cards || []).filter((card) => card);
|
|
134
97
|
}
|
|
135
98
|
|
|
136
|
-
function formatActionDisplay(actionString) {
|
|
137
|
-
if (!actionString) {
|
|
138
|
-
return '';
|
|
139
|
-
}
|
|
140
|
-
const playerMatch = actionString.match(/move=([^\s]+)/);
|
|
141
|
-
if (!playerMatch) {
|
|
142
|
-
return '';
|
|
143
|
-
}
|
|
144
|
-
const moveRaw = playerMatch[1];
|
|
145
|
-
const moveLower = moveRaw.toLowerCase();
|
|
146
|
-
if (moveLower.startsWith('bet') || moveLower.startsWith('raise')) {
|
|
147
|
-
const amountMatch = moveRaw.match(/\d+/);
|
|
148
|
-
return amountMatch ? `r${amountMatch[0]}` : 'r';
|
|
149
|
-
}
|
|
150
|
-
if (moveLower === 'call') {
|
|
151
|
-
return 'c';
|
|
152
|
-
}
|
|
153
|
-
if (moveLower === 'check') {
|
|
154
|
-
return 'k';
|
|
155
|
-
}
|
|
156
|
-
if (moveLower === 'fold') {
|
|
157
|
-
return 'f';
|
|
158
|
-
}
|
|
159
|
-
return moveRaw;
|
|
160
|
-
}
|
|
161
99
|
|
|
162
|
-
function getBlinds(configuration) {
|
|
163
|
-
const blindConfig = configuration?.openSpielGameParameters?.universal_poker_game_string?.blind;
|
|
164
|
-
if (typeof blindConfig !== 'string') {
|
|
165
|
-
return { bigBlind: null, smallBlind: null };
|
|
166
|
-
}
|
|
167
|
-
const parts = blindConfig
|
|
168
|
-
.trim()
|
|
169
|
-
.split(/\s+/)
|
|
170
|
-
.map((entry) => Number(entry))
|
|
171
|
-
.filter((n) => !Number.isNaN(n));
|
|
172
|
-
if (parts.length >= 2) {
|
|
173
|
-
return { bigBlind: parts[0], smallBlind: parts[1] };
|
|
174
|
-
}
|
|
175
|
-
return { bigBlind: null, smallBlind: null };
|
|
176
|
-
}
|
|
177
100
|
|
|
178
101
|
function getCommunityCardsFromUniversal(universal, numPlayers) {
|
|
179
102
|
const parsed = _parseStepHistoryData(universal, null, numPlayers);
|
|
@@ -195,135 +118,8 @@ function getHandCardsFromUniversal(universal, numPlayers) {
|
|
|
195
118
|
});
|
|
196
119
|
}
|
|
197
120
|
|
|
198
|
-
function buildTimeline(environment, numPlayers) {
|
|
199
|
-
const stateHistory = environment?.info?.stateHistory || [];
|
|
200
|
-
if (!stateHistory.length) {
|
|
201
|
-
return [];
|
|
202
|
-
}
|
|
203
121
|
|
|
204
|
-
const parsedStates = stateHistory.map((entry, idx) => {
|
|
205
|
-
const outer = JSON.parse(entry);
|
|
206
|
-
return {
|
|
207
|
-
idx,
|
|
208
|
-
outer,
|
|
209
|
-
universal: JSON.parse(outer.current_universal_poker_json)
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
122
|
|
|
213
|
-
const hands = [];
|
|
214
|
-
let currentHandNumber = parsedStates[0]?.outer?.hand_number ?? 0;
|
|
215
|
-
let currentStates = [];
|
|
216
|
-
parsedStates.forEach((stateInfo) => {
|
|
217
|
-
const handNumber = stateInfo.outer?.hand_number ?? currentHandNumber;
|
|
218
|
-
if (handNumber !== currentHandNumber) {
|
|
219
|
-
if (currentStates.length) {
|
|
220
|
-
hands.push({ handNumber: currentHandNumber, states: currentStates });
|
|
221
|
-
}
|
|
222
|
-
currentStates = [];
|
|
223
|
-
currentHandNumber = handNumber;
|
|
224
|
-
}
|
|
225
|
-
currentStates.push(stateInfo);
|
|
226
|
-
});
|
|
227
|
-
if (currentStates.length) {
|
|
228
|
-
hands.push({ handNumber: currentHandNumber, states: currentStates });
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const processedSteps = environment.__processedSteps || environment.steps || [];
|
|
232
|
-
const actionsByHand = new Map();
|
|
233
|
-
processedSteps.forEach((step) => {
|
|
234
|
-
const handNumber = step?.hand ?? 0;
|
|
235
|
-
if (!actionsByHand.has(handNumber)) {
|
|
236
|
-
actionsByHand.set(handNumber, []);
|
|
237
|
-
}
|
|
238
|
-
if (!step?.isEndState && step?.step?.action && step.step.action.submission !== -1) {
|
|
239
|
-
const actionString = step.step.action.actionString || '';
|
|
240
|
-
const playerMatch = actionString.match(/player=(\d+)/);
|
|
241
|
-
const playerIndex = playerMatch ? parseInt(playerMatch[1], 10) : null;
|
|
242
|
-
actionsByHand.get(handNumber).push({
|
|
243
|
-
playerIndex,
|
|
244
|
-
actionText: formatActionDisplay(actionString),
|
|
245
|
-
stateHistoryIndex: step.stateHistoryIndex
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const events = [];
|
|
251
|
-
let orderCounter = 0;
|
|
252
|
-
const pushEvent = (stateIndex, event) => {
|
|
253
|
-
events.push({
|
|
254
|
-
order: orderCounter++,
|
|
255
|
-
stateIndex,
|
|
256
|
-
highlightPlayer: event.highlightPlayer,
|
|
257
|
-
actionText: event.actionText,
|
|
258
|
-
hideHoleCards: event.hideHoleCards,
|
|
259
|
-
hideCommunity: event.hideCommunity
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
hands.forEach(({ handNumber, states }) => {
|
|
264
|
-
if (!states.length) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const firstState = states[0];
|
|
269
|
-
const dealer = firstState.outer?.dealer ?? 0;
|
|
270
|
-
const { bigBlind, smallBlind } = getBlinds(environment.configuration);
|
|
271
|
-
const smallBlindPlayer = dealer % numPlayers;
|
|
272
|
-
const bigBlindPlayer = (dealer + 1) % numPlayers;
|
|
273
|
-
|
|
274
|
-
pushEvent(firstState.idx, { highlightPlayer: null, actionText: '', hideHoleCards: true, hideCommunity: true });
|
|
275
|
-
pushEvent(firstState.idx, { highlightPlayer: smallBlindPlayer, actionText: smallBlind != null ? `SB ${smallBlind}` : 'SB', hideHoleCards: true, hideCommunity: true });
|
|
276
|
-
pushEvent(firstState.idx, { highlightPlayer: bigBlindPlayer, actionText: bigBlind != null ? `BB ${bigBlind}` : 'BB', hideHoleCards: true, hideCommunity: true });
|
|
277
|
-
|
|
278
|
-
const firstActionState = states.find((stateInfo) => stateInfo.universal.current_player !== -1) || firstState;
|
|
279
|
-
pushEvent(firstActionState.idx, { highlightPlayer: null, actionText: '', hideHoleCards: false, hideCommunity: true });
|
|
280
|
-
|
|
281
|
-
const actions = actionsByHand.get(handNumber) || [];
|
|
282
|
-
actions.forEach((action) => {
|
|
283
|
-
const targetIndex = typeof action.stateHistoryIndex === 'number' ? action.stateHistoryIndex : states[0].idx;
|
|
284
|
-
const postState = states.find((stateInfo) => stateInfo.idx > targetIndex) || states[states.length - 1];
|
|
285
|
-
pushEvent(postState.idx, {
|
|
286
|
-
highlightPlayer: action.playerIndex,
|
|
287
|
-
actionText: action.actionText,
|
|
288
|
-
hideHoleCards: false,
|
|
289
|
-
hideCommunity: false
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
let currentStageCommunityLength = 0;
|
|
294
|
-
states.forEach((stateInfo) => {
|
|
295
|
-
const communityCards = getCommunityCardsFromUniversal(stateInfo.universal, numPlayers);
|
|
296
|
-
const communityLength = communityCards.length;
|
|
297
|
-
if (communityLength > currentStageCommunityLength) {
|
|
298
|
-
currentStageCommunityLength = communityLength;
|
|
299
|
-
if (communityLength === 3 || communityLength === 4 || communityLength === 5) {
|
|
300
|
-
pushEvent(stateInfo.idx, {
|
|
301
|
-
highlightPlayer: null,
|
|
302
|
-
actionText: '',
|
|
303
|
-
hideHoleCards: false,
|
|
304
|
-
hideCommunity: false
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
events.sort((a, b) => a.order - b.order);
|
|
312
|
-
return events.map(({ stateIndex, highlightPlayer, actionText, hideHoleCards, hideCommunity }) => ({
|
|
313
|
-
stateIndex,
|
|
314
|
-
highlightPlayer,
|
|
315
|
-
actionText,
|
|
316
|
-
hideHoleCards: !!hideHoleCards,
|
|
317
|
-
hideCommunity: !!hideCommunity
|
|
318
|
-
}));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function getTimeline(environment, numPlayers) {
|
|
322
|
-
if (!environment.__timeline) {
|
|
323
|
-
environment.__timeline = buildTimeline(environment, numPlayers);
|
|
324
|
-
}
|
|
325
|
-
return environment.__timeline;
|
|
326
|
-
}
|
|
327
123
|
|
|
328
124
|
function getUniversalState(environment, index) {
|
|
329
125
|
const entry = environment?.info?.stateHistory?.[index];
|
|
@@ -343,12 +139,13 @@ export const getPokerStateForStep = (environment, step) => {
|
|
|
343
139
|
return null;
|
|
344
140
|
}
|
|
345
141
|
|
|
346
|
-
const
|
|
347
|
-
|
|
142
|
+
const event = environment.steps[step];
|
|
143
|
+
|
|
348
144
|
if (!event) {
|
|
349
145
|
return null;
|
|
350
146
|
}
|
|
351
|
-
|
|
147
|
+
|
|
148
|
+
const stateInfo = getUniversalState(environment, event.stateHistoryIndex);
|
|
352
149
|
if (!stateInfo) {
|
|
353
150
|
return null;
|
|
354
151
|
}
|
|
@@ -539,6 +539,7 @@ export function renderer(options) {
|
|
|
539
539
|
return defaultStateUiData;
|
|
540
540
|
}
|
|
541
541
|
|
|
542
|
+
|
|
542
543
|
return getPokerStateForStep(environment, step);
|
|
543
544
|
}
|
|
544
545
|
|
|
@@ -710,6 +711,7 @@ export function renderer(options) {
|
|
|
710
711
|
const uiData = _parseKagglePokerState(options);
|
|
711
712
|
_renderPokerTableUI(uiData, options);
|
|
712
713
|
|
|
714
|
+
|
|
713
715
|
// Apply initial scale
|
|
714
716
|
_applyScale(parent);
|
|
715
717
|
|
|
@@ -195,8 +195,8 @@ kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/
|
|
|
195
195
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/vite.config.ts,sha256=KhIjUn0WWhaoQzQ5YKuWjNndimRF0kFlYDgEnZ0cg7U,208
|
|
196
196
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/replays/test-replay.json,sha256=jf4ilR6SmOYPNohkIGJvmKP5Gju5FY6sfSStX1qtFZg,28919900
|
|
197
197
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/main.ts,sha256=Its2m61qv7RHlHUzIW6JkmySaHWq1h2bJ5sWY9woots,1000
|
|
198
|
-
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/repeated_poker_renderer.js,sha256=
|
|
199
|
-
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/getRepeatedPokerStateForStep.js,sha256=
|
|
198
|
+
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/repeated_poker_renderer.js,sha256=omKkYjciuJelgqlm-ce114YPwQhGa3tMs7N8qOzP8RI,26484
|
|
199
|
+
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/getRepeatedPokerStateForStep.js,sha256=f0jh-Fkpgfwbz9LrCSi0fx-twJnWWL63hnrMTx9SjsU,5491
|
|
200
200
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/utils.js,sha256=pXDAu4V2OppRCvMdJKQ56q1uFTJReMPIvBL6gwxIJoI,5734
|
|
201
201
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_1.svg,sha256=v9yCvpnaQAg8OSUJdJ5PhuTHm9_zXnww-9_7oR_DJpc,22160
|
|
202
202
|
kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_10.svg,sha256=z3CP2h5eUGlgBdqNoWGcioekAyPgiuzhyRNr-nbutOE,22160
|
|
@@ -279,8 +279,8 @@ kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_p
|
|
|
279
279
|
kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_parallel_voting_no_tie_exile.yaml,sha256=sfSFlFU4F7doZ-wXUWBl-JgJtmpjrLR-SpCAqKnUYeQ,3662
|
|
280
280
|
kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_parallel_voting_roundbiddiscussion.yaml,sha256=UGSLfOhmC-4pRqWsJvOtZRU0YLUuOMAGeEHtxTf3wf8,3710
|
|
281
281
|
kaggle_environments/static/player.html,sha256=Icl5yYscPe4BRoWt0HLOSRJWnznQq2MdTHHCaC2OrQQ,27753
|
|
282
|
-
kaggle_environments-1.23.
|
|
283
|
-
kaggle_environments-1.23.
|
|
284
|
-
kaggle_environments-1.23.
|
|
285
|
-
kaggle_environments-1.23.
|
|
286
|
-
kaggle_environments-1.23.
|
|
282
|
+
kaggle_environments-1.23.8.dist-info/entry_points.txt,sha256=h03sq76TdcHvXKcsre1Qm3lIni9dkWehu61xJqI-p8k,69
|
|
283
|
+
kaggle_environments-1.23.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
284
|
+
kaggle_environments-1.23.8.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
285
|
+
kaggle_environments-1.23.8.dist-info/METADATA,sha256=7_f7jDxi5Q9FopoGsxSe6xCx_SihDgqu_WzEWmRm7RI,916
|
|
286
|
+
kaggle_environments-1.23.8.dist-info/RECORD,,
|
|
File without changes
|
{kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{kaggle_environments-1.23.6.dist-info → kaggle_environments-1.23.8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|