Wed Jul 12 21:22:00 CST 2023 inscode

上级 91b150da
...@@ -4,7 +4,7 @@ import { is_empty, checkWin, is_black, is_white, robotPlay } from "./utils" ...@@ -4,7 +4,7 @@ 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'
// 配置 // 配置
const size = ref(20) const size = ref(30)
const win_size = ref(5) const win_size = ref(5)
// 棋盘 // 棋盘
const lattices = ref([]) const lattices = ref([])
...@@ -53,6 +53,7 @@ function setPiece([y, x], type) { ...@@ -53,6 +53,7 @@ function setPiece([y, x], type) {
lattices.value[y][x] = type lattices.value[y][x] = type
} }
async function playChess(item, row, col) { async function playChess(item, row, col) {
console.time('playChess')
if (isWin.length || item !== is_empty) return if (isWin.length || item !== is_empty) return
// 玩家下棋 // 玩家下棋
...@@ -70,6 +71,7 @@ async function playChess(item, row, col) { ...@@ -70,6 +71,7 @@ async function playChess(item, row, col) {
if (testRobo) { if (testRobo) {
isWin = testRobo isWin = testRobo
} }
console.timeEnd('playChess')
} }
</script> </script>
......
<template> <template>
<canvas width="500" height="300" ref="canvas"></canvas> <canvas class="canvas" width="500" height="300" ref="canvas"></canvas>
</template> </template>
<script setup> <script setup>
...@@ -71,9 +71,14 @@ function drawBranch(ctx, v0, thick, len, dir) { ...@@ -71,9 +71,14 @@ function drawBranch(ctx, v0, thick, len, dir) {
</script> </script>
<style> <style>
canvas { .canvas {
position: absolute; position: absolute;
right: 10px; right: 10px;
bottom: 10px; bottom: 10px;
pointer-events: none;
}
.canvas:hover {
opacity: 0.3;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册