Tue Jul 4 03:10:00 UTC 2023 inscode

上级 892df0fd
......@@ -9,7 +9,7 @@ const win_size = ref(5)
const lattices = ref([])
// 下起记录
const records = ref([])
// 5 连珠的下标
// 赢棋的下标
let isWin = []
const records_obj = computed(() => {
return records.value.reduce((r, { location, type }) => {
......@@ -60,7 +60,7 @@ async function playChess(item, row, col) {
return
}
// 机器人下棋
const [y, x] = robotPlay(lattices.value, is_white, win_size.value)
const [y, x] = robotPlay(lattices.value, win_size.value)
setPiece([y, x], is_white)
const testRobo = checkWin({ row: y, col: x, board: lattices.value, player: is_white, win_size: win_size.value })
......
......@@ -62,11 +62,10 @@ export function checkWin({ row, col, board, player, win_size }) {
/**
* 机器人下棋位置
* @param {(is_empty|is_white|is_black)[][]} board 棋盘
* @param {is_white} robot 机器人
* @param {number} win_size 赢棋的棋子颗数
* @returns {number[]}
*/
export function robotPlay(board, robot, win_size) {
export function robotPlay(board, win_size) {
let maxScorePos = [];
let maxScore = -1;
// 空位
......@@ -112,7 +111,7 @@ export function robotPlay(board, robot, win_size) {
* 积分最小为 4 * (10**0) = 4
*
* 边界判断
* 如果在棋盘边缘,需要判断连子最多有几颗,小于5颗,可以直接放弃当前位置
* 如果在棋盘边缘,需要判断连子最多有几颗,小于 win_size 颗,可以直接放弃当前位置
*/
/**
......@@ -128,11 +127,10 @@ function getBoundary(size, num) {
/**
* 获取一个一个方向上的棋子数
* @param {*} board
* @param {*} row
* @param {*} col
* @param {*} param3
* @param {*} piece_type
* @param {number} row 行 y
* @param {number} col 列 x
* @param {(is_empty|is_white|is_black)[]} board 棋盘
* @param {number} win_size 需要几个棋子才赢
* @returns
*/
function getDirectionScore(board, row, col, [y, x], win_size) {
......
......@@ -7,6 +7,10 @@ export default defineConfig({
host: true
},
plugins: [vue()],
server: {
https: true,
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.
先完成此消息的编辑!
想要评论请 注册