Calls methods below to return a list of positions which are valid moves
 for piece at index p1, given the current board layout as defined in manifest
339746
def possible_moves(p1, manifest, castling = false)
      return [] if manifest[p1][:type].nil?

      allowed   = []
      type      = manifest[p1][:type]
      my_color  = manifest[p1][:color]

      constants(manifest, my_color, type)

      return [] if unoccupied?(p1)

      if type == :king
        allowed += [move_lateral(p1, 1)].flatten
        allowed += [move_diagonal(p1, 1)].flatten
        allowed += [castle(p1)].flatten if castling

      elsif type == :queen
        allowed += [move_lateral(p1)].flatten
        allowed += [move_diagonal(p1)].flatten

      elsif type == :rook
        allowed += [move_lateral(p1)].flatten

      elsif type == :bishop
        allowed += [move_diagonal(p1)].flatten

      elsif type == :pawn
        allowed += [move_pawn(p1)].flatten

      elsif type == :knight
        allowed += [move_knight(p1)].flatten
      end

      allowed
    end
386552
private int findBacktrackPosition(final int position) {
        int currentPosition = position;

        // check against stack size after the instruction was executed
        while (stackSizes.get(currentPosition).getRight() > 0) {
            currentPosition++;
        }

        return currentPosition;
    }
542036
def get_available_positions(self):
        
        available_positions = ["new"]
        layout = self.context.getLayout()
        used_positions = [int(slot["position"]) for slot in layout]
        if used_positions:
            used = [
                pos for pos in range(1, max(used_positions) + 1) if
                pos not in used_positions]
            available_positions.extend(used)
        return available_positions
1364715
def _is_valid_position(self, position):
        '''
        
        '''
        row, col = position
        valid_r = row in self.row_labels
        valid_c = col in self.col_labels
        return valid_r and valid_c
674142
def parse_moves
      s0 = @current_pos
      s1 = parse_firstboard
      if s1 != :failed
        s2 = []
        s3 = parse_move
        while s3 != :failed
          s2 << s3
          s3 = parse_move
        end
        parse_comments
        @reported_pos = s0
        s0 = s2.unshift(s1)
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
1133135
def make_position_choices(self):
        
        choices = []
        for pos in self.get_available_positions():
            choices.append({
                "ResultValue": pos,
                "ResultText": pos,
            })
        return choices
473244
def select_next_layout(self, count=1):
        
        # List of all layouts. (When we have just two panes, only toggle
        # between horizontal/vertical.)
        if len(self.panes) == 2:
            all_layouts = [LayoutTypes.EVEN_HORIZONTAL, LayoutTypes.EVEN_VERTICAL]
        else:
            all_layouts = LayoutTypes._ALL

        # Get index of current layout.
        layout = self.previous_selected_layout or LayoutTypes._ALL[-1]
        try:
            index = all_layouts.index(layout)
        except ValueError:
            index = 0

        # Switch to new layout.
        new_layout = all_layouts[(index + count) % len(all_layouts)]
        self.select_layout(new_layout)
60672
def move_to_list_on_any_board(list_id)
      list = List.find(list_id)
      if board.id == list.board_id
        move_to_list(list_id)
      else
        move_to_board(Board.find(list.board_id), list)
      end
    end
120459
def possible_moves(self, position):
        
        for move in itertools.chain(*[self.moves_in_direction(fn, position) for fn in self.cross_fn]):
            yield move
211043
def do_boards(self, _):
        
        rows = []
        with DEV_LOCK:
            for dev in DEVS:
                if dev is DEFAULT_DEV:
                    dirs = [dir[:-1] for dir in dev.root_dirs]
                else:
                    dirs = []
                dirs += ['/{}{}'.format(dev.name, dir)[:-1] for dir in dev.root_dirs]
                dirs = 'Dirs: ' + ' '.join(dirs)
                epoch = 'Epoch: {}'.format(time.gmtime(dev.time_offset)[0])
                rows.append((dev.name, '@ %s' % dev.dev_name_short, dev.status(), epoch, dirs))
        if rows:
            column_print('<<<< ', rows, self.print)
        else:
            print('No boards connected')
794803
def do_layout(self, *args):
        """"""
        if self.size == [1, 1]:
            return
        for i in range(0, len(self.decks)):
            self.layout_deck(i)
1261293
function getPositionFromBoard(board, position) {
    try {
        return board[position.y][position.x];
    } catch (e) {
        throw new Error('Error getting position');
    }
}
1252341
function getAllowedMovesFromArray(moves) {
    var from = Position.getPositionFromArray(_ramda2.default.head(moves));
    return _ramda2.default.tail(moves).map(function (to) {
        return { from: from, to: Position.getPositionFromArray(to) };
    });
}
1194875
function getBoardWhereCanIGo(board, from) {
    var positions = getPositionsWhereCanIGo(board, from);
    return mapBoard(board, function (position) {
        return Position.setICanGoHere(positions, position);
    });
}
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
1119796
private int indexRows(TableIndex tableIndex, FeatureResultSet resultSet) {

		int count = -1;

		try {
			while ((progress == null || progress.isActive())
					&& resultSet.moveToNext()) {
				if (count < 0) {
					count++;
				}
				try {
					FeatureRow row = resultSet.getRow();
					boolean indexed = index(tableIndex, row.getId(),
							row.getGeometry());
					if (indexed) {
						count++;
					}
					if (progress != null) {
						progress.addProgress(1);
					}
				} catch (Exception e) {
					log.log(Level.SEVERE, "Failed to index feature. Table: "
							+ tableIndex.getTableName() + ", Position: "
							+ resultSet.getPosition(), e);
				}
			}
		} finally {
			resultSet.close();
		}

		return count;
	}
598958
def read_lsm_positions(fh):
    """"""
    size = struct.unpack('<I', fh.read(4))[0]
    return fh.read_array('<2f8', count=size)