Auto Commit

上级 652cc460
......@@ -14,6 +14,7 @@ export const directions = [
[1, -1] // / 方向
]
// 为什么要做这个东西,简化一下下面函数的行数
Array.prototype.group = function (fn) {
return this.reduce((r, item, index, arr) => {
const key = fn(item, index, arr)
......@@ -122,13 +123,12 @@ export function robotPlay(board, win_size) {
})
}).flat(1)
// 按分数分组
const scores_group_obj = scores.group((item) => {
return Object.values(item)[0]
})
const scores_group_obj = scores.group((item) => Object.values(item)[0])
// 找到最高分数
const max_key = Math.max(...Object.keys(scores_group_obj))
const max_scores_arr = scores_group_obj[max_key]
let res_key = ''
if (max_scores_arr.length === 1) {
res_key = Object.keys(max_scores_arr[0])[0]
......@@ -161,10 +161,10 @@ export function robotPlay(board, win_size) {
* 单边,两边空位置多的那边加分 10**(n) =====
*
* 黑白棋棋盘积分判断
* 比较黑白棋的棋盘最高积分,积分大的位置优先下,避免总是在防守
* 比较黑白棋的棋盘最高积分,积分大的位置优先下,避免总是在防守 =====
*
* 随机下棋
* 如果一个判定回合,棋盘积分中最高的积分有多个,则随机选择一个位置,避免有规律
* 如果一个判定回合,棋盘积分中最高的积分有多个,则随机选择一个位置,避免有规律 =====
*
*/
......
......@@ -4,6 +4,9 @@ import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
host: true
},
define: {
'process.env': {
INSCODE_API_KEY: process.env.INSCODE_API_KEY
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册