From b11663273ab206d2901f5474bc52dbc6bdcbddfd Mon Sep 17 00:00:00 2001 From: 63db3122f0950a2aef64df95 <63db3122f0950a2aef64df95@devide> Date: Fri, 30 Jun 2023 08:43:00 +0000 Subject: [PATCH] Fri Jun 30 08:43:00 UTC 2023 inscode --- src/App.vue | 2 +- src/utils/index.js | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4f9d6f4..106a6e2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,7 +52,7 @@ function getStyle(item, row, col) {

- +

diff --git a/src/utils/index.js b/src/utils/index.js index a64f46d..3461206 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -23,6 +23,7 @@ export const directions = [ * @returns */ export function checkWin({ row, col, board, player, win_size, direction }) { + console.log(win_size) const _row = board.length; const _col = board[0].length const pieceType = player ?? board[row][col] @@ -92,7 +93,7 @@ export function robotPlay(board, robot, win_size) { if (oppWin.length >= win_size) { return [row, col] } else { - // 计算当前棋盘局面的得分 + // 这里要应该是要返回这个位置的分数 const horizontal = checkWin({ row, col, board, player: is_black, win_size, direction: getDirection("horizontal") }); const vertical = checkWin({ row, col, board, player: is_black, win_size, direction: getDirection("vertical") }); const diagonalDown = checkWin({ row, col, board, player: is_black, win_size, direction: getDirection("diagonalDown") }); @@ -128,3 +129,20 @@ function getDirection(direction) { return [0, 0]; } } + +/** + * 评估每个空位置的价值,从八个方向去计算 + * @param {object} Estimate + * @param {object} Estimate.board + * @param {number} Estimate.row + * @param {number} Estimate.col + * @param {number} Estimate.win + * @param {number[]} Estimate.direction + * @return {number} + */ +function estimateScore({board, row, col, win, direction}){ + const player = is_white + let res = 0 + + return res +} -- GitLab