if self.check_win(row, col, NAME_TO_PIECE[x["name"]]):
content = f"The game ends, {x['name']} wins!"
self.game_end = True
else:
# change the board
self.board[row, col] = NAME_TO_PIECE[x["name"]]
# check if the game ends
if self.check_draw():
content = "The game ends in a draw!"
self.game_end = True
else:
next_player_name = (
NAME_BLACK if x["name"] == NAME_WHITE else NAME_WHITE
)
content = CURRENT_BOARD_PROMPT_TEMPLATE.format(
board=self.board2text(),
player=next_player_name,
)
My updated code
# change the board
self.board[row, col] = NAME_TO_PIECE[x["name"]]
# check if the game ends
if self.check_draw():
content = "The game ends in a draw!"
self.game_end = True
else:
next_player_name = (
NAME_BLACK if x["name"] == NAME_WHITE else NAME_WHITE
)
content = CURRENT_BOARD_PROMPT_TEMPLATE.format(
board=self.board2text(),
player=next_player_name,
)
if self.check_win(row, col, NAME_TO_PIECE[x["name"]]):
content = f"The game ends, {x['name']} wins!"
self.game_end = True
My Thinks
五子棋当有一方对角线上 或者 横竖线上存在五子连珠时即获胜,应该将黑白方选择的落棋点更新到board中,再去判断是否 Win !
目前你们官方写的是获取到当前Agent落棋点Row 和 Col,根据Row 和 Col判断当前行列上以及对角线是否存在五子连珠,但是忘记当前落棋点也是一个棋子!
Code
文件路径
Your official code
My updated code
😊可以定义一个User_Agent来与Model进行人机对弈来检测五子的情况是否结束