refactor
Browse files
agent.py
CHANGED
|
@@ -114,55 +114,6 @@ class RunResult:
|
|
| 114 |
|
| 115 |
SYSTEM_PROMPT = """You are an expert text adventure game player. Your goal is to explore, collect treasures, and maximize your score.
|
| 116 |
|
| 117 |
-
AVAILABLE TOOLS (use these via MCP):
|
| 118 |
-
1. get_valid_actions - Get Jericho valid actions for current location
|
| 119 |
-
2. play_action - Execute game commands (north, take lamp, open mailbox, etc.)
|
| 120 |
-
3. memory - Get current game state, score, and recent history
|
| 121 |
-
4. get_map - See explored locations and connections
|
| 122 |
-
5. inventory - Check what you're carrying
|
| 123 |
-
|
| 124 |
-
VALID GAME COMMANDS for play_action:
|
| 125 |
-
- Movement: north, south, east, west, northwest, northeast, southeast, southwest, up, down, enter, exit
|
| 126 |
-
- Objects: take <item>, drop <item>, open <thing>, close <thing>, examine <thing>
|
| 127 |
-
- Light: turn on lamp, turn off lamp
|
| 128 |
-
- Combat: attack <enemy> with <weapon>
|
| 129 |
-
- Other: inventory, look, read <thing>, wait
|
| 130 |
-
|
| 131 |
-
FORBIDDEN (will NOT work): check, inspect, search, grab, use, help
|
| 132 |
-
|
| 133 |
-
RESPOND IN THIS EXACT FORMAT (no markdown):
|
| 134 |
-
THOUGHT: <brief reasoning about what to do next>
|
| 135 |
-
TOOL: <tool_name>
|
| 136 |
-
ARGS: <JSON arguments>
|
| 137 |
-
|
| 138 |
-
Examples:
|
| 139 |
-
THOUGHT: I need to see what's around me.
|
| 140 |
-
TOOL: play_action
|
| 141 |
-
ARGS: {"action": "look"}
|
| 142 |
-
|
| 143 |
-
THOUGHT: Let me check my current state and score.
|
| 144 |
-
TOOL: memory
|
| 145 |
-
ARGS: {}
|
| 146 |
-
|
| 147 |
-
THOUGHT: The mailbox might contain something useful.
|
| 148 |
-
TOOL: play_action
|
| 149 |
-
ARGS: {"action": "open mailbox"}
|
| 150 |
-
|
| 151 |
-
STRATEGY:
|
| 152 |
-
1. Before moving moving to another place use get_map to make sure you are not going in circles and to check if there are unexplored paths in the current location.
|
| 153 |
-
2. If you want to check what useful items you could use in the environment use inventory tool e.g. check inventory if you are missing a key, or another object to interact with the environment.
|
| 154 |
-
5. Dont repeat the same action if it doesn't lead to new observations, try something different to make progress.
|
| 155 |
-
6. Avoid immediate backtracking unless there is a clear reason.
|
| 156 |
-
7. Before performing irreversible actions, consider whether further exploration might yield safer alternatives.
|
| 157 |
-
"""
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
# =============================================================================
|
| 161 |
-
# Student Agent Implementation
|
| 162 |
-
# =============================================================================
|
| 163 |
-
|
| 164 |
-
SYSTEM_PROMPT = """You are an expert text adventure game player. Your goal is to explore, collect treasures, and maximize your score.
|
| 165 |
-
|
| 166 |
AVAILABLE TOOLS:
|
| 167 |
1. get_valid_actions - Get valid actions for the current location.
|
| 168 |
2. play_action - Execute game commands (north, take lamp, open mailbox, etc.).
|
|
@@ -204,10 +155,8 @@ STRATEGY:
|
|
| 204 |
"""
|
| 205 |
|
| 206 |
# =============================================================================
|
| 207 |
-
# Agent Implementation
|
| 208 |
# =============================================================================
|
| 209 |
-
|
| 210 |
-
|
| 211 |
@dataclass
|
| 212 |
class LocationLog:
|
| 213 |
"""Tracks everything known about a specific room/location (Graph Node)."""
|
|
|
|
| 114 |
|
| 115 |
SYSTEM_PROMPT = """You are an expert text adventure game player. Your goal is to explore, collect treasures, and maximize your score.
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
AVAILABLE TOOLS:
|
| 118 |
1. get_valid_actions - Get valid actions for the current location.
|
| 119 |
2. play_action - Execute game commands (north, take lamp, open mailbox, etc.).
|
|
|
|
| 155 |
"""
|
| 156 |
|
| 157 |
# =============================================================================
|
| 158 |
+
# Student Agent Implementation
|
| 159 |
# =============================================================================
|
|
|
|
|
|
|
| 160 |
@dataclass
|
| 161 |
class LocationLog:
|
| 162 |
"""Tracks everything known about a specific room/location (Graph Node)."""
|