Update multi_agent.py
Browse files- multi_agent.py +11 -10
multi_agent.py
CHANGED
@@ -18,13 +18,13 @@ def make_move(move: Annotated[str, "A move in UCI format."]) -> Annotated[str, "
|
|
18 |
global made_move
|
19 |
made_move = True
|
20 |
|
21 |
-
|
22 |
board,
|
23 |
arrows=[(move.from_square, move.to_square)],
|
24 |
fill={move.from_square: "gray"},
|
25 |
size=250
|
26 |
-
)
|
27 |
-
|
28 |
piece = board.piece_at(move.to_square)
|
29 |
piece_symbol = piece.unicode_symbol()
|
30 |
piece_name = (
|
@@ -32,15 +32,14 @@ def make_move(move: Annotated[str, "A move in UCI format."]) -> Annotated[str, "
|
|
32 |
if piece_symbol.isupper()
|
33 |
else chess.piece_name(piece.piece_type)
|
34 |
)
|
35 |
-
|
36 |
-
board_svgs.append(svg)
|
37 |
-
|
38 |
return f"Moved {piece_name} ({piece_symbol}) from "\
|
39 |
-
|
40 |
-
|
41 |
|
42 |
def check_made_move(msg):
|
43 |
global made_move
|
|
|
44 |
if made_move:
|
45 |
made_move = False
|
46 |
return True
|
@@ -121,6 +120,8 @@ def run_multi_agent(llm_white, llm_black, num_moves):
|
|
121 |
)
|
122 |
|
123 |
num_turns = math.ceil(num_moves / 2)
|
|
|
|
|
124 |
|
125 |
chat_result = player_black.initiate_chat(
|
126 |
player_white,
|
@@ -147,8 +148,8 @@ def run_multi_agent(llm_white, llm_black, num_moves):
|
|
147 |
|
148 |
num_move += 1
|
149 |
|
150 |
-
if num_move == num_moves:
|
151 |
-
|
152 |
|
153 |
result = result.rstrip("<br><br>")
|
154 |
|
|
|
18 |
global made_move
|
19 |
made_move = True
|
20 |
|
21 |
+
board_svgs.append(chess.svg.board(
|
22 |
board,
|
23 |
arrows=[(move.from_square, move.to_square)],
|
24 |
fill={move.from_square: "gray"},
|
25 |
size=250
|
26 |
+
))
|
27 |
+
|
28 |
piece = board.piece_at(move.to_square)
|
29 |
piece_symbol = piece.unicode_symbol()
|
30 |
piece_name = (
|
|
|
32 |
if piece_symbol.isupper()
|
33 |
else chess.piece_name(piece.piece_type)
|
34 |
)
|
35 |
+
|
|
|
|
|
36 |
return f"Moved {piece_name} ({piece_symbol}) from "\
|
37 |
+
f"{chess.SQUARE_NAMES[move.from_square]} to "\
|
38 |
+
f"{chess.SQUARE_NAMES[move.to_square]}."
|
39 |
|
40 |
def check_made_move(msg):
|
41 |
global made_move
|
42 |
+
|
43 |
if made_move:
|
44 |
made_move = False
|
45 |
return True
|
|
|
120 |
)
|
121 |
|
122 |
num_turns = math.ceil(num_moves / 2)
|
123 |
+
print("# " + num_moves)
|
124 |
+
print("# " + num_turns)
|
125 |
|
126 |
chat_result = player_black.initiate_chat(
|
127 |
player_white,
|
|
|
148 |
|
149 |
num_move += 1
|
150 |
|
151 |
+
#if num_move == num_moves:
|
152 |
+
# break
|
153 |
|
154 |
result = result.rstrip("<br><br>")
|
155 |
|