<commit_before>= rrschedule

rrschedule makes it easier to generate round-robin schedules for sport leagues. To generate a schedule, it needs a team list, a season 
start date, the day(s) of the week where the games are played and some other options.

It takes into consideration physical constraints such as the number of playing surfaces availables and game times.
Each round of the round-robin is splitted into multiple gamedays that respect these constraints. 

Say for example that you want to generate a round-robin schedule for your 15-teams volleyball league. 
If there are only 3 volleyball fields available and that games are played each monday at 6PM and 8PM, this is technically 
impossible to complete one round in a single day. So rrschedule will put the remaining games of this round on the next gameday 
and will start a new round right after.


== Demo
Online round-robin generator using RRSchedule: http://rrschedule.azanka.ca

== Installation
  gem install rrschedule
  require 'rrschedule'

== Prepare the schedule
  teams = ["Rockets","Jetpacks","Snakes","Cobras","Wolves","Huskies","Tigers","Lions",
           "Moose","Sprinklers","Pacers","Cyclops","Munchkins","Magicians","French Fries"]
           
  schedule=RRSchedule::Schedule.new(
                                  #array of teams that will compete against each other in the season
                                  :teams => teams,  
                                  
                                  #list of available playing surfaces (volleyball fields, curling sheets, tennis courts, etc)
                                  :playing_surfaces => ["A","B","C","D"],
                                  
                                  #day(s) of the week where games are played
                                  :wdays => [3],
                                  
                                  #Season will start on...                
                                  :start_date => Date.parse("2010/10/13"),
                                  
                                  #array of dates WITHOUT games
                                  :exclude_dates => [
                                                      Date.parse("2010/11/24"),
                                                      Date.parse("2010/12/15"),
                                                      Date.parse("2010/12/22"),
                                                      Date.parse("2010/12/29")
                                                    ],
                                                    
                                  #1 for Round Robin, 2 for Double Round Robin and so on. Default is 1
                                  :cycles => 1,
                                  
                                  #Shuffle team order before each cycle. Default is true
                                  :shuffle_initial_order => true,
                                  
                                  #Times of the day where the games are played
                                  :game_times => ["10:00 AM", "1:00 PM"]
                                )

== Generate the schedule
  schedule.generate
  
== Playing with the output

=== human readable schedule
  puts schedule.to_s

=== Iterate through schedule
  schedule.gamedays.each do |gd|
    puts gd.date.strftime("%Y/%m/%d")
    puts "===================="
    gd.games.each do |g|
      puts g.team_a.to_s + " Vs " + g.team_b.to_s + " on playing surface ##{g.playing_surface} at #{g.game_time.strftime("%I:%M %p")}"     
    end
    puts "\n"
  end

=== Team schedule
  test_team = "Sprinklers"
  games=schedule.by_team(test_team)
  puts "Schedule for team ##{test_team.to_s}"
  games.each do |g|
    puts "#{g.game_date.strftime("%Y-%m-%d")}: against #{g.team_a == test_team ? g.team_b.to_s : g.team_a.to_s} on playing surface ##{g.playing_surface} at #{g.game_time.strftime("%I:%M %p")}"     
  end

=== Face to Face
  games=schedule.face_to_face("Lions","Moose")
  puts "FACE TO FACE: Lions Vs Moose"
  games.each do |g|
    puts g.game_date.strftime("%Y/%m/%d") + " on playing surface " + g.playing_surface.to_s + " at " + g.game_time.strftime("%I:%M %p")
  end

=== Each round of the roun-robin without any date/time or playing location info
  #If you have an ODD number of teams you will see a "dummy" opponent in each round
  schedule.rounds.each do |round|
    puts "Round ##{round.round}"
    round.games.each do |g|
      puts g.team_a.to_s + " Vs " + g.team_b.to_s
    end
    puts "\n"
  end
  
== Issues / Other

Starting from version 0.1.5, calling Schedule#gamedays will returns an array of Gameday instances.
If you upgrade to this version you will need to change your code accordingly.

  #this won't work anymore
  schedule.gamedays.each do |gd,games|
      puts gd
      
      games.each do |g|
      end
      #...
  end
  
  #do this instead
  schedule.gamedays.each do |gd|
    puts gd.date
    gd.games.each do |g|
    end
    #...
  end


Hope this gem will be useful to some people!

You can read my blog here: www.rubyfleebie.com
<commit_msg>fix wrong code indentation in Readme<commit_after>= rrschedule

rrschedule makes it easier to generate round-robin schedules for sport leagues. To generate a schedule, it needs a team list, a season 
start date, the day(s) of the week where the games are played and some other options.

It takes into consideration physical constraints such as the number of playing surfaces availables and game times.
Each round of the round-robin is splitted into multiple gamedays that respect these constraints. 

Say for example that you want to generate a round-robin schedule for your 15-teams volleyball league. 
If there are only 3 volleyball fields available and that games are played each monday at 6PM and 8PM, this is technically 
impossible to complete one round in a single day. So rrschedule will put the remaining games of this round on the next gameday 
and will start a new round right after.


== Demo
Online round-robin generator using RRSchedule: http://rrschedule.azanka.ca

== Installation
  gem install rrschedule
  require 'rrschedule'

== Prepare the schedule
  teams = ["Rockets","Jetpacks","Snakes","Cobras","Wolves","Huskies","Tigers","Lions",
           "Moose","Sprinklers","Pacers","Cyclops","Munchkins","Magicians","French Fries"]
           
  schedule=RRSchedule::Schedule.new(
    #array of teams that will compete against each other in the season
    :teams => teams,  
    
    #list of available playing surfaces (volleyball fields, curling sheets, tennis courts, etc)
    :playing_surfaces => ["A","B","C","D"],
    
    #day(s) of the week where games are played
    :wdays => [3],
    
    #Season will start on...                
    :start_date => Date.parse("2010/10/13"),
    
    #array of dates WITHOUT games
    :exclude_dates => [
                        Date.parse("2010/11/24"),
                        Date.parse("2010/12/15"),
                        Date.parse("2010/12/22"),
                        Date.parse("2010/12/29")
                      ],
                      
    #1 for Round Robin, 2 for Double Round Robin and so on. Default is 1
    :cycles => 1,
    
    #Shuffle team order before each cycle. Default is true
    :shuffle_initial_order => true,
    
    #Times of the day where the games are played
    :game_times => ["10:00 AM", "1:00 PM"]
  )

== Generate the schedule
  schedule.generate
  
== Playing with the output

=== human readable schedule
  puts schedule.to_s

=== Iterate through schedule
  schedule.gamedays.each do |gd|
    puts gd.date.strftime("%Y/%m/%d")
    puts "===================="
    gd.games.each do |g|
      puts g.team_a.to_s + " Vs " + g.team_b.to_s + " on playing surface ##{g.playing_surface} at #{g.game_time.strftime("%I:%M %p")}"     
    end
    puts "\n"
  end

=== Team schedule
  test_team = "Sprinklers"
  games=schedule.by_team(test_team)
  puts "Schedule for team ##{test_team.to_s}"
  games.each do |g|
    puts "#{g.game_date.strftime("%Y-%m-%d")}: against #{g.team_a == test_team ? g.team_b.to_s : g.team_a.to_s} on playing surface ##{g.playing_surface} at #{g.game_time.strftime("%I:%M %p")}"     
  end

=== Face to Face
  games=schedule.face_to_face("Lions","Moose")
  puts "FACE TO FACE: Lions Vs Moose"
  games.each do |g|
    puts g.game_date.strftime("%Y/%m/%d") + " on playing surface " + g.playing_surface.to_s + " at " + g.game_time.strftime("%I:%M %p")
  end

=== Each round of the roun-robin without any date/time or playing location info
  #If you have an ODD number of teams you will see a "dummy" opponent in each round
  schedule.rounds.each do |round|
    puts "Round ##{round.round}"
    round.games.each do |g|
      puts g.team_a.to_s + " Vs " + g.team_b.to_s
    end
    puts "\n"
  end
  
== Issues / Other

Starting from version 0.1.5, calling Schedule#gamedays will returns an array of Gameday instances.
If you upgrade to this version you will need to change your code accordingly.

  #this won't work anymore
  schedule.gamedays.each do |gd,games|
      puts gd
      
      games.each do |g|
      end
      #...
  end
  
  #do this instead
  schedule.gamedays.each do |gd|
    puts gd.date
    gd.games.each do |g|
    end
    #...
  end


Hope this gem will be useful to some people!

You can read my blog here: www.rubyfleebie.com

{'fraction_non_alphanumeric': 0.10261333333333333, 'fraction_numerical': 0.0128, 'mean_word_length': 2.040207522697795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2580853', 'n_tokens_mistral': 2851, 'n_tokens_neox': 2679, 'n_words': 939}