Tue Jul 4 02:07:00 UTC 2023 inscode

上级 1ac9bdea
......@@ -83,7 +83,7 @@ export function robotPlay(board, robot, win_size) {
// 评估每个空位置的价值,从八个方向去计算
score = directions.reduce((r, [y, x]) => {
const square = getDirectionScore(board, row, col, [y, x], win_size, is_black) + getDirectionScore(board, row, col, [y * -1, x * -1], win_size, is_black)
const square = getDirectionScore(board, row, col, [y, x], win_size) + getDirectionScore(board, row, col, [y * -1, x * -1], win_size)
return r + (10 ** square)
}, 0)
......@@ -135,14 +135,14 @@ function getBoundary(size, num) {
* @param {*} piece_type
* @returns
*/
function getDirectionScore(board, row, col, [y, x], win_size, piece_type) {
function getDirectionScore(board, row, col, [y, x], win_size) {
const ROW = board.length
const COL = board[0].length
let res = 0
let _row = row + y
let _col = col + x
while (true) {
if (_row < 0 || _col < 0 || !board[_row] || board[_row][_col] !== piece_type) {
if (_row < 0 || _col < 0 || !board[_row] || board[_row][_col] !== is_black) {
break;
}
res += 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册