From f2ad4e031391db0acd28cf693d6ed0b3d7379e73 Mon Sep 17 00:00:00 2001 From: 63db3122f0950a2aef64df95 <63db3122f0950a2aef64df95@devide> Date: Mon, 3 Jul 2023 10:43:00 +0000 Subject: [PATCH] Mon Jul 3 10:43:00 UTC 2023 inscode --- src/utils/index.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 6433976..3c462ab 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -81,21 +81,8 @@ export function robotPlay(board, robot, win_size) { let score = 0; const [row, col] = point; - // 判断在此空位上落子后是否获胜 - const win = checkWin({ row, col, board, player: robot, win_size }); - if (win) { - return [row, col] - } else { - // 判断对手是否能在这一个空位上获胜 - const oppWin = checkWin({ row, col, board, player: is_black, win_size }); - if (oppWin) { - return [row, col] - } else { - // 这里要应该是要返回这个位置的分数 - score = estimateScore({ row, col, board, win_size }) - console.log(score) - } - } + // 这里要应该是要返回这个位置的分数 + score = estimateScore({ row, col, board, win_size }) // 选取分数最高的空位 if (score >= maxScore) { @@ -173,7 +160,6 @@ function getDirectionScore(board, row, col, [y, x], win_size, piece_type) { * @return {number} */ function estimateScore({ board, row, col, win_size }) { - console.log(JSON.stringify(board)) return 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) return r + (10 ** square) -- GitLab