php - Create tournament fixture lists -
i need figure out how solve this:
we trying create fixture list tournament, below find table generated webinterface have. (not sure if ideal layout make fixture list, may changes store , use basis task below).
the tournament concept x number of courts in same location. have court utilization close 100% possible. problem generate fixture list based on table without conflicts( team plays 2 games in same round) , have best utilization of courts.
explanation of concept: tournament_id id of main tournament. have sub tournaments, , identified pool_id. each pool may have several groups play round robin (single/double) group_id. have done setup of games teams playing each other located in home , visit, , round within group indicated round. means if group has 2 games in round 1 maximum games can played in group round, if 1 game maximum 1.
priority used this: equal priority means games should handled during creation of fixture list. in example pool_id=23 has 3 groups, 0,1,2. 1 , 2 has priority 1, , 0 has priority 2. means games group 0 cannot played before games in priority 1 groups 1 , 2 has been played. (it used keep control inside each pool.)
the number of courts in tournament known @ stage , example it's 4.
i able generate fixture list in 2 different ways:
1: use courts column , assign correct court.
2: not use courts column, , assign games next available court.
i have array can loop through make fixture list, game game, round round indication of court assigned.
mysql> select * tournament_games tournament_id=7 order priority,round,fetch_order; +---------------+---------+----------+-------+------+-------+--------+----------+-------------+-----------------------+ | tournament_id | pool_id | group_id | round | home | visit | courts | priority | fetch_order | gametype | +---------------+---------+----------+-------+------+-------+--------+----------+-------------+-----------------------+
| 7 | 20 | 1 | 1 | 156 | 49 | 4 | 1 | 1 | |
| 7 | 20 | 2 | 1 | 80 | 71 | 3 | 1 | 2 | |
| 7 | 18 | 1 | 1 | 69 | 64 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 1 | 68 | 65 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 1 | 155 | 50 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 1 | 153 | 100 | 2 | 1 | 6 | |
| 7 | 20 | 1 | 2 | 49 | 79 | 4 | 1 | 1 | |
| 7 | 20 | 2 | 2 | 71 | 74 | 3 | 1 | 2 | |
| 7 | 18 | 1 | 2 | 64 | 68 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 2 | 69 | 65 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 2 | 50 | 99 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 2 | 100 | 151 | 2 | 1 | 6 | |
| 7 | 20 | 1 | 3 | 156 | 79 | 4 | 1 | 1 | |
| 7 | 20 | 2 | 3 | 74 | 80 | 3 | 1 | 2 | |
| 7 | 18 | 1 | 3 | 65 | 64 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 3 | 69 | 68 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 3 | 155 | 99 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 3 | 153 | 151 | 2 | 1 | 6 | |
| 7 | 20 | 1 | 4 | 49 | 156 | 4 | 1 | 1 | |
| 7 | 18 | 1 | 4 | 65 | 68 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 4 | 64 | 69 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 4 | 50 | 155 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 4 | 100 | 153 | 2 | 1 | 6 | |
| 7 | 20 | 1 | 5 | 79 | 49 | 4 | 1 | 1 | |
| 7 | 18 | 1 | 5 | 65 | 69 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 5 | 68 | 64 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 5 | 50 | 99 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 5 | 100 | 151 | 2 | 1 | 6 | |
| 7 | 20 | 1 | 6 | 79 | 156 | 4 | 1 | 1 | |
| 7 | 18 | 1 | 6 | 69 | 68 | 3-4 | 1 | 4 | |
| 7 | 18 | 1 | 6 | 65 | 64 | 3-4 | 1 | 4 | |
| 7 | 23 | 1 | 6 | 99 | 155 | 1 | 1 | 5 | |
| 7 | 23 | 2 | 6 | 151 | 153 | 2 | 1 | 6 | |
| 7 | 20 | 0 | 1 | 0 | 0 | 3-4 | 2 | 3 | partidos de posición |
| 7 | 20 | 0 | 1 | 0 | 0 | 3-4 | 2 | 3 | partidos de posición |
| 7 | 20 | 0 | 1 | 0 | 0 | 3-4 | 2 | 3 | partidos de posición |
| 7 | 20 | 0 | 1 | 0 | 0 | 3-4 | 2 | 3 | partidos de posición |
| 7 | 23 | 0 | 1 | 0 | 0 | 1-2 | 2 | 7 | semifinales |
| 7 | 23 | 0 | 1 | 0 | 0 | 1-2 | 2 | 7 | semifinales |
| 7 | 23 | 0 | 2 | 0 | 0 | 1-2 | 2 | 7 | final y perdedor |
| 7 | 23 | 0 | 2 | 0 | 0 | 1-2 | 2 | 7 | final y perdedor |
+---------------+---------+----------+-------+------+-------+--------+----------+-------------+-----------------------+ 41 rows in set (0.00 sec)
anyone suggestions on how go solving this?
regards, roar
Comments
Post a Comment