Sat Jul 8 15:32:00 UTC 2023 inscode

上级 3dc414d1
...@@ -103,7 +103,6 @@ export function checkWin({ row, col, board, player, win_size }) { ...@@ -103,7 +103,6 @@ export function checkWin({ row, col, board, player, win_size }) {
* @returns {number[]} * @returns {number[]}
*/ */
export function robotPlay(board, win_size) { export function robotPlay(board, win_size) {
let maxScorePos = [];
// 空位 对每个空位进行评分 // 空位 对每个空位进行评分
const scores = board.map((item, row) => { const scores = board.map((item, row) => {
return item.flatMap((_item, col) => { return item.flatMap((_item, col) => {
...@@ -129,8 +128,8 @@ export function robotPlay(board, win_size) { ...@@ -129,8 +128,8 @@ export function robotPlay(board, win_size) {
const _scores = scores.sort((black_score, white_score) => { const _scores = scores.sort((black_score, white_score) => {
const [b_s1, b_w1] = Object.values(Object.values(black_score)[0]) const [b_s1, b_w1] = Object.values(Object.values(black_score)[0])
const [w_s1, w_w1] = Object.values(Object.values(white_score)[0]) const [w_s1, w_w1] = Object.values(Object.values(white_score)[0])
const score1 = b_s1 > b_w1 ? b_s1 : b_w1 const score1 = Math.max(b_s1, b_w1)
const score2 = w_s1 > w_w1 ? w_s1 : w_w1 const score2 = Math.max(w_s1, w_w1)
return score2 - score1 return score2 - score1
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册