NAME
Games::Tournament - Contestant Pairing
VERSION
Version 0.01
SYNOPSIS
$tourney = Games::Tournament->new(\@entrants);
next if $capablanca->met($alekhine)
$round = $tourney->meeting($member1, [$member2, $member3]);
...
DESCRIPTION
In a tournament, there are contestants, and matches over rounds between the contestants, in which they are differentiated by role. TODO firstround and roles.
REQUIREMENTS
Installing this module requires Module::Build.
METHODS
new
Games::Tournament->new( roles => [qw/Black White/];
rounds => 2, entrants => [ $a, $b, $c ] )
Creates a competition for entrants, over a number of rounds. entrants is a list of player objects. If the first round in which the module is used is not the first round of the competition itself, the actual round can be set in $Games::Tournament::firstround. If the 2 roles players take are not Black and White, then roles can be set in @Games::Tournament::roles. The objects should perhaps be instances of a class that overloads both string quoting with a 'name' method and arithmetical operations with an 'index' method. roles is an anonymous array.
rank
@rankings = $tourney->rank(@players)
Ranks a list of Games::Tournament::Contestant player objects by score, rating, title and name if they all have a score, otherwise ranks them by rating, title and name.
named
$tourney->named($name)
Returns the contestant whose name is $name. Entrants are grepped for the first one with a name with stringwise equality.
ided
$tourney->ided($id)
Returns the contestant whose id is $id. Ids are grepped for stringwise equality.
roleCheck
roleCheck(@games)
Returns the roles of the contestants in the individual $games in @games, eg qw/Black White/, qw/Home Away/, these being all the same (ie no typos), or dies.
met
@rounds = $tourney->met($deepblue, @grandmasters)
next if $tourney->met($deepblue, $capablanca)
In list context, returns an array of the rounds in which $deepblue met the corresponding member of @grandmasters (and of the empty string '' if they haven't met.) In scalar context, returns the number of grandmasters met. Don't forget to collect scorecards in the appropriate games first! (Assumes players do not meet more than once!) This is same as Games::Tournament::Contestant::met or different?
unmarkedCards
@unfinished = $tourney->unmarkedCards(@games)
Returns an array of the games which have no or a wrong result. The result accessor should be an anonymous hash with roles, or 'Bye' as keys and either 'Win' & 'Loss', 'Loss' & 'Win' or 'Draw' & 'Draw', or 'Bye', as values.
dupes
$games = $tourney->dupes(@grandmasters)
Returns an anonymous array, of the games in which @grandmasters have met. Don't forget to collect scorecards in the appropriate games first! (Assumes players do not meet more than once!)
updateScores
@scores = $tourney->updateScores;
Updates entrants' scores for the present (previous) round, using $tourney's play (ie games played) field. Returns an array of the scores in order of the player ids (not at the moment, it doesn't), dying on those entrants who don't have a result for the round. Be careful. Garbage in, garbage out. What is the present round?
randomRole
( $myrole, $yourrole ) = randomRole;
This returns the 2 roles, @Games::Tournament::roles in a random order.
scoreValues
$scores = scoreValues( {Win => 3, Loss => 2, Absent => 0, Draw => 1} )
Gets/sets the possible scoreValues in the competition, eg Home and Away, or Black and White, as an anonymous hash.
play
$tourney->play
Gets the games played, keyed on round and id of player. Also sets, but you don't want to do that.
entrants
$tourney->entrants
Gets/sets the entrants as an anonymous array of player objects.
round
$tourney->round
Gets/sets the round number of a round near you.
rounds
$tourney->rounds
Gets/sets the number of rounds in the tournament.
size
$size = 'Maxi' if $tourney->size > 2**$tourney->rounds
Gets the number of entrants
odd
float($lowest) if $self->odd(@group)
Tests whether the number of players in @group is odd or not.
AUTHOR
Dr Bean, <drbean, followed by the at mark (@), cpan, then a dot, and finally, org>
BUGS
Please report any bugs or feature requests to bug-games-tournament-swiss at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Tournament. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Games::Tournament
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2006 Dr Bean, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.