flamontagne / rrschedule Goto Github PK
View Code? Open in Web Editor NEWRound-Robin Schedule generator
Home Page: http://flamontagne.github.com/rrschedule
License: MIT License
Round-Robin Schedule generator
Home Page: http://flamontagne.github.com/rrschedule
License: MIT License
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
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.
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.
If you have more playing surfaces available for the number of teams competing, the same playing surfaces might repeat themselves on the same gameday
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"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.