A number of C++-defined functions are exported into the
(libtour builtin)
module and can be used by Scheme procedures within
a tournament definition.
A tournament definition which is a list of lists of lists ... can
be tedious to write. In order to simplify it as well as bring some fun
into rules definition a helper module (libtour common)
is
provided.
(libtour filters)
provides some team and game filters for use
in stage definitions.
To use these procedures in your modules, do
(use-modules (libtour builtin))
unless you use (libtour common)
which use
s and
re-export
s them.
Return a list of global team IDs for stage stage-id, group
group-id at position pos. If the stage is not initialized
(see section TStage state transitions), return #f
. Note that this
procedure returns a list rather than a string since more than one team
can occupy a position within a group due to a sorting conflict.
Return a pair of positions (low and high) for the team global-team-id in the group group-id of stage stage-id. Note that global-team-id is a global team ID.
Return global team ID for a team with local team ID local-team-id in stage stage-id.
Return local team ID for a team with global team ID global-team-id in stage stage-id.
Return local team ID for a team with name team-name in stage stage-id.
Return true if the group group-id within stage stage-id contains team with stage-local team id local-team-id.
Make a temporary group within the stage stage-id according to
the group specification group-spec. See section Groups definition,
for a complete description of a group specification list. A group
created with *make-tmp-group*
can later be deleted with
*delete-tmp-group*
.
Delete a temporary group group-id within stage stage-id.
Note that only groups created with *make-tmp-group*
can be
deleted.
Return list of the games for group group-id within stage
stage-id. If only-complete-games flag is #t
omit
the games that haven't been played yet. The return list is in the
following format:
Return list: '(<game> ...) <game>: (<game-spec> <game-res>) <game-spec>: fields for the game as defined inSCHEDULE-FORMAT
<game-res>: if the game result is set, fields for the game result as defined inGAMERES-FIELDS
. If the game result is not set, empty list.
If only-complete-games is #t
only games with a result set
will be returned.
See section Game schedule definition, for SCHEDULE-FORMAT
and
See section Standings and Game result fields definitions, for GAMERES-FIELDS
definitions.
Return #t
if the group group-id within the stage
stage-id is complete. If group-id argument is omitted,
return #t
if all groups in stage stage-id are complete
(the stage is complete).
Return an interger for a team's home position as defined in
SCHEDULE-HOME
variable (see section Game schedule definition). The
return value can be -1
(no home/away), 0
(home team
comes first), or 1
(home team comes second). tour-name is
the name of the tournament.
This is a "less-than" operation for date/time strings in the format
defined in the SCHEDULE-DATE
variable (see section Game schedule definition). It returns true
if time-1 is less than
time-2, and false
otherwise. tour-name is the name
of the tournament.
Make sure to import the (libtour common)
module before calling the
procedures described below.
Compare values for the key key in two associated lists
(alist-1 and alist-2). Return 1
if the value in the
first list is greater than the value in the second list, -1
if
less, and #f
if they are equal. No error checking is done.
Like cmp-assoc-field-p
, only compares difference of values
denoted by keys key-1 and key-2 in two associated lists.
Compare personal results between two teams specified by local team IDs
team-id-1 and team-id-2. The teams must belong to stage
stage-id
. cmp-f is a procedure to compare the teams
(see section Teams comparison procedure), and game-here-f is a
procedure to decide which games should be taken into account
(see section game-belongs-to-group procedure).
Return 1
, -1
, or #f
if the first teams' result is
greater, less, or equal to the second team correspondingly.
cmp-two-teams-p
will create a temporary group in the stage
stage-id with only two teams, sort them and compare their
position within the group. The temporary group is guaranteed to be
deleted in the presence of exceptions.
Return global team ID at position pos in group
group-id within stage stage-id, or #f
if more than
one team share that position. Will throw error if stage stage-id
is "uninitialized" (see section TStage state transitions). Note that
this procedure does not check if stage/group is complete.
Just like uniq-tid
but return #f
immediately if the
group group-id is not complete.
Replace each value of alist associative list with a thunk that returns the value when called. Return the resulting list.
Given associative list alist in the form (("team-id"
"stage-id" "group-id" position) ...)
produce new associative list in
the form (("team-id" . <thunk>) ...)
so that execution of the
thunk will produce a corresponding global team id for that
specification. If procedure proc is present, use it, else use
uniq-tid
.
Note: this is a peculiar procedure used to simplify calls to
uniq-tid
etc. There must be a nicer way...
Transform the associative list spec in the form ((key val1
val2) ...)
into a pair of associative lists (((key . val1) ...)
(key . val2) ...)
. Used in the game interpretation procedures
(see section Game results interpretation procedure).
Make and return a group specification list (see section Groups definition) given the argument denoted by keywords. It is possible to dynamically bind the last three arguments using Guile fluids so that they can be omitted. For instance (from the `ihwc2003_rules.scm'):
(with-fluids ((g-game-here-f-default 'ANY) (g-formula-default '(ROUND 1)) (g-cmp-f-default cmp-prelim-stage-f)) (list (make-group #:id "A" #:teams '("SVK" "GER" "UKR" "JPN")) (make-group #:id "B" #:teams '("RUS" "USA" "SUI" "DEN")) (make-group #:id "C" #:teams '("SWE" "CAN" "LAT" "BLR")) (make-group #:id "D" #:teams '("FIN" "CZE" "AUT" "SLO"))))
Make and return a stage specification list (see section Stages definition). No fluids here.
Filter-making procedures are used in creation of filtered groups
(see section Filtered groups). You have to explicitly list the
filter-making procedures you want to make avalable for a stage in the
FILTERS
field of the stage definition (see section Filters definition).
Make sure to import the (libtour filters)
module before using the
procedures described below.
A game filter. If used will make sure the group has no games. Useful for testing. Returns a procedure that takes a game associative list as the sole argument.
A game filter. A group that uses it will only consider home games
results. This filter cannot be used if SCHEDULE-HOME
is
-1
(see section Game schedule definition). Returns a procedure that
takes a game associative list as the sole argument.
A game filter. A group that uses it will only consider away games
results. This filter cannot be used if SCHEDULE-HOME
is
-1
(see section Game schedule definition). Returns a procedure that
takes a game associative list as the sole argument.
A game filter. A group that uses it will only have games played versus
group with ID vs-gr-id (string
type). Returns a procedure
that takes a game associative list as the sole argument.
A game filter. A group that uses it will only consider games that
satisfies action argument against team stage-local IDs in
team-ls. action is of the symbol
type and one of
Returns a procedure that takes a game associative list as the sole argument.
A game filter. A group that uses it will only have games played
between time-1 (inclusive) and time-2 (exclusive). The
time arguments are of the string
type, and their format should
be conform to the SCHEDULE-DATE
definition (see section Game schedule definition). Returns a procedure that takes a game
associative list as the sole argument.
A game filter. A group that uses it will only consider games that
satisfies action argument towards contents of field
fld-name (symbol
type) in val-ls. val-ls is a
list
of values (string
type). action is of the
symbol
type and one of
Returns a procedure that takes a game associative list as the sole argument.
A team filter. A group that uses it will only contain teams that
satisfy action argument towards contents of the team field
fld-name (symbol
type) in val-ls. val-ls is a
list
of values (string
type). action is of the
symbol
type and one of
Returns a procedure that takes a team associative list as the sole argument.
Go to the first, previous, next, last section, table of contents.