提交 54166b14 编写于 作者: U u014301111

Sun Aug 6 12:45:00 CST 2023 inscode

上级 81de1e9d
<script setup>
import { onMounted, ref, computed } from "vue"
import { is_empty, checkWin, is_black, is_white, robotPlay } from "./utils"
import { is_empty, checkWin, is_black, is_white, robotPlay, sleep } from "./utils"
import RandomTree from "./components/RandomTree.vue";
// import { robotPlay } from './utils/api'
// 配置
......@@ -78,6 +78,40 @@ async function playChess(item, row, col) {
}
console.timeEnd('playChess')
}
onMounted(async () => {
return;
while (true) {
if (records.value.length == size.value * size.value) {
break;
}
// 机器人下棋
const [y, x] = robotPlay(lattices.value, win_size.value)
setPiece([y, x], is_black)
const test_black = checkWin({ row: y, col: x, board: lattices.value, player: is_black, win_size: win_size.value })
if (test_black) {
isWin = test_black
break;
}
await sleep()
// 机器人下棋
const [row, col] = robotPlay(lattices.value, win_size.value)
setPiece([row, col], is_white)
const test_white = checkWin({ row, col, board: lattices.value, player: is_white, win_size: win_size.value })
if (test_white) {
isWin = test_white
break;
}
await sleep()
}
})
</script>
<template>
......
......@@ -14,6 +14,12 @@ export const directions = [
[1, -1] // / 方向
]
export const sleep = (tim = 200) => {
return new Promise(res => {
setTimeout(res, tim);
})
}
/**
* @typedef PanInfo 棋盘信息
* @property {number} ROW
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册