agentscope
agentscope copied to clipboard
[Bug]:RuntimeError: Invalid move: [9, 8] is already occupied by o.
AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
I want to custom this logic in board_agent.py
def assert_valid_move(self, x: int, y: int) -> None:
"""Check if the move is valid."""
if not (0 <= x < self.size and 0 <= y < self.size):
raise RuntimeError(f"Invalid move: {[x, y]} out of board range.")
if not self.board[x, y] == EMPTY_PIECE:
raise RuntimeError(
f"Invalid move: {[x, y]} is already "
f"occupied by {self.board[x, y]}.",
)
after run game_gomoku with vllm config below
# vllm config
YOUR_MODEL_CONFIGURATION_NAME = "vllm_qwen2.5"
YOUR_MODEL_CONFIGURATION = {
"model_type": "openai_chat",
"config_name": YOUR_MODEL_CONFIGURATION_NAME,
"model_name": "/u01/vtpay/llm/Qwen2.5-7B-Instruct",
"api_key": "EMPTY",
"client_args": {
"base_url": "http://gpu152.dev.vllm.dmp.vn/v1/"
},
"generate_args": {
"temperature": 0.9
}
}
Error messages
RuntimeError: Invalid move: [9, 8] is already occupied by o.. I think to overcome this, I need custom assert_valid_move function. However, I have no ideal about this.
this full log
2024-11-21 13:32:37 | INFO | agentscope.manager._model:load_model_configs:115 - Load configs for model wrapper: vllm_qwen2.52024-11-21 13:32:38 | INFO | agentscope.models.model:__init__:203 - Initialize model by configuration [vllm_qwen2.5]2024-11-21 13:32:44 | WARNING | agentscope.models.openai_model:__init__:117 - fail to get max_length for /u01/vtpay/llm/Qwen2.5-7B-Instruct: 'Model [/u01/vtpay/llm/Qwen2.5-7B-Instruct] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212'2024-11-21 13:32:44 | INFO | agentscope.models.model:__init__:203 - Initialize model by configuration [vllm_qwen2.5]2024-11-21 13:32:44 | WARNING | agentscope.models.openai_model:__init__:117 - fail to get max_length for /u01/vtpay/llm/Qwen2.5-7B-Instruct: 'Model [/u01/vtpay/llm/Qwen2.5-7B-Instruct] not found in OPENAI_MAX_LENGTH. The last updated date is 20231212'Host: Welcome to the Gomoku game! Black player goes first. Please make your move.
Alice: {
"thought": "As the first move, it is best to place the piece in the center of the board to maximize control over potential lines. The center is [7, 7] in a 15x15 board.",
"move": [
7,
7
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
0000000o0000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Bob, it's your turn.
Bob: {
"thought": "The game is just starting, and the black player has placed their piece at [7, 7]. I should place my piece in a position that can potentially lead to a winning move while also blocking the opponent's potential wins.",
"move": [
7,
0
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000o0000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Alice, it's your turn.
Alice: {
"thought": "Bob has placed his piece on the far left side, but the board is still relatively open. I need to block potential lines he might form while also planning for my own lines. Placing a piece on [7, 9] helps to block a horizontal line and a vertical one.",
"move": [
7,
9
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000o0o00000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Bob, it's your turn.
Bob: {
"thought": "Alice has placed her piece at [7, 9]. To prevent Alice from forming a line of five in the next move, I should place my piece between her existing pieces at [7, 8]. This also helps in setting up potential winning lines for me.",
"move": [
7,
8
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000oxo00000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Alice, it's your turn.
Alice: {
"thought": "Bob has extended his line horizontally, but I can now block it with a vertical line. Placing my piece on [9, 8] will prevent Bob from forming a winning line while also setting up a vertical line that I can use to win.",
"move": [
9,
8
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000oxo00000
000000000000000
00000000o000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Bob, it's your turn.
Bob: {
"thought": "Alice has placed her piece at [9, 8]. To block her potential winning line and set up my own, I should place my piece at [8, 8]. This move will prevent Alice from forming a line of five vertically and helps to create a_trap for a potential winning line in the next move.",
"move": [
8,
8
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000oxo00000
00000000x000000
00000000o000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
Alice, it's your turn.
Alice: {
"thought": "Bob has extended his line horizontally again. To prevent Bob from forming a winning line and to set up my own potential lines, I should place my piece on [10, 8]. This move will block a potential horizontal line Bob could form while also contributing to my own vertical line.",
"move": [
10,
8
]
}
Host: The current board is as follows:
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
x000000oxo00000
00000000x000000
00000000o000000
00000000o000000
000000000000000
000000000000000
000000000000000
000000000000000
Bob, it's your turn.
Bob: {
"thought": "Alice has placed her piece at [10, 8]. This move creates a potential threat to form a line of five horizontally. To prevent that and to keep the board flexible for future moves, I should place my piece at [9, 8].",
"move": [
9,
8
]
}
Traceback (most recent call last):
File "/media/manhdt4/sda1/agentscope/examples/game_gomoku/code/game_gomoku.py", line 64, in <module>
msg = board(msg)
File "/media/manhdt4/sda1/miniconda3/envs/agentscope/lib/python3.9/site-packages/agentscope/agents/agent.py", line 135, in __call__
res = self.reply(*args, **kwargs)
File "/media/manhdt4/sda1/agentscope/examples/game_gomoku/code/board_agent.py", line 95, in reply
self.assert_valid_move(row, col)
File "/media/manhdt4/sda1/agentscope/examples/game_gomoku/code/board_agent.py", line 134, in assert_valid_move
raise RuntimeError(
RuntimeError: Invalid move: [9, 8] is already occupied by o.
Environment (please complete the following information):
- AgentScope Version: 0.1.2.dev0
- Python Version: 3.9.20
- OS: ubuntu 20.04