countEmptySpaces([x, y], color, explored) {
    if (explored[x][y]) return [];
    explored[x][y] = true;
    let res = [];
    for (let s of V.steps[V.ROOK]) {
      const [i, j] = [x + s[0], y + s[1]];
      if (V.OnBoard(i, j)) {
        if (!explored[i][j] && this.board[i][j] == V.EMPTY) {
          res.push([i, j]);
          explored[i][j] = true; //not counting liberties twice!
        }
        else if (this.getColor(i, j) == color)
          res = res.concat(this.countEmptySpaces([i, j], color, explored));
      }
    }
    return res;
  }
// Modified version to count liberties + find locations
Modified version to count liberties + find locations
Modified version to count liberties + find locations
countEmptySpaces([x, y], color, explored) {
    if (explored[x][y]) return [];
    explored[x][y] = true;
    let res = [];
    for (let s of V.steps[V.ROOK]) {
      const [i, j] = [x + s[0], y + s[1]];
      if (V.OnBoard(i, j)) {
        if (!explored[i][j] && this.board[i][j] == V.EMPTY) {
          res.push([i, j]);
          explored[i][j] = true; 
        }
        else if (this.getColor(i, j) == color)
          res = res.concat(this.countEmptySpaces([i, j], color, explored));
      }
    }
    return res;
  }
countEmptySpaces ( [ x , y ] , color , explored ) { if ( explored [ x ] [ y ] ) return [ ] ; explored [ x ] [ y ] = true ; let res = [ ] ; for ( let s of V . steps [ V . ROOK ] ) { const [ i , j ] = [ x + s [ 0 ] , y + s [ 1 ] ] ; if ( V . OnBoard ( i , j ) ) { if ( ! explored [ i ] [ j ] && this . board [ i ] [ j ] == V . EMPTY ) { res . push ( [ i , j ] ) ; explored [ i ] [ j ] = true ; } else if ( this . getColor ( i , j ) == color ) res = res . concat ( this . countEmptySpaces ( [ i , j ] , color , explored ) ) ; } } return res ; }
Modified version to count liberties + find locations
Modified version to count liberties + find locations
//not counting liberties twice!