diff --git a/src/utils/index.js b/src/utils/index.js index 643397661180e279121acbc01e71f9e73e35ff62..3c462ab07b0f5c70158adfa771804fb09301caf3 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)