kaggle-environments 1.16.7__py2.py3-none-any.whl → 1.16.8__py2.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.

@@ -20,7 +20,7 @@ from .core import *
20
20
  from .main import http_request
21
21
  from . import errors
22
22
 
23
- __version__ = "1.16.7"
23
+ __version__ = "1.16.8"
24
24
 
25
25
  __all__ = ["Agent", "environments", "errors", "evaluate", "http_request",
26
26
  "make", "register", "utils", "__version__",
@@ -47,23 +47,14 @@ async function renderer(context) {
47
47
  let downloadButton = parent.querySelector("#copy-pgn");
48
48
  if (!downloadButton) {
49
49
  try {
50
- downloadButton = document.createElement("button");
51
- downloadButton.id = "copy-pgn";
52
- downloadButton.textContent = "Copy PGN";
53
- downloadButton.style.position = "absolute";
54
- downloadButton.style.top = "10px";
55
- downloadButton.style.left = "10px";
56
- downloadButton.style.zIndex = 1;
57
- parent.appendChild(downloadButton);
58
-
59
50
  const board = environment.steps[step][0].observation.board;
60
51
  const info = environment.info;
61
52
  const agent1 = info?.TeamNames?.[0] || "Agent 1";
62
53
  const agent2 = info?.TeamNames?.[1] || "Agent 2";
63
54
  const game = new Chess(board);
64
55
  let result = environment.rewards;
65
- if (result.some(r => r === undefined || r === null)) {
66
- result = result.map(r => r === undefined || r === null ? 0 : 1)
56
+ if (result.some((r) => r === undefined || r === null)) {
57
+ result = result.map((r) => (r === undefined || r === null ? 0 : 1));
67
58
  }
68
59
 
69
60
  game.header(
@@ -74,7 +65,7 @@ async function renderer(context) {
74
65
  "Black",
75
66
  agent2,
76
67
  "Result",
77
- result.join(" - ")
68
+ result.join("-")
78
69
  );
79
70
 
80
71
  const openingIdx = OPENINGS.indexOf(board);
@@ -98,17 +89,70 @@ async function renderer(context) {
98
89
  }
99
90
  }
100
91
 
92
+ const pgn = game.pgn();
93
+
94
+ downloadButton = document.createElement("button");
95
+ downloadButton.id = "copy-pgn";
96
+ downloadButton.textContent = "Copy PGN";
97
+ downloadButton.style.position = "absolute";
98
+ downloadButton.style.top = "10px";
99
+ downloadButton.style.left = "10px";
100
+ downloadButton.style.zIndex = 1;
101
+ parent.appendChild(downloadButton);
102
+
101
103
  downloadButton.addEventListener("click", async () => {
102
104
  try {
103
- await navigator.clipboard.writeText(game.pgn());
105
+ await navigator.clipboard.writeText(pgn);
104
106
  alert("PGN Copied");
107
+ return;
105
108
  } catch (err) {
106
- console.error("Failed to copy: ", err);
107
- alert("Failed to copy PGN");
109
+ console.info(
110
+ "Clipboard access failed. Fall back to display for manual copy."
111
+ );
112
+ }
113
+
114
+ try {
115
+ const pgnDiv = document.createElement("div");
116
+ downloadButton.textContent = "";
117
+ pgnDiv.style.position = "absolute";
118
+ pgnDiv.style.top = "8px";
119
+ pgnDiv.style.left = "8px";
120
+ pgnDiv.style.zIndex = 2;
121
+ pgnDiv.style.border = "1px solid black";
122
+ pgnDiv.style.padding = "8px";
123
+ pgnDiv.style.background = "#FFFFFF";
124
+ pgnDiv.style.fontFamily = "monospace";
125
+ pgnDiv.style.whiteSpace = "pre-wrap";
126
+
127
+ // Split the PGN into lines and add each to a span for better formatting
128
+ const pgnLines = pgn.split("\n");
129
+ pgnLines.forEach((line) => {
130
+ const lineSpan = document.createElement("span");
131
+ lineSpan.textContent = line + "\n";
132
+ pgnDiv.appendChild(lineSpan);
133
+ });
134
+ parent.appendChild(pgnDiv);
135
+ const closeButton = document.createElement("span");
136
+ closeButton.textContent = "×";
137
+ closeButton.style.position = "absolute";
138
+ closeButton.style.top = "5px";
139
+ closeButton.style.right = "5px";
140
+ closeButton.style.cursor = "pointer";
141
+ closeButton.style.float = "right";
142
+ closeButton.style.fontSize = "16px";
143
+ closeButton.style.marginLeft = "5px";
144
+ closeButton.addEventListener("click", () => {
145
+ downloadButton.textContent = "Copy PGN";
146
+ parent.removeChild(pgnDiv);
147
+ });
148
+ pgnDiv.appendChild(closeButton);
149
+ } catch (e) {
150
+ console.error("Cannot display div");
151
+ alert("PGN cannot be generated");
108
152
  }
109
153
  });
110
154
  } catch (e) {
111
- console.error('Cannot create game pgn')
155
+ console.error("Cannot create game pgn");
112
156
  console.error(e);
113
157
  }
114
158
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaggle-environments
3
- Version: 1.16.7
3
+ Version: 1.16.8
4
4
  Summary: Kaggle Environments
5
5
  Home-page: https://github.com/Kaggle/kaggle-environments
6
6
  Author: Kaggle
@@ -1,4 +1,4 @@
1
- kaggle_environments/__init__.py,sha256=bwbAjK5CWz6unr-mWc8HFf1bsbRzyJn4tWiK2tP3W3Q,1682
1
+ kaggle_environments/__init__.py,sha256=FnLe0VzS2blXtoM59BGPBbwYrt_VBzEO-eipZYSDaTs,1682
2
2
  kaggle_environments/agent.py,sha256=MGBOuCojql8vuODPdyPYJgKRnVAVI_D_YDl53J15aPM,6698
3
3
  kaggle_environments/api.py,sha256=eLBKqr11Ku4tdsMUdUqy74FIVEA_hdV3_QUpX84x3Z8,798
4
4
  kaggle_environments/core.py,sha256=IrEkN9cIA2djBAxI8Sz1GRpGNKjhqbnBdV6irAeTm8Q,27851
@@ -8,7 +8,7 @@ kaggle_environments/main.py,sha256=10wtcEFcGIjdOd9AEps5WOAwslc6Wsx3eZ43LXJa8jE,1
8
8
  kaggle_environments/schemas.json,sha256=zGzLyhqPdH6QQ0d48SrP5LKbvupprrWvgfQBerLqmhw,3307
9
9
  kaggle_environments/status_codes.json,sha256=6a8HuS_Vth95W0f2fov21QLdRfA3KbizUvjKmJhYtBc,995
10
10
  kaggle_environments/utils.py,sha256=FcI17PA4QK2-hyNp0dryS0TQ2pFlH9K19zDUMmuF4-E,5713
11
- kaggle_environments/envs/chess/chess.js,sha256=lMqqAawNyWwDkLeUrlb2DyysXvii3Bcn-7MCdx0Dq8s,34116
11
+ kaggle_environments/envs/chess/chess.js,sha256=EbV8wwnE0ZXX0MYVEv3Xknye96JY2O0yRiobR0RCYNc,35818
12
12
  kaggle_environments/envs/chess/chess.json,sha256=uo0J_Y2DDwv_T8Kyu1xfduUfzAi6T098LTqQm_EqcnU,1548
13
13
  kaggle_environments/envs/chess/chess.py,sha256=fON4l77eR8twHJo1YDcOT2iMxrvHZcIICMB62iYHZUA,7651
14
14
  kaggle_environments/envs/chess/test_chess.py,sha256=ayZEIWRSD3D6BqhJv0q_M5a-j8-pMm8kb4ACAW-DhBE,1748
@@ -201,9 +201,9 @@ kaggle_environments/envs/tictactoe/tictactoe.js,sha256=NZDT-oSG0a6a-rso9Ldh9qkJw
201
201
  kaggle_environments/envs/tictactoe/tictactoe.json,sha256=zMXZ8-fpT7FBhzz2FFBvRLn4XwtngjEqOieMvI6cCj8,1121
202
202
  kaggle_environments/envs/tictactoe/tictactoe.py,sha256=iLNU5V-lz7Xab-d1vpPMfU5jDM3QtgBUH63Y_SU7I9Y,3639
203
203
  kaggle_environments/static/player.html,sha256=XyVoe0XxMa2MO1fTDY_rjyjzPN-JZgbVwJIDoLSnlw0,23016
204
- kaggle_environments-1.16.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
205
- kaggle_environments-1.16.7.dist-info/METADATA,sha256=PnuAkVHY8z-bSq7uAqSuAzSQOmFiVKYSwWmirOUIgPw,10699
206
- kaggle_environments-1.16.7.dist-info/WHEEL,sha256=m9WAupmBd2JGDsXWQGJgMGXIWbQY3F5c2xBJbBhq0nY,110
207
- kaggle_environments-1.16.7.dist-info/entry_points.txt,sha256=HbVC-LKGQFV6lEEYBYyDTtrkHgdHJUWQ8_qt9KHGqz4,70
208
- kaggle_environments-1.16.7.dist-info/top_level.txt,sha256=v3MMWIPMQFcI-WuF_dJngHWe9Bb2yH_6p4wat1x4gAc,20
209
- kaggle_environments-1.16.7.dist-info/RECORD,,
204
+ kaggle_environments-1.16.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
205
+ kaggle_environments-1.16.8.dist-info/METADATA,sha256=VhqcmBNdk8Mx4bk3MQjCDLzti2WF-A8LsjEoqiCPKEU,10699
206
+ kaggle_environments-1.16.8.dist-info/WHEEL,sha256=m9WAupmBd2JGDsXWQGJgMGXIWbQY3F5c2xBJbBhq0nY,110
207
+ kaggle_environments-1.16.8.dist-info/entry_points.txt,sha256=HbVC-LKGQFV6lEEYBYyDTtrkHgdHJUWQ8_qt9KHGqz4,70
208
+ kaggle_environments-1.16.8.dist-info/top_level.txt,sha256=v3MMWIPMQFcI-WuF_dJngHWe9Bb2yH_6p4wat1x4gAc,20
209
+ kaggle_environments-1.16.8.dist-info/RECORD,,