<commit_before>module Freecell
  # Methods for determining the legality of moves
  class MoveLegality
    def cascade_to_cascade_move?(command, cascades, free_cells)
      return false if command.num_cards > num_movable_cards(
        command, cascades, free_cells
      )
      return true if cascades[command.dest_index].empty?
      cascade_cards_legal?(command, cascades)
    end

    def cascade_to_free_cell_move?(free_cells)
      free_cells.length < 4
    end

    def free_cell_to_cascade_move?(command, cascades, free_cells)
      source_card = free_cells[command.source_index]
      dest_card = cascades[command.dest_index].last
      legal_move = legal_cascade_move?(source_card, dest_card)
      legal_move && !free_cells[command.source_index].nil?<commit_msg>Bugfix for crash when moving free cells<commit_after>module Freecell
  # Methods for determining the legality of moves
  class MoveLegality
    def cascade_to_cascade_move?(command, cascades, free_cells)
      return false if command.num_cards > num_movable_cards(
        command, cascades, free_cells
      )
      return true if cascades[command.dest_index].empty?
      cascade_cards_legal?(command, cascades)
    end

    def cascade_to_free_cell_move?(free_cells)
      free_cells.length < 4
    end

    def free_cell_to_cascade_move?(command, cascades, free_cells)
      source_card = free_cells[command.source_index]
      return false unless source_card
      dest_card = cascades[command.dest_index].last
      legal_move = legal_cascade_move?(source_card, dest_card)
      legal_move && !free_cells[command.source_index].nil?
{'fraction_non_alphanumeric': 0.06956521739130435, 'fraction_numerical': 0.0012422360248447205, 'mean_word_length': 4.018691588785047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5911581', 'n_tokens_mistral': 535, 'n_tokens_neox': 499, 'n_words': 105}