kaggle-environments 1.14.3__py2.py3-none-any.whl → 1.14.6__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.

@@ -21,7 +21,7 @@ from .main import http_request
21
21
  from . import errors
22
22
  from . import utils
23
23
 
24
- __version__ = "1.14.3"
24
+ __version__ = "1.14.6"
25
25
 
26
26
  __all__ = ["Agent", "environments", "errors", "evaluate", "http_request",
27
27
  "make", "register", "utils", "__version__",
@@ -90,7 +90,7 @@ async function renderer(context) {
90
90
 
91
91
  const info = environment.info;
92
92
  const team1_text = info?.TeamNames?.[0] || "Team 1";
93
- const team2_text = info?.TeamNames?.[1] || "Team 2";
93
+ const team2_text = info?.TeamNames?.[2] || "Team 2";
94
94
 
95
95
  const ctx = canvas.getContext("2d");
96
96
  const padding = 20;
@@ -112,12 +112,13 @@ async function renderer(context) {
112
112
 
113
113
  // Keyword Row
114
114
  ctx.fillText("Keyword: " + state[1].observation.keyword, label_x, line_height * line);
115
+ ctx.fillText("Round: " + Math.floor(step / 3 + 1), team2_x, line_height * line);
115
116
 
116
117
  line += 2;
117
118
 
118
119
  // Team Row
119
120
  ctx.fillText(team1_text, team1_x, line_height * line);
120
- ctx.fillText(team2_text, team2_x, line_height *line);
121
+ ctx.fillText(team2_text, team2_x, line_height * line);
121
122
 
122
123
  line++;
123
124
 
@@ -7,6 +7,7 @@
7
7
  "configuration": {
8
8
  "episodeSteps": 61,
9
9
  "actTimeout": 60,
10
+ "runTimeout": 9600,
10
11
  "agentTimeout": {
11
12
  "description": "Obsolete field kept for backwards compatibility, please use observation.remainingOverageTime.",
12
13
  "type": "number",
@@ -68,4 +69,4 @@
68
69
  "defaults": ["ACTIVE", "INACTIVE", "ACTIVE", "INACTIVE"]
69
70
  }
70
71
  }
71
-
72
+
@@ -20,6 +20,17 @@ model = None
20
20
  tokenizer = None
21
21
  model_initialized = False
22
22
 
23
+ ERROR = "ERROR"
24
+ DONE = "DONE"
25
+ INACTIVE = "INACTIVE"
26
+ ACTIVE = "ACTIVE"
27
+ TIMEOUT = "TIMEOUT"
28
+
29
+ GUESS = "guess"
30
+ ASK = "ask"
31
+ GUESSER = "guesser"
32
+ ANSWERER = "guesser"
33
+
23
34
  keywords_list = json.loads(KEYWORDS_JSON)
24
35
  keyword_cat = random.choice(keywords_list)
25
36
  category = keyword_cat["category"]
@@ -31,7 +42,7 @@ alts = keyword_obj["alts"]
31
42
  def guesser_agent(obs):
32
43
  info_prompt = """You are playing a game of 20 questions where you ask the questions and try to figure out the keyword, which will be a real or fictional person, place, or thing. \nHere is what you know so far:\n{q_a_thread}"""
33
44
  questions_prompt = """Ask one yes or no question."""
34
- guess_prompt = """Guess the keyword. Only respond with the exact word/phrase. For example, if you think the keyword is [paris], don't respond with [I think the keyword is paris] or [Is the kewyord Paris?]. Respond only with the word [paris]."""
45
+ guess_prompt = """Guess the keyword. Only respond with the exact word/phrase. For example, if you think the keyword is [paris], don't respond with [I think the keyword is paris] or [Is the keyword Paris?]. Respond only with the word [paris]."""
35
46
 
36
47
  q_a_thread = ""
37
48
  for i in range(0, len(obs.answers)):
@@ -42,12 +53,12 @@ def guesser_agent(obs):
42
53
  )
43
54
 
44
55
  prompt = ""
45
- if obs.turnType == "ask":
56
+ if obs.turnType == ASK:
46
57
  prompt = "{}{}".format(
47
58
  info_prompt.format(q_a_thread=q_a_thread),
48
59
  questions_prompt
49
60
  )
50
- elif obs.turnType == "guess":
61
+ elif obs.turnType == GUESS:
51
62
  prompt = "{}{}".format(
52
63
  info_prompt.format(q_a_thread=q_a_thread),
53
64
  guess_prompt
@@ -73,7 +84,66 @@ def answerer_agent(obs):
73
84
  return ""
74
85
 
75
86
 
76
- agents = {"guesser": guesser_agent, "answerer": answerer_agent}
87
+ agents = {GUESSER: guesser_agent, ANSWERER: answerer_agent}
88
+
89
+ def guesser_action(active, inactive, step):
90
+ guessed = False
91
+ if not active.action:
92
+ active.status = ERROR
93
+ elif active.observation.turnType == ASK:
94
+ question = active.action[:2000]
95
+ active.observation.questions.append(question)
96
+ inactive.observation.questions.append(question)
97
+ elif active.observation.turnType == GUESS:
98
+ guess = active.action[:100]
99
+ active.observation.guesses.append(guess)
100
+ inactive.observation.guesses.append(guess)
101
+ if active.action and keyword_guessed(active.action):
102
+ guessed = True
103
+ score = 20 - int(step / 3)
104
+ end_game(active, inactive, score, DONE, DONE)
105
+ return guessed
106
+
107
+ def end_game(active, inactive, reward, status, inactive_status):
108
+ active.observation.keyword = keyword
109
+ active.observation.category = category
110
+ inactive.observation.keyword = keyword
111
+ inactive.observation.category = category
112
+ active.reward = reward
113
+ inactive.reward = reward
114
+ active.status = status
115
+ inactive.status = inactive_status
116
+
117
+
118
+ def answerer_action(active, inactive):
119
+ active.observation.keyword = keyword
120
+ active.observation.category = category
121
+ response = active.action
122
+ if not response:
123
+ response = "none"
124
+ end_game(active, inactive, -1, ERROR, DONE)
125
+ elif "yes" in response.lower():
126
+ response = "yes"
127
+ elif "no" in response.lower():
128
+ response = "no"
129
+ else:
130
+ response = "maybe"
131
+ end_game(active, inactive, -1, ERROR, DONE)
132
+ active.observation.answers.append(response)
133
+ inactive.observation.answers.append(response)
134
+
135
+ def increment_turn(active, inactive, step, guessed):
136
+ if step == 59 and not guessed:
137
+ end_game(active, inactive, -1, DONE, DONE)
138
+ elif active.observation.turnType == "guess":
139
+ active.observation.turnType = "ask"
140
+ elif active.observation.turnType == "ask":
141
+ active.observation.turnType = "guess"
142
+ active.status = INACTIVE
143
+ inactive.status = ACTIVE
144
+ else:
145
+ active.status = INACTIVE
146
+ inactive.status = ACTIVE
77
147
 
78
148
 
79
149
  def interpreter(state, env):
@@ -81,14 +151,14 @@ def interpreter(state, env):
81
151
  return state
82
152
 
83
153
  # Isolate the active and inactive agents.
84
- active1 = state[0] if state[0].status == "ACTIVE" else state[1]
85
- inactive1 = state[0] if state[0].status == "INACTIVE" else state[1]
86
- active2 = state[2] if state[2].status == "ACTIVE" else state[3]
87
- inactive2 = state[2] if state[2].status == "INACTIVE" else state[3]
88
- if active1.status == "DONE" and inactive1.status == "DONE":
154
+ active1 = state[0] if state[0].status == ACTIVE else state[1]
155
+ inactive1 = state[0] if state[0].status == INACTIVE else state[1]
156
+ active2 = state[2] if state[2].status == ACTIVE else state[3]
157
+ inactive2 = state[2] if state[2].status == INACTIVE else state[3]
158
+ if active1.status == DONE and inactive1.status == DONE:
89
159
  active1 = None
90
160
  inactive1 = None
91
- if active2.status == "DONE" or inactive2.status == "DONE":
161
+ if active2.status == DONE or inactive2.status == DONE:
92
162
  active2 = None
93
163
  inactive2 = None
94
164
  if active1 is None and inactive1 is None and active2 is None and inactive2 is None:
@@ -96,110 +166,46 @@ def interpreter(state, env):
96
166
 
97
167
  step = state[0].observation.step
98
168
 
169
+ end_early = (active1 and active1.status) in (TIMEOUT, ERROR) or (active2 and active2.status in (TIMEOUT, ERROR))
170
+ one_guessed = False
171
+ two_guessed = False
172
+
99
173
  if active1 is not None:
100
174
  guessed = False
101
- if active1.observation.role == "guesser":
102
- if active1.observation.turnType == "ask":
103
- active1.observation.questions.append(active1.action)
104
- inactive1.observation.questions.append(active1.action)
105
- elif active1.observation.turnType == "guess":
106
- active1.observation.guesses.append(active1.action)
107
- inactive1.observation.guesses.append(active1.action)
108
- if keyword_guessed(active1.action):
109
- guessed = True
110
- score = 20 - int(step / 3)
111
- active1.reward = score
112
- inactive1.reward = score
113
- active1.status = "DONE"
114
- inactive1.status = "DONE"
115
- active1.observation.keyword = keyword
116
- active1.observation.category = category
117
- inactive1.observation.keyword = keyword
118
- inactive1.observation.category = category
175
+ if active1.observation.role == GUESSER:
176
+ guessed = guesser_action(active1, inactive1, step)
177
+ one_guessed = guessed
119
178
  else:
120
- active1.observation.keyword = keyword
121
- active1.observation.category = category
122
- response = active1.action
123
- if response.lower().__contains__("yes"):
124
- response = "yes"
125
- elif response.lower().__contains__("no"):
126
- response = "no"
127
- else:
128
- response = "maybe"
129
- active1.observation.answers.append(response)
130
- inactive1.observation.answers.append(response)
131
-
132
- if step == 59 and not guessed:
133
- active1.observation.keyword = keyword
134
- active1.observation.category = category
135
- inactive1.observation.keyword = keyword
136
- inactive1.observation.category = category
137
- active1.reward = -1
138
- inactive1.reward = -1
139
- active1.status = "DONE"
140
- inactive1.status = "DONE"
141
- elif active1.observation.turnType == "guess":
142
- active1.observation.turnType = "ask"
143
- elif active1.observation.turnType == "ask":
144
- active1.observation.turnType = "guess"
145
- active1.status = "INACTIVE"
146
- inactive1.status = "ACTIVE"
179
+ answerer_action(active1, inactive1)
180
+
181
+ if active1.status in (TIMEOUT, ERROR):
182
+ end_game(active1, inactive1, 0, active1.status, DONE)
183
+ elif end_early:
184
+ end_game(active1, inactive1, 0, DONE, DONE)
147
185
  else:
148
- active1.status = "INACTIVE"
149
- inactive1.status = "ACTIVE"
186
+ increment_turn(active1, inactive1, step, guessed)
150
187
 
151
188
  if active2 is not None:
152
189
  guessed = False
153
- if active2.observation.role == "guesser":
154
- if active2.observation.turnType == "ask":
155
- active2.observation.questions.append(active2.action)
156
- inactive2.observation.questions.append(active2.action)
157
- elif active2.observation.turnType == "guess":
158
- active2.observation.guesses.append(active2.action)
159
- inactive2.observation.guesses.append(active2.action)
160
- if keyword_guessed(active2.action):
161
- guessed = True
162
- score = 20 - int(step / 3)
163
- active2.reward = score
164
- inactive2.reward = score
165
- active2.status = "DONE"
166
- inactive2.status = "DONE"
167
- active2.observation.keyword = keyword
168
- active2.observation.category = category
169
- inactive2.observation.keyword = keyword
170
- inactive2.observation.category = category
171
- else:
172
- active2.observation.keyword = keyword
173
- active2.observation.category = category
174
- response = active2.action
175
- if response.lower().__contains__("yes"):
176
- response = "yes"
177
- elif response.lower().__contains__("no"):
178
- response = "no"
179
- else:
180
- response = "maybe"
181
- active2.observation.answers.append(response)
182
- inactive2.observation.answers.append(response)
183
-
184
- if step == 59 and not guessed:
185
- active2.observation.keyword = keyword
186
- active2.observation.category = category
187
- inactive2.observation.keyword = keyword
188
- inactive2.observation.category = category
189
- active2.reward = -1
190
- inactive2.reward = -1
191
- active2.status = "DONE"
192
- inactive2.status = "DONE"
193
- elif active2.observation.turnType == "guess":
194
- active2.observation.turnType = "ask"
195
- elif active2.observation.turnType == "ask":
196
- active2.observation.turnType = "guess"
197
- active2.status = "INACTIVE"
198
- inactive2.status = "ACTIVE"
190
+ if active2.observation.role == GUESSER:
191
+ guessed = guesser_action(active2, inactive2, step)
192
+ two_guessed = guessed
199
193
  else:
200
- active2.status = "INACTIVE"
201
- inactive2.status = "ACTIVE"
194
+ answerer_action(active2, inactive2)
202
195
 
196
+ if active2.status in (TIMEOUT, ERROR):
197
+ end_game(active2, inactive2, 0, active2.status, DONE)
198
+ elif end_early:
199
+ end_game(active2, inactive2, 0, DONE, DONE)
200
+ else:
201
+ increment_turn(active2, inactive2, step, guessed)
202
+
203
+ # make sure to end the game if only one team guessed correctly this round
204
+ if one_guessed and not two_guessed:
205
+ end_game(active2, inactive2, 0, DONE, DONE)
206
+ elif two_guessed and not one_guessed:
207
+ end_game(active1, inactive1, 0, DONE, DONE)
208
+
203
209
  return state
204
210
 
205
211
 
@@ -207,7 +213,7 @@ def renderer(state, env):
207
213
 
208
214
  for s in state:
209
215
  print("role: ", s.observation.role)
210
- if s.observation.role == "guesser":
216
+ if s.observation.role == GUESSER:
211
217
  transcript = ""
212
218
  for i in range(0, len(s.observation.guesses)):
213
219
  transcript = "{}Q: {} A: {}\nG: {}\n".format(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaggle-environments
3
- Version: 1.14.3
3
+ Version: 1.14.6
4
4
  Summary: Kaggle Environments
5
5
  Home-page: https://github.com/Kaggle/kaggle-environments
6
6
  Author: Kaggle
@@ -10,17 +10,17 @@ Keywords: Kaggle
10
10
  Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: Flask (>=1.1.2)
14
- Requires-Dist: gymnasium (==0.29.0)
15
- Requires-Dist: jsonschema (>=3.0.1)
16
- Requires-Dist: numpy (>=1.19.5)
17
- Requires-Dist: pettingzoo (==1.24.0)
18
- Requires-Dist: requests (>=2.25.1)
19
- Requires-Dist: scipy (>=1.11.2)
20
- Requires-Dist: shimmy (>=1.2.1)
21
- Requires-Dist: stable-baselines3 (==2.1.0)
22
- Requires-Dist: transformers (>=4.33.1)
23
- Requires-Dist: vec-noise (>=1.1.4)
13
+ Requires-Dist: Flask >=1.1.2
14
+ Requires-Dist: gymnasium ==0.29.0
15
+ Requires-Dist: jsonschema >=3.0.1
16
+ Requires-Dist: numpy >=1.19.5
17
+ Requires-Dist: pettingzoo ==1.24.0
18
+ Requires-Dist: requests >=2.25.1
19
+ Requires-Dist: scipy >=1.11.2
20
+ Requires-Dist: shimmy >=1.2.1
21
+ Requires-Dist: stable-baselines3 ==2.1.0
22
+ Requires-Dist: transformers >=4.33.1
23
+ Requires-Dist: vec-noise >=1.1.4
24
24
 
25
25
  # [<img src="https://kaggle.com/static/images/site-logo.png" height="50" style="margin-bottom:-15px" />](https://kaggle.com) Environments
26
26
 
@@ -1,4 +1,4 @@
1
- kaggle_environments/__init__.py,sha256=nmRV4RENpsoopKO_dSA9WfbSOfTQ0JD4tgIhpz1HfJw,1702
1
+ kaggle_environments/__init__.py,sha256=hPRYE2tJ2sk-B3QLoCYsaoGabpxvNYM46oH9MeJG6m0,1702
2
2
  kaggle_environments/agent.py,sha256=BpYrAC6EOhJF3Wzynq-CWg8l-z5uXW1Lq4qUsyOM0ik,6203
3
3
  kaggle_environments/api.py,sha256=eLBKqr11Ku4tdsMUdUqy74FIVEA_hdV3_QUpX84x3Z8,798
4
4
  kaggle_environments/core.py,sha256=IrEkN9cIA2djBAxI8Sz1GRpGNKjhqbnBdV6irAeTm8Q,27851
@@ -70,9 +70,9 @@ kaggle_environments/envs/kore_fleets/starter_bots/ts/test/configuration.json,sha
70
70
  kaggle_environments/envs/kore_fleets/starter_bots/ts/test/fullob.json,sha256=lEWzlv1rqiDMRmLqiGIO3j6m2Uf7OMjXx0zXBplAz1M,6791
71
71
  kaggle_environments/envs/kore_fleets/starter_bots/ts/test/observation.json,sha256=SIgLl8uTPmv2T_-g3gsFaibh_DWfvZNlZS7yPXL1Cnc,5998
72
72
  kaggle_environments/envs/llm_20_questions/keywords.py,sha256=BnyVrV0_xbiDt_Td4YXSKae9hHndAo5YYfYVtyL4eS4,45282
73
- kaggle_environments/envs/llm_20_questions/llm_20_questions.js,sha256=qy6V_j7GOqjCbCowBdJ6dtr23HCvK2MdSbQWi-0blPY,5923
74
- kaggle_environments/envs/llm_20_questions/llm_20_questions.json,sha256=nFAPb4vc10qW3-WOOM-iEHtOro-ij7-Um4UdzRoK8Xc,2074
75
- kaggle_environments/envs/llm_20_questions/llm_20_questions.py,sha256=39ud8BnfwO9lyGViGQoKmRs3TUnqIR4EYbr0YjFC1y0,10141
73
+ kaggle_environments/envs/llm_20_questions/llm_20_questions.js,sha256=o30Nx1Tt0eAxBsQukmyxYlr7GuvptTUADWUnEnYDHe8,6009
74
+ kaggle_environments/envs/llm_20_questions/llm_20_questions.json,sha256=VYxgQEDCaJv910sQdE_FOtV2w1V83Y3C6nTjx4FFZyo,2101
75
+ kaggle_environments/envs/llm_20_questions/llm_20_questions.py,sha256=cvcujfKJRXo17S4-gHkPpJtFWavmD7jBoFggjw2yLo0,9341
76
76
  kaggle_environments/envs/lux_ai_2021/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
77
  kaggle_environments/envs/lux_ai_2021/agents.py,sha256=bDqsY17Jxrk69a8HXb96ex2U1ipKkQPVJuXxmiA5hMA,421
78
78
  kaggle_environments/envs/lux_ai_2021/index.html,sha256=4Ec1FuHuuH1EvkvlLOpNUUFYLovnS_IA-rOOHEUjcGY,1550
@@ -176,9 +176,9 @@ kaggle_environments/envs/tictactoe/tictactoe.js,sha256=NZDT-oSG0a6a-rso9Ldh9qkJw
176
176
  kaggle_environments/envs/tictactoe/tictactoe.json,sha256=zMXZ8-fpT7FBhzz2FFBvRLn4XwtngjEqOieMvI6cCj8,1121
177
177
  kaggle_environments/envs/tictactoe/tictactoe.py,sha256=iLNU5V-lz7Xab-d1vpPMfU5jDM3QtgBUH63Y_SU7I9Y,3639
178
178
  kaggle_environments/static/player.html,sha256=HH8qvFfTIDw8eZvw5W88jcCu58Lo4_eUQ1ak46KWVGQ,22945
179
- kaggle_environments-1.14.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
180
- kaggle_environments-1.14.3.dist-info/METADATA,sha256=oEgT1xFfbYa8xb-XRdMhdUNfehjJvN6POkNyMX-k4HA,10722
181
- kaggle_environments-1.14.3.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
182
- kaggle_environments-1.14.3.dist-info/entry_points.txt,sha256=HbVC-LKGQFV6lEEYBYyDTtrkHgdHJUWQ8_qt9KHGqz4,70
183
- kaggle_environments-1.14.3.dist-info/top_level.txt,sha256=v3MMWIPMQFcI-WuF_dJngHWe9Bb2yH_6p4wat1x4gAc,20
184
- kaggle_environments-1.14.3.dist-info/RECORD,,
179
+ kaggle_environments-1.14.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
180
+ kaggle_environments-1.14.6.dist-info/METADATA,sha256=V1iJ5xdkq_om0PoWL06DaLDvj0pmXAht0tOyz96XPWA,10700
181
+ kaggle_environments-1.14.6.dist-info/WHEEL,sha256=m9WAupmBd2JGDsXWQGJgMGXIWbQY3F5c2xBJbBhq0nY,110
182
+ kaggle_environments-1.14.6.dist-info/entry_points.txt,sha256=HbVC-LKGQFV6lEEYBYyDTtrkHgdHJUWQ8_qt9KHGqz4,70
183
+ kaggle_environments-1.14.6.dist-info/top_level.txt,sha256=v3MMWIPMQFcI-WuF_dJngHWe9Bb2yH_6p4wat1x4gAc,20
184
+ kaggle_environments-1.14.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.41.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any