<commit_before>module Cranberry
  module Mixins
    module MazeGenerator
      DIRECTIONS = [ [1, 0], [-1, 0], [0, 1], [0, -1] ]
     
<<<<<<< HEAD
      def setup_maze(options = {})

        @columns   ||= options[:columns]
        @rows      ||= options[:rows]
        @start_x     = rand(@columns)
        @start_y     = 0
        @end_x       = rand(@columns)
        @end_y       = @rows - 1
=======
      def initialize(width, height)
        @width   = width
        @height  = height
        @start_x = rand(width)
        @start_y = 0
        @end_x   = rand(width)
        @end_y   = height - 1
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
     
        # Which walls do exist? Default to "true". Both arrays are
        # one element bigger than they need to be. For example, the
        # @vertical_walls[x][y] is true if there is a wall between
        # (x,y) and (x+1,y). The additional entry makes printing easier.
<<<<<<< HEAD
        @vertical_walls   = Array.new(columns) { Array.new(rows, true) }
        @horizontal_walls = Array.new(columns) { Array.new(rows, true) }
        # Path for the solved maze.
        @path             = Array.new(columns) { Array.new(rows) }
=======
        @vertical_walls   = Array.new(width) { Array.new(height, true) }
        @horizontal_walls = Array.new(width) { Array.new(height, true) }
        # Path for the solved maze.
        @path             = Array.new(width) { Array.new(height) }
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
     
        # "Hack" to print the exit.
        @horizontal_walls[@end_x][@end_y] = false
     
        # Generate the maze.
<<<<<<< HEAD
        generate_maze
      end
     
      # Print a nice ASCII maze.
      def print_maze
        # Special handling: print the top line.
        puts @columns.times.inject("+") {|str, x| str << (x == @start_x ? "   +" : "---+")}
     
        # For each cell, print the right and bottom wall, if it exists.
        @rows.times do |y|
          line = @columns.times.inject("|") do |str, x|
=======
        generate
      end
     
      # Print a nice ASCII maze.
      def print
        # Special handling: print the top line.
        puts @width.times.inject("+") {|str, x| str << (x == @start_x ? "   +" : "---+")}
     
        # For each cell, print the right and bottom wall, if it exists.
        @height.times do |y|
          line = @width.times.inject("|") do |str, x|
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
            str << (@path[x][y] ? " * " : "   ") << (@vertical_walls[x][y] ? "|" : " ")
          end
          puts line
     
<<<<<<< HEAD
          puts @columns.times.inject("+") {|str, x| str << (@horizontal_walls[x][y] ? "---+" : "   +")}
=======
          puts @width.times.inject("+") {|str, x| str << (@horizontal_walls[x][y] ? "---+" : "   +")}
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
        end
      end
     
      private
     
      # Reset the VISITED state of all cells.
      def reset_visiting_state
<<<<<<< HEAD
        @visited = Array.new(@columns) { Array.new(@rows) }
=======
        @visited = Array.new(@width) { Array.new(@height) }
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
      end
     
      # Is the given coordinate valid and the cell not yet visited?
      def move_valid?(x, y)
<<<<<<< HEAD
        (0...@columns).cover?(x) && (0...@rows).cover?(y) && !@visited[x][y]
      end
     
      # Generate the maze.
      def generate_maze

=======
        (0...@width).cover?(x) && (0...@height).cover?(y) && !@visited[x][y]
      end
     
      # Generate the maze.
      def generate
>>>>>>> d2504d605e84d936b078c00afdaccf62205f88ed
        reset_visiting_state
        generate_visit_cell(@start_x, @start_y)
      end
     
      # Depth-first maze generation.
      def generate_visit_cell(x, y)
        # Mark cell as visited.
        @visited[x][y] = true
     
        # Randomly get coordinates of surrounding cells (may be outside
        # of the maze range, will be sorted out later).
        coordinates = DIRECTIONS.shuffle.map { |dx, dy| [x + dx, y + dy] }
     <commit_msg>OH NOEZ merge conflicts<commit_after>module Cranberry
  module Mixins
    module MazeGenerator
      DIRECTIONS = [ [1, 0], [-1, 0], [0, 1], [0, -1] ]
     
      def setup_maze(options = {})

        @columns   ||= options[:columns]
        @rows      ||= options[:rows]
        @start_x     = rand(@columns)
        @start_y     = 0
        @end_x       = rand(@columns)
        @end_y       = @rows - 1
     
        # Which walls do exist? Default to "true". Both arrays are
        # one element bigger than they need to be. For example, the
        # @vertical_walls[x][y] is true if there is a wall between
        # (x,y) and (x+1,y). The additional entry makes printing easier.
        @vertical_walls   = Array.new(columns) { Array.new(rows, true) }
        @horizontal_walls = Array.new(columns) { Array.new(rows, true) }
        # Path for the solved maze.
        @path             = Array.new(columns) { Array.new(rows) }
     
        # "Hack" to print the exit.
        @horizontal_walls[@end_x][@end_y] = false
     
        # Generate the maze.
        generate_maze
      end
     
      # Print a nice ASCII maze.
      def print_maze
        # Special handling: print the top line.
        puts @columns.times.inject("+") {|str, x| str << (x == @start_x ? "   +" : "---+")}
     
        # For each cell, print the right and bottom wall, if it exists.
        @rows.times do |y|
          line = @columns.times.inject("|") do |str, x|
            str << (@path[x][y] ? " * " : "   ") << (@vertical_walls[x][y] ? "|" : " ")
          end
          puts line
          puts @columns.times.inject("+") {|str, x| str << (@horizontal_walls[x][y] ? "---+" : "   +")}
        end
      end
     
      private
     
      # Reset the VISITED state of all cells.
      def reset_visiting_state
        @visited = Array.new(@columns) { Array.new(@rows) }
      end
     
      # Is the given coordinate valid and the cell not yet visited?
      def move_valid?(x, y)
        (0...@columns).cover?(x) && (0...@rows).cover?(y) && !@visited[x][y]
      end
     
      # Generate the maze.
      def generate_maze
        reset_visiting_state
        generate_visit_cell(@start_x, @start_y)
      end
     
      # Depth-first maze generation.
      def generate_visit_cell(x, y)
        # Mark cell as visited.
        @visited[x][y] = true
     
        # Randomly get coordinates of surrounding cells (may be outside
        # of the maze range, will be sorted out later).
        coordinates = DIRECTIONS.shuffle.map { |dx, dy| [x + dx, y + dy] }
     
{'fraction_non_alphanumeric': 0.14899670560047917, 'fraction_numerical': 0.02605570530098832, 'mean_word_length': 1.9566179725542274, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2634170', 'n_tokens_mistral': 2336, 'n_tokens_neox': 2201, 'n_words': 567}