diff --git a/src/App.vue b/src/App.vue index 4f9d6f49640a3ffccd83d02ce381267f4bc55cf5..106a6e218c4300007ee8e231c2387e05f0aa153c 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 a64f46d7d77ca2a94c7422932727fe6f187c252c..346120654218793271a1855dd3e0988cdfaaa43e 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 +}