Single elimination template generator for 256 and above players json#3
Open
spaghetticode wants to merge 16 commits intoagoragames:mainfrom
Open
Single elimination template generator for 256 and above players json#3spaghetticode wants to merge 16 commits intoagoragames:mainfrom
spaghetticode wants to merge 16 commits intoagoragames:mainfrom
Conversation
add Guardfile add .rspec file
set starting_seats build matches with basic hash already populated
add single elimination 256, 512, 1024 templates
Contributor
|
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 |
Contributor
Author
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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