bstraehle commited on
Commit
d862ca7
1 Parent(s): 1347df5

Update multi_agent.py

Browse files
Files changed (1) hide show
  1. multi_agent.py +9 -23
multi_agent.py CHANGED
@@ -2,12 +2,9 @@ import chess, chess.svg, math
2
  from autogen import ConversableAgent, register_function
3
  from typing_extensions import Annotated
4
 
5
- g_moves = 0
6
- counter = 0
7
- made_move = False
8
-
9
- board = chess.Board()
10
- board_svgs = []
11
 
12
  def get_legal_moves() -> Annotated[str, "A list of legal moves in UCI format"]:
13
  return "Possible moves are: " + ",".join(
@@ -15,10 +12,6 @@ def get_legal_moves() -> Annotated[str, "A list of legal moves in UCI format"]:
15
  )
16
 
17
  def make_move(move: Annotated[str, "A move in UCI format."]) -> Annotated[str, "Result of the move."]:
18
- global counter
19
- counter += 1
20
- print("### "+str(counter)+" of "+str(g_moves))
21
-
22
  move = chess.Move.from_uci(move)
23
  board.push_uci(str(move))
24
  global made_move
@@ -63,22 +56,15 @@ def get_num_turns(num_moves):
63
  num_turns += 1
64
 
65
  return num_turns
66
-
67
- def run_multi_agent(llm_white, llm_black, num_moves):
68
- ###
69
- global g_moves
70
- g_moves = num_moves
71
- ###
72
- global counter
73
- counter = 0
74
- global made_move
75
- made_move = False
76
 
77
- global board
 
78
  board = chess.Board()
79
- global board_svgs
80
  board_svgs = []
81
- ###
 
 
 
82
 
83
  llm_config_white = {"model": llm_white}
84
  llm_config_black = {"model": llm_black}
 
2
  from autogen import ConversableAgent, register_function
3
  from typing_extensions import Annotated
4
 
5
+ board = None
6
+ board_svgs = None
7
+ made_move = None
 
 
 
8
 
9
  def get_legal_moves() -> Annotated[str, "A list of legal moves in UCI format"]:
10
  return "Possible moves are: " + ",".join(
 
12
  )
13
 
14
  def make_move(move: Annotated[str, "A move in UCI format."]) -> Annotated[str, "Result of the move."]:
 
 
 
 
15
  move = chess.Move.from_uci(move)
16
  board.push_uci(str(move))
17
  global made_move
 
56
  num_turns += 1
57
 
58
  return num_turns
 
 
 
 
 
 
 
 
 
 
59
 
60
+ def initialize():
61
+ global board, board_svgs, made_move
62
  board = chess.Board()
 
63
  board_svgs = []
64
+ made_move = False
65
+
66
+ def run_multi_agent(llm_white, llm_black, num_moves):
67
+ initialize()
68
 
69
  llm_config_white = {"model": llm_white}
70
  llm_config_black = {"model": llm_black}