Problem
Design a database to record scores of a various competitions
of a card game and to calculate points and player standings based on the
scores.
Business Requirements
The smallest unit of competition is called match.
Each match play 3 or 4 players.
There could be multiple competitions happening at the same
time. The competitions are called tournaments.
Tournaments are time limited events. A tournament usually
lasts a year but it can be shorter or longer.
Tournaments are organized in rounds. For each round a
schedule is prepared. The schedule contains:
- Time interval for playing the round.
- Matches to be played. For each match the set of players is defined.
- Each player can only play one match of each round of a tournament.
For some tournaments the rounds are defined at the beginning
of the tournament, for some, the rounds are defined at the beginning of each
round.
The system has to support entering schedules independently
of the results. However, the results can only be provided for the matches in
schedule.
At the end of the match the score (or result) is calculated
for each player. Each player's score has to be even number. Sum of all players’
scores of a match has to be zero. The winner is the player with the greatest
(positive) score.
Each player earns point based on his/her result in a match.
Total of points in a tournament determines the player’s standing in the
tournament. The player with the most
points wins.
In order to explain how points are assigned let's first talk
about well-known example.
In football (soccer, for the minority), the score is:
Tottenham - Arsenal 2:0 (no pun intended).
In one point system, the winner gets 3 points, the looser 0
and in case of draw, both teams get 1 point. The actual scores are kept to
decide in case of point ties. In the example, Tottenham gets 3 points and
Arsenal 0.
However, in 1970s and before, the winner used to get only 2
points. In the example above, Tottenham would’ve got 2 points and Arsenal 0. It
was a different point system.
In both systems the actual scores (or goal differential) are
used to break ties – cases when multiple teams have the same number of points.
In our case, different tournaments can have different point
systems. What is always the same is the
way match score is presented: set of even numbers, one number per player,
totaling zero.
Since the total match score has to be zero, the distribution
of individual player scores can be:
- all scored 0
- some scored positive and some negative
Zero is treated as a positive score.
All point systems have the following characteristics:
- If two scores are equal then the corresponding points must be equal as well.
- If one score is greater than the other than the points for one score are greater than the points for the other
- We're now going to describe two point systems to be supported.
Point System 1
Matches are played by 3 players only (never 4).
The points assigned depend only on placement of players in a
match.
The points are assigned using one of:
- 4, 1, 0
- 3, 2, 0
If the winner has the only positive score, the points are
assigned as per 1.
If two players have positive scores, the points are assigned
as per 2.
If two or three players have the same score they'll all get
points for the next available place. So, if two or three players share the
first place, they all get 3 points, if two players share the second or third
place they both get 1 point.
To recap, the actual point for any match can only be:
4, 1, 0
(different scores, 2 negative)
4, 1, 1 (2
same negative scores)
3, 3, 3 (all
scored 0)
3, 2, 0 (different
scores, 2 positive)
3, 3, 0 (2
same positive scores)
Point System 2
Matches are played by 3 or 4 players.
The points assigned depend on:
- placement (rank) of players in a match
- strength of the table (opponents)
- actual score achieved
Let's first define the calculation of points for 2 and 3.
Each match is assigned a number, to be used as points,
called table strength, representing the degree of difficulty of the opponents.
This number is assigned when the round is defined (drawn) and does not depend
on the result of the match. The table strength is the number between 1 and the
number of matches in the round. 1 is assigned to the weakest table.
The points based on achieved score are calculated as the score
divided by 10 and rounded to the nearest integer (0.5 rounds to 1). This number
of points is limited to between -50 and
50. So, a player can actually lose up to 50 points for a score <= -495 or
win up to 50 points for a score >= 495.
If three players play a match, the points for placement are
assigned using one of:
- 40, 10, 0
- 30, 20, 0
If the winner has the only positive score, the points are
assigned as per 1.
If two players have positive scores, the points are assigned
as per 2.
If two or more players have the same score they'll both get
points equal to the average of points available for the places they won rounded
to the nearest integer. So, if 3 players share the first place, they all get 17
points, if two players share the first place they'll get 25 points, etc.
To recap, the actual point for any match played by 3 players
can only be:
40, 10,
0 (different scores, 2 negative)
40,
5, 5 (2 same
negative scores)
17, 17, 17 (all scored 0)
30, 20,
0 (different scores, 2 positive)
25, 25,
0 (2 same positive scores)
If four players play a match, the points for placement are
assigned as follows: 35, 25, 10, 0.
If two or more players have the same score they'll both get
points equal to the average of points available for the places they won rounded
to the nearest integer.
To recap, the actual point for any match played by 4 players
can only be:
35, 25, 10,
0 (different scores)
18, 18, 18, 18 (all scored 0)
23, 23, 23,
0 (first 3 scored the same)
35, 12, 12, 12 (last 3 scored the same)
30, 30,
5, 5 (first 2
scored the same and last 2 scored the same)
30, 30, 10,
0 (first 2 scored the same and last 2 have different scores)
35, 18, 18,
0 (second and third scored the same and first and last have
different scores)
35, 25,
5, 5 (last 2
scored the same and first two have different scores)
No comments:
Post a Comment