import { board } from "../board.js" import { Vector2 } from "../engine/vector2.js" const SURROUNDING = [ new Vector2(-1, 0), new Vector2(0, 1), new Vector2(0, -1), new Vector2(1, 0), ] export function hasLiberties({ position, team }) { return Array.from(SURROUNDING) .map(v => Vector2.sum(v, position)) .filter(z => 0 <= z.x && z.x < board.size && 0 <= z.y && z.y < board.size ) .some(z => board.stones[z.y][z.x] == undefined ? true : board.stones[z.y][z.x].team == team ) }