Spaces:
Running
Running
remove typings
Browse files
agents.py
CHANGED
@@ -15,9 +15,6 @@ from mistralai import Mistral
|
|
15 |
|
16 |
# --- Poke-Env ---
|
17 |
from poke_env.player import Player
|
18 |
-
from poke_env.environment.battle import Battle
|
19 |
-
from poke_env.environment.move import Move
|
20 |
-
from poke_env.environment.pokemon import Pokemon
|
21 |
from typing import Optional, Dict, Any, Union
|
22 |
|
23 |
# --- Helper Function & Base Class ---
|
@@ -101,7 +98,7 @@ class LLMAgentBase(Player):
|
|
101 |
self.standard_tools = STANDARD_TOOL_SCHEMA
|
102 |
self.battle_history = []
|
103 |
|
104 |
-
def _format_battle_state(self, battle
|
105 |
active_pkmn = battle.active_pokemon
|
106 |
active_pkmn_info = f"Your active Pokemon: {active_pkmn.species} " \
|
107 |
f"(Type: {'/'.join(map(str, active_pkmn.types))}) " \
|
@@ -147,7 +144,7 @@ class LLMAgentBase(Player):
|
|
147 |
f"Opponent Side Conditions: {battle.opponent_side_conditions}"
|
148 |
return state_str.strip()
|
149 |
|
150 |
-
def _find_move_by_name(self, battle
|
151 |
normalized_name = normalize_name(move_name)
|
152 |
# Prioritize exact ID match
|
153 |
for move in battle.available_moves:
|
@@ -160,7 +157,7 @@ class LLMAgentBase(Player):
|
|
160 |
return move
|
161 |
return None
|
162 |
|
163 |
-
def _find_pokemon_by_name(self, battle
|
164 |
normalized_name = normalize_name(pokemon_name)
|
165 |
for pkmn in battle.available_switches:
|
166 |
# Normalize the species name for comparison
|
@@ -168,7 +165,7 @@ class LLMAgentBase(Player):
|
|
168 |
return pkmn
|
169 |
return None
|
170 |
|
171 |
-
async def choose_move(self, battle
|
172 |
battle_state_str = self._format_battle_state(battle)
|
173 |
decision_result = await self._get_llm_decision(battle_state_str)
|
174 |
print(decision_result)
|
|
|
15 |
|
16 |
# --- Poke-Env ---
|
17 |
from poke_env.player import Player
|
|
|
|
|
|
|
18 |
from typing import Optional, Dict, Any, Union
|
19 |
|
20 |
# --- Helper Function & Base Class ---
|
|
|
98 |
self.standard_tools = STANDARD_TOOL_SCHEMA
|
99 |
self.battle_history = []
|
100 |
|
101 |
+
def _format_battle_state(self, battle) -> str:
|
102 |
active_pkmn = battle.active_pokemon
|
103 |
active_pkmn_info = f"Your active Pokemon: {active_pkmn.species} " \
|
104 |
f"(Type: {'/'.join(map(str, active_pkmn.types))}) " \
|
|
|
144 |
f"Opponent Side Conditions: {battle.opponent_side_conditions}"
|
145 |
return state_str.strip()
|
146 |
|
147 |
+
def _find_move_by_name(self, battle, move_name: str) -> Optional[Move]:
|
148 |
normalized_name = normalize_name(move_name)
|
149 |
# Prioritize exact ID match
|
150 |
for move in battle.available_moves:
|
|
|
157 |
return move
|
158 |
return None
|
159 |
|
160 |
+
def _find_pokemon_by_name(self, battle, pokemon_name: str) -> Optional[Pokemon]:
|
161 |
normalized_name = normalize_name(pokemon_name)
|
162 |
for pkmn in battle.available_switches:
|
163 |
# Normalize the species name for comparison
|
|
|
165 |
return pkmn
|
166 |
return None
|
167 |
|
168 |
+
async def choose_move(self, battle) -> str:
|
169 |
battle_state_str = self._format_battle_state(battle)
|
170 |
decision_result = await self._get_llm_decision(battle_state_str)
|
171 |
print(decision_result)
|