úÎD/B9$      !"#unstableEirik <clux> Albrigtsen Safe-Infered*Results in descending order of placement. Only constructed by " once the last game was played. Record of each player'-s accomplishments in the current tournament. #Player associated with the record. 5Placement of the player associated with this record. <Number of games the player associated with this record won. :Sum of scores for the games the associated player played.  The bracket location of a game. For   or ., most matches exist in the winners bracket () J , with the exception of the bronze final and possible crossover matches.  $ or ? with crossovers will have extra matches in the loser bracket (). Duel Tournament option. 5 elimation is a standard power of 2 tournament tree,  wheras $E elimination grants each loser a second chance in the lower bracket. OThe location of a game is written as to simulate the classical shorthand WBR2, O but includes additionally the game number for complete positional uniqueness. A 3 elimination final will have the unique identifier   let wbf = GameId WB p 1 where 'p == count t WB'. Power of a tournament.  It'=s defined as 2^num_players rounded up to nearest power of 2. type Power = Int LComputes both the upper and lower player seeds for a duel elimiation match. 4 The first argument is the power of the tournament: 5p :: 2^num_players rounding up to nearest power of 2 :The second parameter is the game number i (in round one). The pair (p,i) must obey p > 0 && 0 < i <= 2^(p-1). BCheck if the 3 criteria for perfect seeding holds for the current  power and seed pair arguments. N This can be used to make a measure of how good the seeding was in retrospect GSplits a numer of players into groups of as close to equal seeding sum J as possible. When groupsize is even and s | n, the seed sum is constant. ( Fixes the number of groups as ceil $ n /0 s, but will reduce s when all groups not full. 6Round robin schedules a list of n players and returns ; a list of rounds (where a round is a list of pairs). Uses  http:en.wikipedia.orgwikiRound-robin_tournament#Scheduling_algorithm ?Count the number of rounds in a given bracket in a Tournament. T TODO: rename to length once it has been less awkwardly moved into an internal part -Get the list of all GameIds in a Tournament. $ This list is also ordered by GameId's Ord, and in fact, T if the corresponding games were scored in this order, the tournament would finish, H and scorable would only return False for a few special walkover games. K TODO: if introducing crossovers, this would not be true for LB crossovers # => need to place them in WB in an ' interim round' 7Create match shells for an FFA elimination tournament. C Result comes pre-filled in with either top advancers or advancers  intersect seedList. G This means what the player numbers represent is only fixed per round. I TODO: Either String Tournament as return for intelligent error handling !;Check if a GameId exists and is ready to be scored through ". "3Score a match in a tournament and propagate winners/losers.  If match is not !., the Tournament will pass through unchanged. RFor a Duel tournament, winners (and losers if Double) are propagated immediately, [ wheras FFA tournaments calculate winners at the end of the round (when all games played). \There is no limitation on re-scoring old games, so care must be taken to not update too far a back ones and leaving the tournament in an inconsistent state. When scoring games more than one Z round behind the corresponding active round, the locations to which these propagate must  be updated manually. QTo prevent yourself from never scoring older matches, only score games for which  %9 returns True. Though this has not been implemented yet.   gid = (GameId WB 2 1) > tUpdated = if safeScorable gid then score gid [1,0] t else t TODO: strictify this function ! TODO: better to do a scoreSafe?  call this scoreUnsafe $  !"#$  !"#)  "!#   !"#&      !"#$%&'(Tournament-0.0.1Game.Tournament TournamentresultsSizeRulesDuelFFA Advancers GroupSizeResultsResultplayer placementwinstotalScoreBracketLBWB EliminationDoubleSingleGameIdbracketroundgameseeds duelExpectedgroupsrobincountkeys tournamentscorablescoretestcaseghc-prim GHC.Types safeScorable