Board spaces that are attackable by opposing pieces
  TODO: check? method should use this function
168828
def attack_vectors(color = @player_turn, proposed_manifest = @piece_locations)
      enemy_color = opposing_color(color)
      kill_zone = []

      proposed_manifest.each do |piece, details|
        kill_zone << possible_moves(piece, proposed_manifest) if details.fetch(:color) == enemy_color
      end

      kill_zone.flatten.uniq
    end
1185679
function hasPositionByBoardSize(boardSize, position) {
    return position && position.x >= 0 && position.y >= 0 && boardSize.y > position.y && boardSize.x > position.x;
}
258056
def controls(self, move):
    ''''''
    to_move = self.board.turn
    analysis_board = chess.Board(self.board.fen())
    analysis_board.push(move)
    squares = 0
    for square in chess.SQUARES:
      if move.to_square in analysis_board.attackers(to_move, square):
        squares |= chess.BB_SQUARES[square]
    return SquareSet(squares)
39031
function isMyTurn(game, from) {
    if (game.score.ended)
        return false;
    from = Board.getPositionFromBoard(game.board, from);
    return isWhiteTurn(game) ? Position.hasWhitePiece(from) : Position.hasBlackPiece(from);
}
450934
function canFitText(gx, gy, gw, gh, occupied) {
      // Go through the occupied points,
      // return false if the space is not available.
      var i = occupied.length;
      while (i--) {
        var px = gx + occupied[i][0];
        var py = gy + occupied[i][1];

        if (px >= ngx || py >= ngy || px < 0 || py < 0) {
          if (!settings.drawOutOfBound) {
            return false;
          }
          continue;
        }

        if (!grid[px][py]) {
          return false;
        }
      }
      return true;
    }
196783
def attackers(self, color: Color, square: Square) -> "SquareSet":
        
        return SquareSet(self.attackers_mask(color, square))
700242
function() {
					gobbleSpaces();
					var biop, to_check = expr.substr(index, max_binop_len), tc_len = to_check.length;
					while(tc_len > 0) {
						// Don't accept a binary op when it is an identifier.
						// Binary ops that start with a identifier-valid character must be followed
						// by a non identifier-part valid character
						if(binary_ops.hasOwnProperty(to_check) && (
							!isIdentifierStart(exprICode(index)) ||
							(index+to_check.length< expr.length && !isIdentifierPart(exprICode(index+to_check.length)))
						)) {
							index += tc_len;
							return to_check;
						}
						to_check = to_check.substr(0, --tc_len);
					}
					return false;
				}
216033
def move_pawn(p1)
      col = get_col_from_index(p1)
      valid = []

      # Piece color defines direction of travel. Enemy presence defines
      # the validity of diagonal movements
      if Move.color == :red
        valid << (p1 - 8) if unoccupied?(p1 - 8)
        valid << (p1 - 7) if piece_color(p1 - 7) == Move.enemy_color && col < 8
        valid << (p1 - 9) if piece_color(p1 - 9) == Move.enemy_color && col > 1
        # Only if the pieces is unmoved, can it move forward two rows
        valid << (p1 - 16) if !Move.pieces[p1][:moved] && unoccupied?(p1 - 8) && unoccupied?(p1 - 16)

      elsif Move.color == :black

        valid << (p1 + 8) if unoccupied?(p1 + 8)
        valid << (p1 + 7) if piece_color(p1 + 7) == Move.enemy_color && col > 1
        valid << (p1 + 9) if piece_color(p1 + 9) == Move.enemy_color && col < 8
        valid << (p1 + 16) if !Move.pieces[p1][:moved] && unoccupied?(p1 + 8) && unoccupied?(p1 + 16)
      end

      valid
    end
328722
private boolean tryMove(float x, float y) {
		float newx = playerX + x;
		float newy = playerY + y;
		
		// first we try the real move, if that doesn't work
		// we try moving on just one of the axis (X and then Y) 
		// this allows us to slide against edges
		if (blocked(newx,newy)) {
			if (blocked(newx, playerY)) {
				if (blocked(playerX, newy)) {
					// can't move at all!
					return false;
				} else {
					playerY = newy;
					return true;
				}
			} else {
				playerX = newx;
				return true;
			}
		} else {
			playerX = newx;
			playerY = newy;
			return true;
		}
	}
1099006
def find_all(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Iterator[Entry]:
        """"""
        try:
            key = int(board)  # type: ignore
            context = None  # type: Optional[chess.Board]
        except (TypeError, ValueError):
            context = typing.cast(chess.Board, board)
            key = zobrist_hash(context)

        i = self.bisect_key_left(key)
        size = len(self)

        while i < size:
            entry = self[i]
            i += 1

            if entry.key != key:
                break

            if entry.weight < minimum_weight:
                continue

            if context:
                move = context._from_chess960(context.chess960, entry.move.from_square, entry.move.to_square, entry.move.promotion, entry.move.drop)
                entry = Entry(entry.key, entry.raw_move, entry.weight, entry.learn, move)

            if exclude_moves and entry.move in exclude_moves:
                continue

            if context and not context.is_legal(entry.move):
                continue

            yield entry
990233
def is_adjacent(self, other: ops.Qid) -> bool:
        """"""
        return (isinstance(other, GridQubit) and
                abs(self.row - other.row) + abs(self.col - other.col) == 1)
718106
function isActuallyCombinator(combinatorNode) {
  // `.foo  /*comment*/, .bar`
  //      ^^
  // If include comments, this spaces is a combinator, but it is not combinators.
  if (!/^\s+$/.test(combinatorNode.value)) {
    return true;
  }

  let next = combinatorNode.next();

  while (skipTest(next)) {
    next = next.next();
  }

  if (isNonTarget(next)) {
    return false;
  }

  let prev = combinatorNode.prev();

  while (skipTest(prev)) {
    prev = prev.prev();
  }

  if (isNonTarget(prev)) {
    return false;
  }

  return true;

  function skipTest(node) {
    if (!node) {
      return false;
    }

    if (node.type === "comment") {
      return true;
    }

    if (node.type === "combinator" && /^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }

  function isNonTarget(node) {
    if (!node) {
      return true;
    }

    if (node.type === "combinator" && !/^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }
}
769896
def get_open_spaces(board):
  """"""
  open_spaces = []
  for i in range(3):
    for j in range(3):
      if board[i][j] == 0:
        open_spaces.append(encode_pos(i, j))
  return open_spaces
263167
function getBoard() {
    var game = $.cookie("game");
    var board_margin = 5;

    $.getJSON("/games/" + enc(game) + "/dimensions", function (data) {
        var dimensions = data;
        // add 5 for each side since players can add up to 5 pieces per turn
        var top = dimensions.top - board_margin;
        var bottom = dimensions.bottom + board_margin;
        var left = dimensions.left - board_margin;
        var right = dimensions.right + board_margin;

        $(BOARD).empty();

        var rows = bottom - top + 1;
        var cols = right - left + 1;
        for (var i = 0; i < rows; i++) {
            for (var j = 0; j < cols; j++) {
                $(BOARD).append('<div class="grid"></div>');
                $(GRIDCLS+":last-child").data(
                    "col", (j+left)).data("row", (top+i));
            }
        }

        // if ($(BOARD).width() < $(BOARD).height()) {
        //     $(BOARD).height($(BOARD).width());
        // } else {
        //     $(BOARD).width($(BOARD).height());
        // }

        $(GRIDCLS).css("width", (100/cols)+"%");
        $(GRIDCLS).css("height", (100/rows)+"%");
        var fontsize = Math.min($(GRIDCLS).height(), $(GRIDCLS).width());
        $(GRIDCLS).css("font-size", fontsize);

        //$(BOARD).css("width", (($(GRIDCLS).width()) * 10))
        //$(BOARD).css("height", (($(GRIDCLS).height()) * 10))

        $.getJSON("/games/" + enc(game) + "/board", function (data) {
            var i, idx;
            // place pieces on board
            if (data.length > 0) {
                for (i in data) {
                    var piece = data[i].piece;
                    var row = data[i].row;
                    var col = data[i].column;
                    var drow = row - dimensions.top + board_margin;
                    var dcol = col - dimensions.left + board_margin;
                    idx = drow*cols + dcol + 1;
                    $(GRIDCLS+":nth-child("+idx+")").addClass("boardpiece");
                    $(GRIDCLS+":nth-child("+idx+")").css("color",
                                                      pastels[piece.color]);
                    $(GRIDCLS+":nth-child("+idx+")").html(ushapes[piece.shape]);
                }
                $(".boardpiece").css("line-height", fontsize+"px");
            } else {  // place marker in center if board is empty
                idx = parseInt(($(GRIDCLS).length + 1) / 2, 10);
                $(GRIDCLS+":nth-child("+idx+")").addClass('snapgrid');
            }

            // iterate through board and mark spots adjacent to pieces
            if (data.length > 0) {
                var offsets = [1, -1, cols, -cols];
                for (i = 1; i <= $(GRIDCLS).length; i++) {
                    var cur = $(GRIDCLS+":nth-child("+i+")");
                    for (var j in offsets) {
                        var next = $(GRIDCLS+":nth-child("+(i+offsets[j])+")");
                        if (!cur.hasClass("boardpiece") &&
                            next.hasClass("boardpiece"))
                            cur.addClass("snapgrid");
                    }
                }
            }

            $(SNAPGRIDCLS).droppable({
                accept: PIECECLS,
                activate: function (event, ui) {
                    $(SNAPGRIDCLS).html("&middot;");
                    $(BOARD).addClass("activate");
                },
                deactivate: function (event, ui) {
                    $(SNAPGRIDCLS).html("");
                    $(BOARD).removeClass("activate");
                },
                drop: onPieceDrop
            });
        });
    });
}
1029337
void xor(LongBitSet other) {
		assert other.numWords <= numWords : "numWords=" + numWords + ", other.numWords=" + other.numWords;
		int pos = Math.min(numWords, other.numWords);
		while (--pos >= 0) {
			bits[pos] ^= other.bits[pos];
		}
	}
1038728
def under_attack(col, queens):
        
        left = right = col
        for _, column in reversed(queens):
            left, right = left - 1, right + 1
            if column in (left, col, right):
                return True
        return False
404516
function boxIntersectWrapper(arg0, arg1, arg2) {
  var result
  switch(arguments.length) {
    case 1:
      return intersectFullArray(arg0)
    case 2:
      if(typeof arg1 === 'function') {
        return boxIntersect(arg0, arg0, arg1, true)
      } else {
        return intersectBipartiteArray(arg0, arg1)
      }
    case 3:
      return boxIntersect(arg0, arg1, arg2, false)
    default:
      throw new Error('box-intersect: Invalid arguments')
  }
}