diff --git a/src/utils/index.js b/src/utils/index.js index fe33e58a4436c5b72c34b77aef1d92b2379208ac..b9737eb0fd1d165e6f9018c6c6a29d7ef02dee82 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -172,17 +172,21 @@ function getBoundary(size, num) { function getScore(board, row, col, win_size) { const ROW = board.length const COL = board[0].length + // 连续棋子数 let res = 0 + // 一侧到边缘的距离 + let side = 0 let _row = row + y let _col = col + x - while (true) { - if (inRange(_row, ROW) && inRange(_col, COL) && board[_row][_col] === is_white) { + while (inRange(_row, ROW) && inRange(_col, COL)) { + if (board[_row][_col] === is_white) { res += 1 - _row += y - _col += x - } + side += 1 + + _row += y + _col += x } }