From 483e543d09db85b22b3d6d4cbcb6def5664dd53c Mon Sep 17 00:00:00 2001 From: 63db3122f0950a2aef64df95 <63db3122f0950a2aef64df95@devide> Date: Mon, 3 Jul 2023 23:02:00 +0000 Subject: [PATCH] Mon Jul 3 23:02:00 UTC 2023 inscode --- src/App.vue | 44 ++++++++++++++++++++++++++++++-------------- src/assets/base.css | 10 ++++++++++ src/assets/main.css | 4 ++-- src/utils/index.js | 22 +++++----------------- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/App.vue b/src/App.vue index c25caf1..7715305 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 8e5bf0f..7b729c6 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 2f2af80..bbe49b6 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 3c462ab..5a1d48a 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) -} -- GitLab