Monday, March 28, 2016

TournamentCompare v0.003 - Validating a tournament template

Because the tournament template system is flexible enough to allow all sorts of formats, it is also flexible enough to bring in all sorts of loops, missing players, unlinked matches, etc, so I'll be making up a validator to vet each tournament template before running thousands of tests on an invalid tournament.

Here's the high level pseudocode:

  1. Start with the final match and work back along the player entry locations until all matches have been processed into a list (vettedMatchList) and all the players are in another list (competitorList). This also sets the match layer (how deep into the tournament that this match represents)
  2. Check to make sure that all TournamentTemplateMatches for this TournamentTemplate have been accounted for.
  3. Check to make sure that all competitors have an entry into the tournament
  4. Build a list (noExitMatchList) for each match that 2nd place continues in the tournament.This is combined with the match layer to evaluate final exit position for 2nd placegetters that do NOT continue.
  5. Mark the tournament as valid and update the database with match layers & exit positions.