sol.models.tourney – Tournaments

class sol.models.tourney.Rank(points, bucholz, netscore, totscore, rate)
bucholz

Alias for field number 1

netscore

Alias for field number 2

points

Alias for field number 0

rate

Alias for field number 4

totscore

Alias for field number 3

class sol.models.tourney.RankingStats

An interim object used keep the ongoing values needed to compute the ranking of a single competitor.

bucholz

Bucholz.

drawn()

Update stats after a tie.

lost(netscore)

Update stats after a lost match.

netscore

Net score.

played_matches

Number of played matches.

points

Overall points.

rank(rate)

Return the final Rank.

real_points

Points made against real competitors.

totscore

Total score.

virtual_points

Estimated further points, after retirement.

won(netscore, against_phantom)

Update stats after a winned match.

class sol.models.tourney.Tourney(**kwargs)

A single tournament.

_areFinalTurnsEnoughForPrizing()

Determine whether final rounds are enough to complete the tourney with prize-giving.

_assignAsisPrizes()

Assign decreasing integer numbers as final prizes, down to 1 to the last competitor.

_assignBoards(matches, comp_boards, available_boards=None)

Assign a table to each match, possibly one not already used.

_assignCentesimalPrizes()

Assigns 100 to the winner, 1 to the last, linear interpolation to the others.

_assignFixed40Prizes()

Assign fixed prizes to the first 40 competitors.

_assignFixedPrizes(prizes=None)

Assign fixed prizes to the first 16 competitors.

_assignMillesimalPrizes()

Assign 1000 points to the winner stepping down in fixed amount.

_combine(competitors, done, _level=0)

Build the next round, based on current ranking.

This recursively tries to build the next round, pairing together competitors that did not already played against each other.

_computeFinalWins()

Compute the number of matches won by each competitor in the finals

_dazedVisitor(pivot, competitors, done)

Visit the competitors, giving precedence to the competitors with the same points.

Parameters:
  • pivot – a Competitor instance
  • competitors – a list of possible opponents
  • done – the set of already played pairings

Like _serialVisitor() this yields the positions of the competitors that didn’t meet pivot. It starts looking at the competitors with the same points, and then goes on with the others: this is to postpone as much as possible the match between the strongest competitors.

_makeFirstTurn()

Create the first round of a tourney, pairing competitors in a random way.

_makeNextAAATurn(competitors, done)

Mechanically generate next turn out of all possible matches.

_makeNextTurn()

Build the next round of the game.

_serialVisitor(pivot, competitors, done)

Visit the competitors in order.

Parameters:
  • pivot – a Competitor instance
  • competitors – a list of possible opponents
  • done – the set of already played pairings

This is a generator, used by the combination maker in the simplest case: it yields the position in the list, maintaining the order, of the items that haven’t played against competitor pivot. skip is a set containing the previous matches (it contains both (a,b) and (b,a)).

Given that the list of competitors is sorted by their rank, this effectively tries to combine players with the same strength.

allPlayers()

Generator that return all involved players.

assignPrizes()

Consolidate final points.

caption(html=None, localized=True)

Return a possibly HTML-decorated caption of the entity.

Parameters:
  • html – either None (the default) or a boolean value
  • localized – a boolean value, True by default
Return type:

str

If html is None or True then the result may be an HTML representation of the entity, otherwise it is plain text.

If localized is False then the localization is turned off.

classmethod check_insert(session, fields)

Check description validity

check_update(fields)

Check description validity

competitors

List of competitors.

computeRanking(turn=None)

Recompute competitors ranking.

Parameters:turn – if given, compute the ranking up to that turn
Returns:a list of tuples, each containing one of the competitors and a Rank instance, sorted on the second item in descending order

Compute each competitor rank by examining the matches of this tourney, summing up each other’s current ranking position as the bucholz.

countdownstarted

Timestamp of the start of the clock countdown, milliseconds since Unix epoch.

couplings

Kind of pairing method used to build next round. It may be all, serial or dazed.

currentturn

The current round.

date

Event date.

delaytoppairing

Number of rounds for which pairing of top players should be postponed, if possible.

description

Event description.

duration

Duration in minutes of each round, used by the clock.

finalkind

Kind of finals. It may be simple or bestof3.

finals

The number of finals that will be played.

finalturns

Whether the tourney is in final rounds state.

idchampionship

Related championship’s ID.

idowner

ID of the user that is responsible for this record.

idrating

Possible rating ID this tourney uses and updates.

idtourney

Primary key.

location

Event location.

makeFinalTurn()

Generate the final matches.

makeNextTurn()

Setup the next round.

If there are no matches, build up the first round using a random coupler. Otherwise, using current ranking, create the next round pairing any given competitor with a not-yet-met other one that follows him in the ranking.

matches

List of matches, sorted by round and board.

owner

The owner of this record, admin when None.

phantomscore

The score assigned to a player in matches against the Phantom.

prealarm

Prealarm before the end of the round.

prized

Whether the tourney is closed, and final prizes updated.

rankedturn

The highest round considered in the ranking.

ranking

Competitors sorted by their rank.

Return type:sequence
Returns:sorted list of competitors
replay(date, newidowner=None)

Clone this tourney, creating new one at given date.

Of the original, only the competitors are copied. This is particularly useful for doubles (or team), so that the players get copied in the same order.

resetPrizes()

Reset assigned final points.

retirements

Policy used to adjust the bucholz of competitors who played against retired players.

serialize(serializer)

Reduce a single tourney to a simple dictionary.

Parameters:serializer – a Serializer instance
Return type:dict
Returns:a plain dictionary containing a flatified view of this tourney
updateRanking()

Recompute and update competitors ranking.