App::War - turn one big decision into many small decisions
use App::War; my $war = App::War->new; $war->items(qw/ this that the-other that-too /); $war->init; $war->rank; print $war->report;
How do you go about ranking a number of items? One way to do it is to compare the objects two at a time until a clear winner can be established.
This module does just that, using a topological sort to establish a unique ordering of all the "combatants" in the "war".
This module is modeled loosely after http://kittenwar.com/, a crowdsourced web application for determining the cutest kitten in the universe.
Constructs a new war object.
Starts the war.
Uses the content of $self->items to initialize a graph containing only vertices, one per item.
$self->items
Returns the current state of the war graph as a multiline string.
Returns the graph object that stores the user choices.
Get/set the items to be ranked. It's a bad idea to modify this once the war has started.
Starts the process of uniquely ordering the graph vertices. This method calls method tsort_not_unique until it returns false, i.e. we have a unique topo sort.
tsort_not_unique
This method returns a true value (more on this later) if the graph currently lacks a unique topo sort. If the graph has a unique sort, the "war" is over, and results should be reported.
If the graph lacks a unique topological sort, this method returns an arrayref containing a pair of vertices that have an ambiguous ordering. From http://en.wikipedia.org/wiki/Topological_sorting:
If a topological sort has the property that all pairs of consecutive vertices in the sorted order are connected by edges, then these edges form a directed Hamiltonian path in the DAG. If a Hamiltonian path exists, the topological sort order is unique; no other order respects the edges of the path.
This property of the topological sort is used to ensure that we have a unique ordering of the "combatants" in our "war".
Handles user interaction choosing one of two alternatives. Arguments $index1 and $index2 are indexes into the internal array of items to be ranked, and indicate the two items that need to have their rank disambiguated.
$index1
$index2
John Trammell, <johntrammell@gmail.com>
<johntrammell@gmail.com>
Please report any bugs or feature requests to bug-app-war at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-War. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-app-war at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::War
Your operating system may also have installed a manual page for this module; it would likely be available via the command
man war
You can also look for information at:
GitHub
http://github.com/trammell/app-war
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-War
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-War
CPAN Ratings
http://cpanratings.perl.org/d/App-War
Search CPAN
http://search.cpan.org/dist/App-War/
Copyright 2009 John Trammell, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install App::War, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::War
CPAN shell
perl -MCPAN -e shell install App::War
For more information on module installation, please visit the detailed CPAN module installation guide.