GithubHelp home page GithubHelp logo

flamontagne / rrschedule Goto Github PK

View Code? Open in Web Editor NEW
39.0 4.0 8.0 120 KB

Round-Robin Schedule generator

Home Page: http://flamontagne.github.com/rrschedule

License: MIT License

Ruby 99.46% Shell 0.54%

rrschedule's Issues

Home and Away issue for Round Robin

Hi,

I notice there is an issue with rrschedule when generating home and away for certain Teams.

schedule = RRSchedule::Schedule.new(:teams => (1..6).collect.to_a,
:rules => [RRSchedule::Rule.new(:wday => 1)],
:cycles => 2,
:shuffle => false
).generate

The data that it generates out

@rules=[#<RRSchedule::Rule:0x007fac6480a418 @gt=[Thu, 11 Feb 2016 19:00:00 +0000], @ps=["Field #1", "Field #2"], @wday=1>],
 @schedule=
  [{:team_a=>6, :team_b=>1, :gamedate=>Mon, 15 Feb 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>5, :team_b=>2, :gamedate=>Mon, 15 Feb 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>4, :team_b=>3, :gamedate=>Mon, 22 Feb 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>5, :team_b=>1, :gamedate=>Mon, 22 Feb 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>4, :team_b=>6, :gamedate=>Mon, 29 Feb 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>3, :gamedate=>Mon, 29 Feb 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>1, :team_b=>4, :gamedate=>Mon, 07 Mar 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>3, :team_b=>5, :gamedate=>Mon, 07 Mar 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>6, :gamedate=>Mon, 14 Mar 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>3, :team_b=>1, :gamedate=>Mon, 14 Mar 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>4, :gamedate=>Mon, 21 Mar 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>6, :team_b=>5, :gamedate=>Mon, 21 Mar 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>1, :gamedate=>Mon, 28 Mar 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>6, :team_b=>3, :gamedate=>Mon, 28 Mar 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>4, :team_b=>5, :gamedate=>Mon, 04 Apr 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>6, :team_b=>1, :gamedate=>Mon, 04 Apr 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>5, :gamedate=>Mon, 11 Apr 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>3, :team_b=>4, :gamedate=>Mon, 11 Apr 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>1, :team_b=>5, :gamedate=>Mon, 18 Apr 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>6, :team_b=>4, :gamedate=>Mon, 18 Apr 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>3, :gamedate=>Mon, 25 Apr 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>4, :team_b=>1, :gamedate=>Mon, 25 Apr 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>3, :team_b=>5, :gamedate=>Mon, 02 May 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>6, :gamedate=>Mon, 02 May 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>1, :team_b=>3, :gamedate=>Mon, 09 May 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>4, :team_b=>2, :gamedate=>Mon, 09 May 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>5, :team_b=>6, :gamedate=>Mon, 16 May 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>2, :team_b=>1, :gamedate=>Mon, 16 May 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>6, :team_b=>3, :gamedate=>Mon, 23 May 2016, :ps=>"Field #1", :gt=>Thu, 11 Feb 2016 19:00:00 +0000},
   {:team_a=>5, :team_b=>4, :gamedate=>Mon, 23 May 2016, :ps=>"Field #2", :gt=>Thu, 11 Feb 2016 19:00:00 +0000}],

As you look through the data, it seems like Team 1 and Team 6 is challenging each other on the same team_a and team_b slot for both rounds. By right for round 2, Team 6 should be team_b and Team 1 should be team_a.

I tried looking at your code but I can't see to find the issue. Do let me know if you need more info to help you in rectifying the issue. Thanks

balanced_ps => false throws error in get_best_ps

Hey man. Great gem.

schedule=RRSchedule::Schedule.new(
              :teams => [
                %w(A1 A2 A3 A4 A5 A6 A7 A8),
                %w(B1 B2 B3 B4 B5 B6 B7 B8),
                %w(C1 C2 C3 C4 C5 C6 C7 C8),
                %w(D1 D2 D3 D4 D5 D6 D7 D8),
                %w(E1 E2 E3 E4 E5 E6 E7 E8),                                                                
              ],

              :rules => [
                RRSchedule::Rule.new(
                  :wday => 3,
                  :gt => ["6:00 PM", "6:50 PM"],
                  :ps => ["North Field", "South Field"],
                )
                
              ],
              :cycles => 1,
              :start_date => Date.parse("2010/10/13"),
              :balanced_gt => false,
              :balanced_ps => false
            ).generate

This throws an error on this line: https://github.com/flamontagne/rrschedule/blob/master/lib/rrschedule.rb#L299

Debugging shows that it's only pulling the first letter, so it seems that inside the 'else' it should be @gt_ps_avail[gt].first instead of @gt_ps_avail[gt].first[0]

I know you haven't updated this in quite a while, so I'm not sure if there's an edge case that I'm missing.

I'd be happy to submit a pull request if you'd like. I've got some other ideas that I'd like to play with on this gem also.

Error when passed object contains paperclip data

If the object passed into the schedule generator has a paperclip object that was just created using a form, then it does not know how to handle the information and I get a type error. I solved the problem by passing an integer instead of the object itself, but this does break the specification for the gem. It could also be an issue with paperclip. Will submit a similar report.

Bug when extra available resources

If you have more playing surfaces available for the number of teams competing, the same playing surfaces might repeat themselves on the same gameday

Have a way to specify the maximum of playing locations in a rule

Say for example that there are 8 volleyball fields available and that you want a maximum of 4 games played at 7:00 PM. Currently you have to specify 4 playing locations in the array, like [1,2,3,4]. The problem is that no games will be played on fields 5,6,7 and 8. There should be a way to say: "Here is the list of all my playing locations. Now choose 4 of them for the games"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.