diff --git a/src/App.vue b/src/App.vue index c25caf13ec8f81b11e896500b0a80a7d180eeb57..771530578b572a3837aaff979dbc7b974b48ee14 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,14 +1,26 @@ @@ -56,10 +71,11 @@ function getStyle(item, row, col) {
+-
diff --git a/src/assets/base.css b/src/assets/base.css index 8e5bf0f2831678755233e26f9cd61683f0536e6c..7b729c6532b83bc03ea571bfa9e10f7bec9be47d 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -4,6 +4,10 @@ --vt-c-white-soft: #f8f8f8; --vt-c-white-mute: #f2f2f2; + --vt-c-red: #ff0000; + --vt-c-red-soft: #f80808; + --vt-c-red-mute: #f20202; + --vt-c-black: #181818; --vt-c-black-soft: #222222; --vt-c-black-mute: #282828; @@ -36,6 +40,9 @@ --color-text: var(--vt-c-text-light-1); --section-gap: 160px; + + --p-border-color: var(--vt-c-black); + --p-win-border-color: var(--vt-c-red); } @media (prefers-color-scheme: dark) { @@ -49,6 +56,9 @@ --color-heading: var(--vt-c-text-dark-1); --color-text: var(--vt-c-text-dark-2); + + --p-border-color: var(--vt-c-white); + --p-win-border-color: var(--vt-c-white); } } diff --git a/src/assets/main.css b/src/assets/main.css index 2f2af80161ad4720974b1e66cf5aa66c85932752..bbe49b6c05341f2c013da3763c262a1da34f995c 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -113,12 +113,12 @@ input { .isBlack::after { background-color: black; - border-color: black; + border-color: var(--p-border-color); } .isWin::after { background-color: red; - border-color: red; + border-color: var(--p-win-border-color); } .space-nowrap { diff --git a/src/utils/index.js b/src/utils/index.js index 3c462ab07b0f5c70158adfa771804fb09301caf3..5a1d48a52127d868faf1441fb0775e8f6a892253 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -81,8 +81,11 @@ export function robotPlay(board, robot, win_size) { let score = 0; const [row, col] = point; - // 这里要应该是要返回这个位置的分数 - score = estimateScore({ row, col, board, win_size }) + // 评估每个空位置的价值,从八个方向去计算 + score = 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) + }, 0) // 选取分数最高的空位 if (score >= maxScore) { @@ -150,18 +153,3 @@ function getDirectionScore(board, row, col, [y, x], win_size, piece_type) { return res } -/** - * 评估每个空位置的价值,从八个方向去计算, - * 计分规则 1,10,100,1000,10000,100000 根据棋子数量计分,每多一颗棋子,分数乘以10 - * @param {object} Estimate - * @param {object} Estimate.board - * @param {number} Estimate.row - * @param {number} Estimate.col - * @return {number} - */ -function estimateScore({ board, row, col, win_size }) { - 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) - }, 0) -}