-
Notifications
You must be signed in to change notification settings - Fork 17
Single elimination template generator for 256 and above players json #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
add Guardfile add .rspec file
set starting_seats build matches with basic hash already populated
add single elimination 256, 512, 1024 templates
|
Thanks for the contribution! I will take a look at this today, but to clarify a few things:
For generation, you can utilize the BracketTree::Bracket::Base to eliminate some of the complex processing. Here's something I whipped together that is missing the bracket = BracketTree::Bracket::SingleElimination.new
players = 64
players.times do |player|
bracket.add player, {}
end
bracket.depth[:total].times do |round|
bracket.round(round).all.each_slice(2) do |pair|
seats = [pair[0].position, pair[1].position]
parent = nil # We should really save a reference to the parent in the child
match = Match.new({ seats: seats, winner_to: parent, loser_to: nil})
bracket.matches << match
end
end
# take the round one positions and set them all as seeding. NOTE: this is not a
# typical seeding structure, but an example of how it can be done.
bracket.seed_order = bracket.round(1).all.map(&:position)
bracket.to_hI'm wondering if we need to change |
|
After finding an issue in the 128.json template (fix already merged) I replaced the line @first_seat = contenders > 64 ? @flat_seats.first + @flat_seats.second : @flat_seats.first*2with @first_seat = @flat_seats.first*2Now I need to write the double elimination generator, but don't know the logic to generate the loosers bracket seat positions starting from the winner seats positions |
Hi there, I need to generate json templates for trees with more than 128 players. So I did some reverse engineering on existing jsons, and built the single_elimination_generator.rb file to build these jsons.
I have a problem: I can't really understand the logic behind the json "seats" attributes.
. On the 128 files instead it seems to be the sum of the 2 preceeding seats (64 + 192 = 256). I don't know how to unify the 2 behaviors in code.
The relevant code is the following, please excuse the bad quality but I wanted to be able to inspect the various steps in my specs:
The code is in lib/bracket_tree/templates/single_elimination_generator.rb and the specs are in specs/single_elimination_json_generator_spec.rb
Once the issues are solved maybe you could consider merging this code, so that anyone can generate jsons with arbitrary numbers of players. Of course if you need some clarification please contact me.
Regards
Andrea