The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Games::Tournament::Contestant::Swiss::Preference A competitor's right to a role.

VERSION

Version 0.01

SYNOPSIS

    pray if $preference->role eq 'Black' and $preference->strength eq 'Strong';

DESCRIPTION

The preference, or expectation/right/duty one has with reference to a role, eg White, in the next round depends on the difference between the number of games previously played in it and in the alternative roles, and is either Mild, Strong, or Absolute. The more games played in other roles than in this role, the greater the right/duty to play the next game in this role. The FIDE Swiss Rules (C04.1) represent the difference as the number of Games as White minus the number as Black, so a greater number of games as Black is a negative number and of White a positive number. For equal number of games, +0 indicates the last game was as White, and -0 indicates the last game was as Black. So +0 represents a Mild preference for Black and -0 for White. This implementation uses a 'direction' field to perform the same function as the +/- sign. As an API, the strength method returns 'Mild', 'Strong', or 'Absolute' and the role method returns 'Black', 'White', or whatever the preferred role is, respecting the 2 consecutive games in the same role rule. A7

METHODS

new

    $pref = Games::Tournament::Contestant::Swiss::Preference->new(
        difference => 0, direction => 'Black', round => 0 );

The default round and difference are 0. The default direction is ''.

update

        $pref->update( $oldRoles  )

        Updates the difference (ie, the internal representation of preference) on the basis of the last 2 given roles. Minimal sanity check is performed. $oldRoles is a history of roles in previous rounds. The two last roles are needed to determine the preference if the same role was taken in the last 2 games. (Is this true? $self->direction can be other than the last role?) Byes are passed over. TODO What about absences?

asString

        $pref->asString

        The difference as a string, ^[+-][012]$. '0' represents a mild preference, '1' a strong one and '2' an absolute one. '-' represents a preference for White, or the first element of @Games::Tournament::Swiss::Config::roles, and '+' represents a preference for Black or the second element.

difference

        $pref->difference(2)

        Sets/gets the value of the difference in games played in one role over those played in other alternative roles. Equals either 0,1,2.

direction

        $pref->direction('Black')

Sets/gets the role which the player has taken more often, or more recently, than other alternative roles. The preference is thus for the other role.

strength

        $pref->strength

Gets the strength of the preference, 'Mild,' 'Strong,' or 'Absolute.'

role

        $pref->role

Gets the role which the preference entitles/requires the player to take in the next round.

round

        $pref->round

Sets/gets the round in this game up to which play is used to calculate the preference . The default is 0.

lastTwo

        $pref->lastTwo

Sets/gets a list of the roles in the last 2 games. If the 2 roles are the same, there is an absolute preference for the other role. (Is that actually the definition of absolute preference?)

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-contestant at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Tournament-Swiss. 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::Contestant::Swiss::Preference

You can also look for information at:

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.