If the move is a capture and there is no piece on the
 destination square, it must be an en passant capture.
505224
def en_passant_capture
      return nil if self.move.castle

      if !self.board.at(self.move.destination) && self.move.capture
        self.move.destination[0] + self.origin[1]
      end
    end
1311593
def capture(board):
    
    game = Game()
    v = (0, 0)
    stub_actor = base.Actor('capture', v, v, v, v, v, v, v, v, v)
    root = base.State(board, stub_actor, stub_actor,
                      turn=1, actions_remaining=1)
    solution_node = None
    for eot in game.all_ends_of_turn(root):
        # check for a solution
        if eot.is_mana_drain:  # quick check before checking whole board
            if eot.parent.board.is_empty():
                solution_node = eot
                break
    # if solution found, build the list of swaps
    solution_sequence = list()  # empty sequence (no solution) by default
    if solution_node:
        node = solution_node
        while node:
            # record each swap in the path to the root
            if not isinstance(node, base.Swap):
                node = node.parent
                continue
            summary = base.Summary(node.parent.board, node.position_pair,
                                   None, None, None)
            solution_sequence.append(summary)
            node = node.parent
    return tuple(reversed(solution_sequence))
308349
def exit_if_missing_graphviz(self):
        
        (out, err) = utils.capture_shell("which dot")

        if "dot" not in out:
            ui.error(c.MESSAGES["dot_missing"])
202520
def disambiguate_discovered_check(possibilities)
      DIRECTIONS.each do |attacking_piece, directions|
        attacking_piece = attacking_piece.upcase if self.move.black?

        directions.each do |dir|
          piece, square = first_piece(king_position, dir)
          next unless piece == self.move.piece && possibilities.include?(square)

          piece, _ = first_piece(square, dir)
          possibilities.reject! {|p| p == square } if piece == attacking_piece
        end
      end

      possibilities
    end
639140
def assert_dut_trace_not_contains(self, k, message):
        
        asserts.assertDutTraceDoesNotContain(k, message, bench=self.bench)
560291
private boolean isTileBlocked(Pathfindable mover, int tx, int ty)
    {
        final Tile tile = map.getTile(tx, ty);
        if (tile != null)
        {
            final TilePath tilePath = tile.getFeature(TilePath.class);
            return mover.isBlocking(tilePath.getCategory());
        }
        return false;
    }
707015
def _is_en_passant_valid(self, opponent_pawn_location, position):
        
        try:
            pawn = position.piece_at_square(opponent_pawn_location)
            return pawn is not None and \
                isinstance(pawn, Pawn) and \
                pawn.color != self.color and \
                position.piece_at_square(opponent_pawn_location).just_moved_two_steps
        except IndexError:
            return False
739335
def has_free_moves(self):
        """"""
        return any(self._can_cell_be_merged(x, y)
                   for x in range(self.COUNT_X)
                   for y in range(self.COUNT_Y))
800656
def isEmpty(self):
        """"""
        return self.x0 == self.x1 or self.y0 == self.y1
1171572
def is_nonempty(self):
        
        if len(self._subject) == 0:
            raise self._error_factory(_format("Expected {} to be non-empty", self._subject))
        return ChainInspector(self._subject)
761712
function(x, y){
            if(this.canMoveTo(x, y)){
                this.moveTo(x, y);
                return true;
            } else {
                // entity occupying target tile (if any)
                var targetTileEnt = this.game.entityManager.get(x, y);
                // if already occupied
                if(targetTileEnt){
                    this.game.console.log('Excuse me <strong>Mr.' + targetTileEnt.name + '</strong>, you appear to be in the way.');
                    return targetTileEnt.bump(this);
                } else {
                    // targeted tile (attempting to move into)
                    var targetTile = this.game.map.get(x, y);
                    return targetTile.bump(this);
                }
            }
            return false;
        }
721479
def has_variation(self, move: chess.Move) -> bool:
        """"""
        return move in (variation.move for variation in self.variations)
777063
private boolean isTileNotAvailable(Pathfindable mover, int ctx, int cty, Integer ignoreObjectId)
    {
        final Collection<Integer> ids = getObjectsId(ctx, cty);
        final Tile tile = map.getTile(ctx, cty);
        if (tile != null)
        {
            final TilePath tilePath = tile.getFeature(TilePath.class);
            if (mover.isBlocking(tilePath.getCategory())
                || ignoreObjectId != null && !ids.isEmpty() && !ids.contains(ignoreObjectId))
            {
                return true;
            }
        }
        return false;
    }
822444
def move_origins(moves = nil)
      moves         ||= MOVES[move.piece.downcase]
      possibilities   = []
      file, rank      = destination_coords

      moves.each do |i, j|
        f = file + i
        r = rank + j

        if valid_square?(f, r) && self.board.at(f, r) == move.piece
          possibilities << [f, r]
        end
      end

      possibilities
    end
329609
def no_moves(position):
    
    return position.no_moves(color.white) \
        or position.no_moves(color.black)
913285
function getPiecesWhereCanIGo(board, positions) {
    return positions.map(function (position) {
        var x = position.x,
            y = position.y,
            isBlack = position.isBlack;

        return {
            x: x, y: y, isBlack: isBlack,
            whereCanIGo: getPositionsWhereCanIGo(board, position)
        };
    });
}
91676
def loc_adjacent_to_opponent_king(self, location, position):
        
        for fn in self.cardinal_directions:
            try:
                if isinstance(position.piece_at_square(fn(location)), King) and \
                        position.piece_at_square(fn(location)).color != self.color:
                    return True

            except IndexError:
                pass

        return False