From 892df0fd413b15b26ad398d4ae618a9d73267f40 Mon Sep 17 00:00:00 2001 From: 63db3122f0950a2aef64df95 <63db3122f0950a2aef64df95@devide> Date: Tue, 4 Jul 2023 02:07:00 +0000 Subject: [PATCH] Tue Jul 4 02:07:00 UTC 2023 inscode --- src/utils/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 5a1d48a..8e2a44c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -83,7 +83,7 @@ export function robotPlay(board, robot, win_size) { // 评估每个空位置的价值,从八个方向去计算 score = directions.reduce((r, [y, x]) => { - const square = getDirectionScore(board, row, col, [y, x], win_size, is_black) + getDirectionScore(board, row, col, [y * -1, x * -1], win_size, is_black) + const square = getDirectionScore(board, row, col, [y, x], win_size) + getDirectionScore(board, row, col, [y * -1, x * -1], win_size) return r + (10 ** square) }, 0) @@ -135,14 +135,14 @@ function getBoundary(size, num) { * @param {*} piece_type * @returns */ -function getDirectionScore(board, row, col, [y, x], win_size, piece_type) { +function getDirectionScore(board, row, col, [y, x], win_size) { const ROW = board.length const COL = board[0].length let res = 0 let _row = row + y let _col = col + x while (true) { - if (_row < 0 || _col < 0 || !board[_row] || board[_row][_col] !== piece_type) { + if (_row < 0 || _col < 0 || !board[_row] || board[_row][_col] !== is_black) { break; } res += 1 -- GitLab