kaggle-environments 1.22.6__py3-none-any.whl → 1.24.3__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/connectx/visualizer/default/index.html +13 -0
- kaggle_environments/envs/connectx/visualizer/default/package.json +22 -0
- kaggle_environments/envs/connectx/visualizer/default/replays/test-replay.json +1129 -0
- kaggle_environments/envs/connectx/visualizer/default/src/main.ts +12 -0
- kaggle_environments/envs/connectx/visualizer/default/src/renderer.ts +396 -0
- kaggle_environments/envs/connectx/visualizer/default/src/style.css +38 -0
- kaggle_environments/envs/connectx/visualizer/default/tsconfig.json +4 -0
- kaggle_environments/envs/connectx/visualizer/default/vite.config.ts +7 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/repeated_poker.js +163 -88
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/index.html +13 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/package.json +23 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/replays/test-replay.json +1 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/scripts/print_first_steps.mjs +202 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/scripts/print_replay.mjs +215 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/scripts/print_steps_with_end_states.mjs +234 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/getRepeatedPokerStateForStep.js +260 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/components/utils.ts +61 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/debug_repeated_poker_renderer.ts +49 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_1.svg +22 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_10.svg +22 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_100.svg +48 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_25.svg +22 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/images/poker_chip_5.svg +22 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/main.ts +36 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/repeated_poker_renderer.ts +573 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/src/style.css +594 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/tsconfig.json +7 -0
- kaggle_environments/envs/open_spiel_env/games/repeated_poker/visualizer/default/vite.config.ts +6 -0
- kaggle_environments/envs/werewolf/README.md +190 -0
- kaggle_environments/envs/werewolf/harness/__init__.py +0 -0
- kaggle_environments/envs/werewolf/harness/base.py +773 -0
- kaggle_environments/envs/werewolf/harness/litellm_models.yaml +51 -0
- kaggle_environments/envs/werewolf/harness/main.py +54 -0
- kaggle_environments/envs/werewolf/harness/test_base.py +35 -0
- kaggle_environments/envs/werewolf/runner.py +146 -0
- kaggle_environments/envs/werewolf/scripts/__init__.py +0 -0
- kaggle_environments/envs/werewolf/scripts/add_audio.py +425 -0
- kaggle_environments/envs/werewolf/scripts/configs/audio/standard.yaml +24 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/block_basic.yaml +102 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/comprehensive.yaml +100 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/roundrobin_discussion_DisableDoctorSelfSave_DisableDoctorConsecutiveSave_large.yaml +104 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/roundrobin_discussion_large.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/roundrobin_discussion_small.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_DisableDoctorSelfSave_DisableDoctorConsecutiveSave.yaml +104 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_DisableDoctorSelfSave_SeerRevealTeam.yaml +105 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_DisableDoctorSelfSave_SeerRevealTeam_NightEliminationNoReveal_DayExileNoReveal.yaml +105 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_DisableDoctorSelfSave_SeerRevealTeam_NightEliminationRevealTeam_DayExileRevealTeam.yaml +105 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_disable_doctor_self_save.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_parallel_voting.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_parallel_voting_no_tie_exile.yaml +103 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/rule_experiment/standard_parallel_voting_roundbiddiscussion.yaml +105 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/run_config.yaml +58 -0
- kaggle_environments/envs/werewolf/scripts/configs/run/vertex_api_example_config.yaml +115 -0
- kaggle_environments/envs/werewolf/scripts/measure_cost.py +251 -0
- kaggle_environments/envs/werewolf/scripts/plot_existing_trajectories.py +135 -0
- kaggle_environments/envs/werewolf/scripts/rerender_html.py +87 -0
- kaggle_environments/envs/werewolf/scripts/run.py +93 -0
- kaggle_environments/envs/werewolf/scripts/run_block.py +237 -0
- kaggle_environments/envs/werewolf/scripts/run_pairwise_matrix.py +222 -0
- kaggle_environments/envs/werewolf/scripts/self_play.py +196 -0
- kaggle_environments/envs/werewolf/scripts/utils.py +47 -0
- kaggle_environments/envs/werewolf/werewolf.json +1 -1
- {kaggle_environments-1.22.6.dist-info → kaggle_environments-1.24.3.dist-info}/METADATA +1 -1
- {kaggle_environments-1.22.6.dist-info → kaggle_environments-1.24.3.dist-info}/RECORD +68 -7
- {kaggle_environments-1.22.6.dist-info → kaggle_environments-1.24.3.dist-info}/WHEEL +0 -0
- {kaggle_environments-1.22.6.dist-info → kaggle_environments-1.24.3.dist-info}/entry_points.txt +0 -0
- {kaggle_environments-1.22.6.dist-info → kaggle_environments-1.24.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
openrouter/deepseek/deepseek-chat-v3.1:
|
|
2
|
+
input_cost_per_token: 2e-7
|
|
3
|
+
output_cost_per_token: 8e-7
|
|
4
|
+
openrouter/openai/gpt-4o-mini:
|
|
5
|
+
input_cost_per_token: 1.5e-7
|
|
6
|
+
output_cost_per_token: 6e-7
|
|
7
|
+
openrouter/qwen/qwen3-235b-a22b-2507:
|
|
8
|
+
input_cost_per_token: 7.8e-8
|
|
9
|
+
output_cost_per_token: 3.12e-7
|
|
10
|
+
openrouter/z-ai/glm-4.5:
|
|
11
|
+
input_cost_per_token: 2e-7
|
|
12
|
+
output_cost_per_token: 8e-7
|
|
13
|
+
openrouter/openai/gpt-oss-120b:
|
|
14
|
+
input_cost_per_token: 7.2e-8
|
|
15
|
+
output_cost_per_token: 2.8e-7
|
|
16
|
+
openrouter/openai/gpt-oss-20b:
|
|
17
|
+
input_cost_per_token: 4e-8
|
|
18
|
+
output_cost_per_token: 1.5e-7
|
|
19
|
+
openrouter/qwen/qwen3-30b-a3b:
|
|
20
|
+
input_cost_per_token: 1e-7
|
|
21
|
+
output_cost_per_token: 3e-7
|
|
22
|
+
openrouter/openai/gpt-5:
|
|
23
|
+
input_cost_per_token: 1.25e-6
|
|
24
|
+
output_cost_per_token: 1e-5
|
|
25
|
+
openrouter/openai/gpt-4.1:
|
|
26
|
+
input_cost_per_token: 2e-6
|
|
27
|
+
output_cost_per_token: 8e-6
|
|
28
|
+
openrouter/anthropic/claude-sonnet-4:
|
|
29
|
+
input_cost_per_token: 3e-6
|
|
30
|
+
output_cost_per_token: 1.5e-5
|
|
31
|
+
openrouter/x-ai/grok-4:
|
|
32
|
+
input_cost_per_token: 3e-6
|
|
33
|
+
output_cost_per_token: 1.5e-5
|
|
34
|
+
openrouter/google/gemini-2.5-flash-lite:
|
|
35
|
+
input_cost_per_token: 1e-7
|
|
36
|
+
output_cost_per_token: 4e-7
|
|
37
|
+
openrouter/google/gemini-2.5-pro:
|
|
38
|
+
input_cost_per_token: 1.25e-6
|
|
39
|
+
output_cost_per_token: 1e-5
|
|
40
|
+
openrouter/google/gemini-2.5-flash:
|
|
41
|
+
input_cost_per_token: 3e-7
|
|
42
|
+
output_cost_per_token: 2.5e-6
|
|
43
|
+
vertex_ai/gemini-2.5-pro:
|
|
44
|
+
input_cost_per_token: 1.25e-6
|
|
45
|
+
output_cost_per_token: 1e-5
|
|
46
|
+
vertex_ai/gemini-2.5-flash:
|
|
47
|
+
input_cost_per_token: 3e-7
|
|
48
|
+
output_cost_per_token: 2.5e-6
|
|
49
|
+
vertex_ai/gemini-2.5-flash-lite:
|
|
50
|
+
input_cost_per_token: 1e-7
|
|
51
|
+
output_cost_per_token: 4e-7
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Main file for the Game Arena submission."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
_AGENT_OBJECT = None
|
|
7
|
+
_SETUP_COMPLETE = False
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def agent(observation, configuration):
|
|
11
|
+
"""Kaggle agent for Game Arena."""
|
|
12
|
+
global _AGENT_OBJECT, _SETUP_COMPLETE
|
|
13
|
+
|
|
14
|
+
if not _SETUP_COMPLETE:
|
|
15
|
+
print("--- Performing one-time agent setup... ---")
|
|
16
|
+
|
|
17
|
+
# 1. Add the vendored 'lib' directory to Python's search path.
|
|
18
|
+
print("Updating system path with vendored libraries...")
|
|
19
|
+
script_dir = os.path.dirname(configuration["__raw_path__"])
|
|
20
|
+
lib_dir = os.path.join(script_dir, "lib")
|
|
21
|
+
if lib_dir not in sys.path:
|
|
22
|
+
sys.path.insert(0, lib_dir)
|
|
23
|
+
print(f"System path updated. First entry is now: {sys.path[0]}")
|
|
24
|
+
|
|
25
|
+
# 2. Now that the path is set, we can import our libraries.
|
|
26
|
+
# pylint: disable=g-import-not-at-top
|
|
27
|
+
|
|
28
|
+
from kaggle_environments.envs.werewolf.werewolf import AgentFactoryWrapper, LLM_SYSTEM_PROMPT
|
|
29
|
+
from kaggle_environments.envs.werewolf.harness.base import LLMWerewolfAgent
|
|
30
|
+
|
|
31
|
+
if "MODEL_NAME" not in os.environ:
|
|
32
|
+
raise ValueError("MODEL_NAME was not specified as an environment variable. Agent cannot be configured.")
|
|
33
|
+
|
|
34
|
+
if "MODEL_PROXY_KEY" not in os.environ:
|
|
35
|
+
raise ValueError("MODEL_PROXY_KEY was not specified as an environment variable. "
|
|
36
|
+
"Model proxy cannot function correctly.")
|
|
37
|
+
|
|
38
|
+
if "MODEL_PROXY_URL" not in os.environ:
|
|
39
|
+
raise ValueError("MODEL_PROXY_URL was not injected. Agent cannot run.")
|
|
40
|
+
|
|
41
|
+
_AGENT_OBJECT = AgentFactoryWrapper(
|
|
42
|
+
agent_class=LLMWerewolfAgent,
|
|
43
|
+
model_name=os.environ["MODEL_NAME"],
|
|
44
|
+
system_prompt=LLM_SYSTEM_PROMPT,
|
|
45
|
+
litellm_model_proxy_kwargs={
|
|
46
|
+
"api_base": os.environ["MODEL_PROXY_URL"],
|
|
47
|
+
"api_key": os.environ["MODEL_PROXY_KEY"]
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
_SETUP_COMPLETE = True
|
|
52
|
+
print("--- Agent setup complete. ---")
|
|
53
|
+
|
|
54
|
+
return _AGENT_OBJECT(observation, configuration)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import litellm
|
|
5
|
+
import pytest
|
|
6
|
+
from dotenv import load_dotenv
|
|
7
|
+
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.mark.skip("Require the key to run test.")
|
|
12
|
+
def test_vertex_ai():
|
|
13
|
+
model = "vertex_ai/deepseek-ai/deepseek-r1-0528-maas"
|
|
14
|
+
file_path = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
|
|
15
|
+
with open(file_path, "r") as file:
|
|
16
|
+
vertex_credentials = json.load(file)
|
|
17
|
+
|
|
18
|
+
vertex_credentials_json = json.dumps(vertex_credentials)
|
|
19
|
+
|
|
20
|
+
response = litellm.completion(
|
|
21
|
+
model=model,
|
|
22
|
+
messages=[{"role": "user", "content": "hi"}],
|
|
23
|
+
temperature=0.7,
|
|
24
|
+
vertex_ai_project=os.environ["VERTEXAI_PROJECT"],
|
|
25
|
+
vertex_ai_location=os.environ["VERTEXAI_LOCATION"],
|
|
26
|
+
vertex_credentials=vertex_credentials_json,
|
|
27
|
+
)
|
|
28
|
+
print(response)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.skip("Require the key to run test.")
|
|
32
|
+
def test_together():
|
|
33
|
+
model = "together_ai/deepseek-ai/DeepSeek-R1"
|
|
34
|
+
response = litellm.completion(model=model, messages=[{"role": "user", "content": "hi"}])
|
|
35
|
+
print(response)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import random
|
|
4
|
+
import subprocess
|
|
5
|
+
import time
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
from kaggle_environments import PROJECT_ROOT, make
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LogExecutionTime:
|
|
14
|
+
"""
|
|
15
|
+
A context manager to log the execution time of a code block.
|
|
16
|
+
The elapsed time is stored in the `elapsed_time` attribute.
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
with LogExecutionTime(logger, "My Task") as timer:
|
|
21
|
+
# Code to be timed
|
|
22
|
+
time.sleep(1)
|
|
23
|
+
print(f"Task took {timer.elapsed_time:.2f} seconds.")
|
|
24
|
+
print(f"Formatted time: {timer.elapsed_time_formatted()}")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, logger_obj: logging.Logger, task_str: str):
|
|
28
|
+
"""
|
|
29
|
+
Initializes the context manager.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
logger_obj: The logger instance to use for output.
|
|
33
|
+
task_str: A descriptive string for the task being timed.
|
|
34
|
+
"""
|
|
35
|
+
self.logger = logger_obj
|
|
36
|
+
self.task_str = task_str
|
|
37
|
+
self.start_time = None
|
|
38
|
+
self.elapsed_time = 0.0
|
|
39
|
+
|
|
40
|
+
def __enter__(self):
|
|
41
|
+
"""Records the start time when entering the context."""
|
|
42
|
+
self.start_time = time.time()
|
|
43
|
+
self.logger.info(f"Starting: {self.task_str}")
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
47
|
+
"""Calculates and logs the elapsed time upon exiting the context."""
|
|
48
|
+
end_time = time.time()
|
|
49
|
+
self.elapsed_time = end_time - self.start_time
|
|
50
|
+
self.logger.info(f"Finished: {self.task_str} in {self.elapsed_time_formatted()}.")
|
|
51
|
+
|
|
52
|
+
def elapsed_time_formatted(self) -> str:
|
|
53
|
+
"""Returns the elapsed time as a formatted string (HH:MM:SS)."""
|
|
54
|
+
return time.strftime("%H:%M:%S", time.gmtime(self.elapsed_time))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def append_timestamp_to_dir(dir_path, append=True):
|
|
58
|
+
if not append:
|
|
59
|
+
return dir_path
|
|
60
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
61
|
+
out = dir_path + f"_{timestamp}"
|
|
62
|
+
return out
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def shuffle_roles_inplace(config):
|
|
66
|
+
agents = config["agents"]
|
|
67
|
+
roles = [agent["role"] for agent in agents]
|
|
68
|
+
random.shuffle(roles)
|
|
69
|
+
for new_role, agent in zip(roles, agents):
|
|
70
|
+
agent["role"] = new_role
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def run_werewolf(output_dir, base_name, config, agents, debug):
|
|
74
|
+
"""
|
|
75
|
+
Runs a game of Werewolf, saves the replay, and logs the execution time.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
output_dir (str): The directory where the output files will be saved.
|
|
79
|
+
base_name (str): The base name for the output files (HTML, JSON).
|
|
80
|
+
config (dict): The configuration for the Werewolf environment.
|
|
81
|
+
agents (list): A list of agents to participate in the game.
|
|
82
|
+
debug (bool): A flag to enable or disable debug mode.
|
|
83
|
+
"""
|
|
84
|
+
start_time = time.time()
|
|
85
|
+
logger.info(f"Results saved to {output_dir}.")
|
|
86
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
87
|
+
html_file = os.path.join(output_dir, f"{base_name}.html")
|
|
88
|
+
json_file = os.path.join(output_dir, f"{base_name}.json")
|
|
89
|
+
|
|
90
|
+
with LogExecutionTime(logger_obj=logger, task_str="env run") as timer:
|
|
91
|
+
env = make("werewolf", debug=debug, configuration=config)
|
|
92
|
+
env.run(agents)
|
|
93
|
+
|
|
94
|
+
env.info["total_run_time"] = timer.elapsed_time
|
|
95
|
+
env.info["total_run_time_formatted"] = timer.elapsed_time_formatted()
|
|
96
|
+
|
|
97
|
+
logger.info("Game finished")
|
|
98
|
+
env_out = env.render(mode="html")
|
|
99
|
+
with open(html_file, "w") as out:
|
|
100
|
+
out.write(env_out)
|
|
101
|
+
logger.info(f"HTML replay written to {html_file}")
|
|
102
|
+
env_out = env.render(mode="json")
|
|
103
|
+
with open(json_file, "w") as out:
|
|
104
|
+
out.write(env_out)
|
|
105
|
+
logger.info(f"JSON replay written to {json_file}")
|
|
106
|
+
end_time = time.time()
|
|
107
|
+
elapsed_time = end_time - start_time
|
|
108
|
+
formatted_time = time.strftime("%H:%M:%S", time.gmtime(elapsed_time))
|
|
109
|
+
logger.info(f"Script finished in {formatted_time}.")
|
|
110
|
+
return env
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def setup_logger(output_dir, base_name):
|
|
114
|
+
"""
|
|
115
|
+
Sets up a logger to output to both the console and a log file.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
output_dir (str): The directory where the log file will be saved.
|
|
119
|
+
base_name (str): The base name for the log file.
|
|
120
|
+
"""
|
|
121
|
+
log_file = os.path.join(output_dir, f"{base_name}.log")
|
|
122
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
123
|
+
handlers = [logging.StreamHandler(), logging.FileHandler(log_file, mode="w")]
|
|
124
|
+
logging.basicConfig(
|
|
125
|
+
level=logging.INFO,
|
|
126
|
+
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
127
|
+
handlers=handlers,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def log_git_hash():
|
|
132
|
+
try:
|
|
133
|
+
result = subprocess.run(
|
|
134
|
+
["git", "rev-parse", "HEAD"],
|
|
135
|
+
cwd=PROJECT_ROOT,
|
|
136
|
+
capture_output=True,
|
|
137
|
+
text=True,
|
|
138
|
+
check=False, # Don't raise exception on non-zero exit code
|
|
139
|
+
)
|
|
140
|
+
if result.returncode == 0:
|
|
141
|
+
git_hash = result.stdout.strip()
|
|
142
|
+
logger.info(f"Running from git commit: {git_hash}")
|
|
143
|
+
else:
|
|
144
|
+
logger.info("Not a git repository or git command failed.")
|
|
145
|
+
except FileNotFoundError:
|
|
146
|
+
logger.info("Git command not found.")
|
|
File without changes
|