File Coverage

blib/lib/Games/PetalsAroundTheRose.pm
Criterion Covered Total %
statement 9 19 47.3
branch n/a
condition n/a
subroutine 3 6 50.0
pod n/a
total 12 25 48.0


line stmt bran cond sub pod time code
1             package Games::PetalsAroundTheRose;
2              
3 1     1   46409 use warnings;
  1         2  
  1         1227  
4 1     1   8 use strict;
  1         1  
  1         133  
5              
6             =head1 NAME
7              
8             Games::PetalsAroundTheRose - Petals Around the Rose Game
9              
10             =cut
11              
12             our $VERSION = '0.01';
13              
14             =head1 SYNOPSIS
15              
16             Use the C command instead.
17              
18             =head1 WARNING
19              
20             Don't look at the code for the solution. It will spoil half the fun
21             and it will only mean you gave up O:-)
22              
23             =head1 HISTORY
24              
25             I found this game at L.
26             Since I had nothing better to do and my brain was melting already (too
27             much work), I decided to give myself a break and code it in Perl.
28              
29             =head1 Instructions
30              
31             1. Let the dice be rolled.
32              
33             2. Enter how many petals you think are around the rose.
34              
35             3. Hit "Enter" and see if you got it right.
36              
37             4. Repeat steps 1-3 until you can get it right every time!
38              
39             5. Once you have figured it out, don't spoil the fun for others...let
40             them figure it out for themselves!
41              
42             =head1 Background
43              
44             This bit written by Chris David:
45              
46             I was introduced to "Petals Around the Rose" by Dr. Richard Duke at
47             the University of Michigan . Dr. Duke used to begin each of his
48             gaming/simulation courses with this exercise. While some students
49             would solve the problem right away, others would struggle all
50             semester. It had taken Dr. Duke well over a year himself, and he would
51             always explain that the smarter you were, the longer it took to figure
52             it out.
53              
54             The game is quite simple. Only a basic understanding of math is
55             required and an open and creative mind. The game can be used as an
56             example of how different people look at the world differently, and how
57             these different ways of looking can yield different answers. In
58             "Petals Around the Rose" there is always one correct answer. The
59             problem is how we define the problem.
60              
61             "Petals Around the Rose" is traditionally played with 5 six-sided
62             dice. I developed this version using Macromedia Flash as both an
63             exercise for me to learn Flash and as a way to share the game with the
64             world. Let me know what you think!
65              
66             Chris can be reached at C
67              
68             =cut
69              
70             our (@first_line, @second_line, @third_line);
71             BEGIN {
72 1     1   4 our @first_line = (' ', ' .', ' .', '. .', '. .', '. .');
73 1         6 our @second_line = (' . ', ' ', ' . ', ' ', ' . ', '. .');
74 1         245 our @third_line = (' ', '. ', '. ', '. .', '. .', '. .');
75             }
76              
77             sub _five_dice {
78 0     0     map { int rand(5) } (1..5);
  0            
79             }
80              
81             sub _total {
82 0     0     my $total = 0;
83 0           for (@_) {
84 0           $total += (0,0,2,0,4,0)[$_]; #print "Total is now $total (die was $_)\n";
85             }
86 0           $total;
87             }
88              
89             sub _display {
90 0           "+---+---+---+---+---+\n|" .
91 0           (join "|", map {$first_line[$_] } @_) . "|\n|" .
92 0           (join "|", map {$second_line[$_]} @_) . "|\n|" .
93 0     0     (join "|", map {$third_line[$_] } @_) .
94             "|\n+---+---+---+---+---+\n";
95             }
96              
97             =head1 AUTHOR
98              
99             Jose Castro, C<< >>
100              
101             =head1 BUGS
102              
103             Please report any bugs or feature requests to
104             C, or through the web interface at
105             L. I will be notified, and then you'll automatically
106             be notified of progress on your bug as I make changes.
107              
108             =head1 ACKNOWLEDGEMENTS
109              
110             Chris Davis, for putting up this game in a website.
111              
112             =head1 COPYRIGHT & LICENSE
113              
114             Copyright 2005 Jose Castro, All Rights Reserved.
115              
116             This program is free software; you can redistribute it and/or modify it
117             under the same terms as Perl itself.
118              
119             =cut
120              
121             1; # End of Games::PetalsAroundTheRose