Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,13 @@ import os
|
|
| 5 |
import random
|
| 6 |
import traceback
|
| 7 |
import logging
|
| 8 |
-
import threading
|
|
|
|
| 9 |
|
| 10 |
-
# --- [ Previous code for imports, configuration, logging setup remains the same ] ---
|
| 11 |
-
# Import poke-env components
|
| 12 |
from poke_env.player import Player, RandomPlayer
|
| 13 |
from poke_env import AccountConfiguration, ServerConfiguration
|
| 14 |
-
|
| 15 |
-
from agents import OpenAIAgent
|
| 16 |
|
| 17 |
# --- Configuration ---
|
| 18 |
POKE_SERVER_URL = "wss://jofthomas.com/showdown/websocket"
|
|
@@ -27,7 +26,6 @@ custom_config = ServerConfiguration(POKE_SERVER_URL, POKE_AUTH_URL)
|
|
| 27 |
|
| 28 |
|
| 29 |
# --- Agent Creation (Async - Required by poke-env) ---
|
| 30 |
-
# [ create_agent_async function remains exactly the same as the previous version ]
|
| 31 |
async def create_agent_async(agent_type: str, battle_format: str = DEFAULT_BATTLE_FORMAT) -> Player | str:
|
| 32 |
"""
|
| 33 |
Creates and initializes a SINGLE agent instance with a unique username.
|
|
@@ -37,7 +35,7 @@ async def create_agent_async(agent_type: str, battle_format: str = DEFAULT_BATTL
|
|
| 37 |
logging.info(f"Attempting to create agent of type: {agent_type}")
|
| 38 |
player: Player | None = None
|
| 39 |
error_message: str | None = None
|
| 40 |
-
username: str = "unknown_agent"
|
| 41 |
|
| 42 |
agent_suffix = random.randint(10000, 999999)
|
| 43 |
|
|
@@ -81,7 +79,6 @@ async def create_agent_async(agent_type: str, battle_format: str = DEFAULT_BATTL
|
|
| 81 |
return error_message
|
| 82 |
|
| 83 |
# --- Battle Invitation (Async - Required by poke-env) ---
|
| 84 |
-
# [ send_battle_invite_async function remains exactly the same as the previous version ]
|
| 85 |
async def send_battle_invite_async(player: Player, opponent_username: str, battle_format: str) -> str:
|
| 86 |
"""
|
| 87 |
Sends a challenge using the provided player object.
|
|
|
|
| 5 |
import random
|
| 6 |
import traceback
|
| 7 |
import logging
|
| 8 |
+
import threading
|
| 9 |
+
|
| 10 |
|
|
|
|
|
|
|
| 11 |
from poke_env.player import Player, RandomPlayer
|
| 12 |
from poke_env import AccountConfiguration, ServerConfiguration
|
| 13 |
+
|
| 14 |
+
from agents import OpenAIAgent
|
| 15 |
|
| 16 |
# --- Configuration ---
|
| 17 |
POKE_SERVER_URL = "wss://jofthomas.com/showdown/websocket"
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
# --- Agent Creation (Async - Required by poke-env) ---
|
|
|
|
| 29 |
async def create_agent_async(agent_type: str, battle_format: str = DEFAULT_BATTLE_FORMAT) -> Player | str:
|
| 30 |
"""
|
| 31 |
Creates and initializes a SINGLE agent instance with a unique username.
|
|
|
|
| 35 |
logging.info(f"Attempting to create agent of type: {agent_type}")
|
| 36 |
player: Player | None = None
|
| 37 |
error_message: str | None = None
|
| 38 |
+
username: str = "unknown_agent"
|
| 39 |
|
| 40 |
agent_suffix = random.randint(10000, 999999)
|
| 41 |
|
|
|
|
| 79 |
return error_message
|
| 80 |
|
| 81 |
# --- Battle Invitation (Async - Required by poke-env) ---
|
|
|
|
| 82 |
async def send_battle_invite_async(player: Player, opponent_username: str, battle_format: str) -> str:
|
| 83 |
"""
|
| 84 |
Sends a challenge using the provided player object.
|