提交 d34eb8df 编写于 作者: U u014301111

Fri Sep 1 22:44:04 CST 2023 inscode

上级 fd6cfb4d
<script setup> <script setup>
import { onMounted, ref, computed } from "vue" import { onMounted, ref, computed } from "vue"
import { is_empty, checkWin, is_black, is_white, robotPlay, sleep } from "./utils" import { is_empty, checkWin, is_black, is_white, robotPlay } from "./utils"
import RandomTree from "./components/RandomTree.vue"; import RandomTree from "./components/RandomTree.vue";
// import { robotPlay } from './utils/api' // import { robotPlay } from './utils/api'
// 配置 // 配置
...@@ -80,47 +80,6 @@ async function playChess(item, row, col) { ...@@ -80,47 +80,6 @@ async function playChess(item, row, col) {
console.timeEnd('playChess') console.timeEnd('playChess')
} }
const autoPlay = async () => {
await sleep()
confirm()
setPiece([(size.value / 2) | 0, (size.value / 2) | 0], is_black)
while (true) {
console.log(1)
if (records.value.length == size.value * size.value) {
break;
}
// 机器人下棋
const [y, x] = robotPlay(lattices.value, win_size.value)
setPiece([y, x], is_white)
const test_black = checkWin({ row: y, col: x, board: lattices.value, player: is_white, win_size: win_size.value })
if (test_black) {
isWin = test_black
break;
}
if (records.value.length == size.value * size.value) {
break;
}
await sleep()
// 机器人下棋
const [row, col] = robotPlay(lattices.value, win_size.value)
setPiece([row, col], is_black)
const test_white = checkWin({ row, col, board: lattices.value, player: is_black, win_size: win_size.value })
if (test_white) {
isWin = test_white
break;
}
await sleep()
}
}
</script> </script>
<template> <template>
...@@ -134,7 +93,6 @@ const autoPlay = async () => { ...@@ -134,7 +93,6 @@ const autoPlay = async () => {
<input v-model="win_size" id="win_size" type="number" min="3" max="8"> <input v-model="win_size" id="win_size" type="number" min="3" max="8">
</p> </p>
<button @click="confirm" whitespace-nowrap mr-6px px-6px>重新开始</button> <button @click="confirm" whitespace-nowrap mr-6px px-6px>重新开始</button>
<button @click="autoPlay" whitespace-nowrap mr-6px px-6px>自动下棋</button>
<button @click="back" whitespace-nowrap px-6px>返回上一步</button> <button @click="back" whitespace-nowrap px-6px>返回上一步</button>
</div> </div>
<div p-6px box-border flex flex-col items-center border="t t-solid #999"> <div p-6px box-border flex flex-col items-center border="t t-solid #999">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册