Domino.pm

filter: Statementstmt 34.0% 83 / 244 Branchbran 10.7% 6 / 56 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 52.9% 18 / 34 Podpod 90.0% 9 / 10 totaltotal 30.8% 116 / 376 CC 42 SCAR 30.4
CC
42
Cov
28%
result
56.0
_save
56.0
play
42.0
CRAP 20.9
« Domino/Player.pm ↑ Summary Domino/Tile.pm »
1 package Games::Domino;
2  
3 2 $Games::Domino::VERSION = '0.22';
4 2 $Games::Domino::AUTHORITY = 'cpan:MANWAR';
5  
6 =head1 NAME
7  
8 Games::Domino - Interface to the Domino game.
9  
10 =head1 VERSION
11  
12 Version 0.22
13  
14 =cut
15  
16 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use List::Util qw(shuffle);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Term::ANSIColor::Markup;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use Games::Domino::Tile;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Games::Domino::Player;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Games::Domino::Params qw($ZeroOrOne $ZeroToSix);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 ▶use overload ('""' => \&as_string);
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 2 has 'stock' => (is => 'rw');
31 2 has 'board' => (is => 'rw');
32 2 has 'human' => (is => 'rw');
33 2 has 'computer' => (is => 'rw');
34 2 has 'current' => (is => 'rw');
35 2 has 'board_l' => (is => 'rw', isa => $ZeroToSix);
36 2 has 'board_r' => (is => 'rw', isa => $ZeroToSix);
37 2 ▶has 'cheat' => (is => 'ro', isa => $ZeroOrOne, default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
38 1 ▶has 'debug' => (is => 'rw', isa => $ZeroOrOne, default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
39 3 ▶has 'action' => (is => 'rw', default => sub { [] });
Subroutine __ANON__: called CC=1 SCAR=0.0
40  
41 =head1 DESCRIPTION
42  
43 This is a very basic Domino game played by two players (Computer vs Human) at the
44 moment. This is just an initial draft of Proof of Concept, also to get my head
45 around the game which I have never played in my life before.There is a cheat flag
46 which makes tiles for "Computer" visible to the other player "Human". Avoid this
47 flag if possible.By default the cheat flag is turned off.There is a debug switch
48 as well which is turned off by default. They are arranged like here before we
49 shuffle to start the the game.
50  
51 [0 | 0]
52 [0 | 1] [1 | 1]
53 [0 | 2] [1 | 2] [2 | 2]
54 [0 | 3] [1 | 3] [2 | 3] [3 | 3]
55 [0 | 4] [1 | 4] [2 | 4] [3 | 4] [4 | 4]
56 [0 | 5] [1 | 5] [2 | 5] [3 | 5] [4 | 5] [5 | 5]
57 [0 | 6] [1 | 6] [2 | 6] [3 | 6] [4 | 6] [5 | 6] [6 | 6]
58  
59 =head1 SYNOPSIS
60  
61 Below is the working code for the Domino game using the L<Games::Domino> package.
62 The game script C<play-domino> is supplied with the distribution and on install,
63 is available to play with.
64  
65 use strict; use warnings;
66 use Games::Domino;
67  
68 select(STDOUT);
69 $|=1;
70  
71 $SIG{'INT'} = sub {
72 print {*STDOUT} "\n\nCaught Interrupt (^C), Aborting the game.\n"; exit(1);
73 };
74  
75 my $game = Games::Domino->new;
76 print {*STDOUT} $game->instructions, "\n";
77  
78 my ($response);
79 do {
80 my $move = 1;
81 do {
82 my ($index);
83 if ($move % 2 == 1) {
84 print {*STDOUT} $game->show, "\n";
85 do {
86 print {*STDOUT} "Pick your tile [" . $game->get_available_tiles . "] or [B]? ";
87 $index = <STDIN>;
88 chomp $index;
89 } until ($game->is_valid_tile($index));
90 }
91  
92 $game->play($index);
93 $move++;
94  
95 } until ($game->is_over);
96  
97 print {*STDOUT} $game->show, "\n";
98 print {*STDOUT} $game->result, "\n";
99 $game->reset;
100  
101 do {
102 print {*STDOUT} "Do you wish to continue (Y/N)? ";
103 $response = <STDIN>;
104 chomp($response);
105 } until (defined $response && ($response =~ /^[Y|N]$/i));
106  
107 } until ($response =~ /^N$/i);
108  
109 print {*STDOUT} "\nThank you.\n";
110  
111 Once it is installed, it can be played on a terminal/command window as below:
112  
113 $ play-domino
114  
115 =cut
116  
117 sub BUILD {
118 1 ▶ my ($self) = @_;
Subroutine BUILD: called CC=2 SCAR=7.2
Pod undocumented
119  
120 1 $self->{human} = Games::Domino::Player->new({ name => 'H', show => 1 });
121 1 ▶ if ($self->cheat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cheat) { } 0 1 1
122 0 $self->{computer} = Games::Domino::Player->new({ name => 'C', show => 1 });
123 }
124 else {
125 1 $self->{computer} = Games::Domino::Player->new({ name => 'C' });
126 }
127  
128 1 $self->_init;
129 }
130  
131 =head1 METHODS
132  
133 =head2 play()
134  
135 Pick a tile from the current player. If no matching tile found then picks it from
136 the stock until it found one or the stock has only 2 tiles left at that time the
137 game is over.
138  
139 =cut
140  
141 sub play {
142 0 ▶ my ($self, $index) = @_;
Subroutine play: not called CC=6 SCAR=37.4
Pod documented
143  
144 0 my $player = $self->current;
145 0 my $name = $player->name;
146  
147 0 ▶ if (defined $index) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $index) { } 0 0 0
148 0 ▶ if ($index =~ /^B$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index =~ /^B$/i) { } 0 0 0
149 0 $self->_pick_from_bank($player);
150 }
151 else {
152 0 my $tile = $player->_tile($index);
153 0 ▶ print {*STDOUT} "[H] [P]: $tile [S]\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
154 0 splice(@{$player->{bank}}, $index-1, 1);
155 0 $self->_save($tile);
156 }
157 }
158 else {
159 0 my $tile = $player->pick($self->board_l, $self->board_r);
160 0 ▶ if (defined $tile) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tile) { } 0 0 0
161 0 ▶ print {*STDOUT} "[C] [P]: $tile [S]\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
162 0 $self->_save($tile);
163 }
164 else {
165 0 $self->_pick_from_bank($player);
166 }
167 }
168 }
169  
170 =head2 get_available_tiles()
171  
172 Returns all available tile's index.
173  
174 =cut
175  
176 sub get_available_tiles {
177 0 ▶ my ($self) = @_;
Subroutine get_available_tiles: not called CC=1 SCAR=6.9
Pod documented
178  
179 0 return $self->current->_available_indexes;
180 }
181  
182 =head2 is_valid_tile($index)
183  
184 Return 1/0 depending on whether the tile at the given C<$index> is valid or not.
185  
186 =cut
187  
188 sub is_valid_tile {
189 0 ▶ my ($self, $index) = @_;
Subroutine is_valid_tile: not called CC=4 SCAR=30.0
Pod documented
190  
191 0 ▶ return (defined($index)
Condition0%0/9
defined $index && ($index =~ /^B$/i || $self->current->_validate_index($index) && $self->current->_validate_tile($index, $self->board_l, $self->board_r))
!ll&&!rl&&r
000
$index =~ /^B$/i or $self->current->_validate_index($index) and $self->current->_validate_tile($index, $self->board_l, $self->board_r)
l!l&&r!l&&!r
000
$self->current->_validate_index($index) and $self->current->_validate_tile($index, $self->board_l, $self->board_r)
!ll&&!rl&&r
000
MC/DC0%0/4
defined $index && ($index =~ /^B$/i || $self->current->_validate_index($index) && $self->current->_validate_tile($index, $self->board_l, $self->board_r))
defined $index $index =~ /^B$/i $self->current->_validate_index($index) $self->current->_validate_tile($index, $self->board_l, $self->board_r)
Truth table0%0/5
A && B or C and D
A= defined $indexB= $index =~ /^B$/iC= $self->current->_validate_index($index)D= $self->current->_validate_tile($index, $self->board_l, $self->board_r)
ABCDresult
0XXX0
100X0
10100
11XX1
10111
192 && (($index =~ /^B$/i)
193 ||
194 ($self->current->_validate_index($index)
195 && $self->current->_validate_tile($index, $self->board_l, $self->board_r))
196 ));
197 }
198  
199 =head2 is_over()
200  
201 Returns 1 or 0 depending whether the game is over or not.The game can be declared
202 over in the following circumstances:
203  
204 =over 2
205  
206 =item * Any one of the two players have used all his tiles.
207  
208 =item * There are only two (2) tiles left in the bank.
209  
210 =back
211  
212 =cut
213  
214 sub is_over {
215 0 ▶ my ($self) = @_;
Subroutine is_over: not called CC=3 SCAR=24.8
Pod documented
216  
217 0 return ((scalar(@{$self->{stock}}) == 2)
218 ||
219 0 (scalar(@{$self->{human}->{bank}}) == 0)
220 ||
221 0 ▶ (scalar(@{$self->{computer}->{bank}}) == 0));
Condition0%0/6
scalar @{$self->{'stock'};} == 2 || scalar @{$self->{'human'}{'bank'};} == 0 || scalar @{$self->{'computer'}{'bank'};} == 0
l!l&&r!l&&!r
000
scalar @{$self->{"stock"};} == 2 or scalar @{$self->{"human"}{"bank"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/3
scalar @{$self->{'stock'};} == 2 || scalar @{$self->{'human'}{'bank'};} == 0 || scalar @{$self->{'computer'}{'bank'};} == 0
scalar @{$self->{"stock"};} == 2 scalar @{$self->{"human"}{"bank"};} == 0 scalar @{$self->{'computer'}{'bank'};} == 0
Truth table0%0/4
A or B || C
A= scalar @{$self->{"stock"};} == 2B= scalar @{$self->{"human"}{"bank"};} == 0C= scalar @{$self->{'computer'}{'bank'};} == 0
ABCresult
1XX1
01X1
0011
0000
222 }
223  
224 =head2 result()
225  
226 Declares who is the winner against whom and by how much margin.
227  
228 =cut
229  
230 sub result {
231 0 ▶ my ($self) = @_;
Subroutine result: not called CC=7 SCAR=40.3
Pod documented
232  
233 0 ▶ print {*STDOUT} "STOCK : ", $self->as_string, "\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
234 0 my ($result);
235 0 ▶ if (scalar(@{$self->stock}) == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->stock;} == 2) { } 0 0 0
236 0 my $c_b = scalar(@{$self->computer->bank});
237 0 my $h_b = scalar(@{$self->human->bank});
238 0 ▶ if ($c_b < $h_b) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c_b < $h_b) { } 0 0 0
239 0 $result = $self->_result('Sorry, computer is the winner.', $c_b, $h_b);
240 }
241 else {
242 0 $result = $self->_result('Congratulation, you are the winner.', $h_b, $c_b);
243 }
244 }
245 else {
246 0 my $h = $self->human->value;
247 0 my $c = $self->computer->value;
248  
249 0 ▶ if (scalar(@{$self->human->bank}) == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$self->human->bank;} == 0) { } 0 0 0
elsif (scalar @{$self->computer->bank;} == 0) { } 0 0 0
250 0 $result = $self->_result('Congratulation, you are the winner.', $h, $c);
251 }
252 0 elsif (scalar(@{$self->computer->bank}) == 0) {
253 0 $result = $self->_result('Sorry, computer is the winner.', $c, $h);
254 }
255 else {
256 0 ▶ if ($h < $c) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h < $c) { } 0 0 0
257 0 $result = $self->_result('Congratulation, you are the winner.', $h, $c);
258 }
259 else {
260 0 $result = $self->_result('Sorry, computer is the winner.', $c, $h);
261 }
262 }
263 }
264  
265 0 return Term::ANSIColor::Markup->colorize($result);
266 }
267  
268 =head2 show()
269  
270 Returns the current state of the game.
271  
272 =cut
273  
274 sub show {
275 0 ▶ my ($self) = @_;
Subroutine show: not called CC=1 SCAR=6.9
Pod documented
276  
277 0 my $game = sprintf("%s\n", $self->_line);
278 0 $game .= sprintf("[C]: %s\n", $self->computer->as_string);
279 0 $game .= sprintf("[H]: %s\n", $self->human->as_string);
280 0 $game .= "[G]: " . $self->_board . "\n";
281 0 $game .= sprintf("%s", $self->_line);
282  
283 0 return $game;
284 }
285  
286 =head2 reset()
287  
288 Reset the game.
289  
290 =cut
291  
292 sub reset {
293 0 ▶ my ($self) = @_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod documented
294  
295 0 $self->human->reset;
296 0 $self->computer->reset;
297 0 $self->_init;
298 }
299  
300 =head2 instructions()
301  
302 Returns instructions regarding how to play.
303  
304 =cut
305  
306 sub instructions {
307 0 ▶ my ($self) = @_;
Subroutine instructions: not called CC=1 SCAR=6.9
Pod documented
308  
309 0 return $self->_instructions;
310 }
311  
312 =head2 as_string()
313  
314 Returns all the unused tiles remained in the bank.
315  
316 =cut
317  
318 sub as_string {
319 1 ▶ my ($self) = @_;
Subroutine as_string: called CC=3 SCAR=11.0
Pod documented
320  
321 1 ▶ return '[EMPTY]' unless scalar(@{$self->{stock}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"stock"};} 0 1 1
322  
323 1 my $domino = '';
324 1 foreach (@{$self->{stock}}) {
325 14 $domino .= sprintf("%s==", $_);
326 }
327  
328 1 $domino =~ s/[\=]+\s?$//;
329 1 $domino =~ s/\s+$//;
330 1 return $domino;
331 }
332  
333 #
334 #
335 # PRIVATE METHODS
336  
337 sub _pick_from_bank {
338 0 ▶ my ($self, $player) = @_;
Subroutine _pick_from_bank: not called CC=5 SCAR=34.0
339  
340 0 my $name = $player->name;
341 0 ▶ while (scalar(@{$self->{stock}}) > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"stock"};} > 2) 0 0 0
342 0 my $_tile = $self->_pick();
343 0 $player->save($_tile);
344 0 my $tile = $player->pick($self->board_l, $self->board_r);
345 0 ▶ if (defined $tile) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tile) { } 0 0 0
346 0 ▶ print {*STDOUT} "[$name] [B]: $tile [S]\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
347 0 $self->_save($tile);
348 0 last;
349 }
350 else {
351 0 ▶ print {*STDOUT} "[$name] [B]: $_tile [F]\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
352 }
353 }
354 }
355  
356 sub _save {
357 0 ▶ my ($self, $tile) = @_;
Subroutine _save: not called CC=7 SCAR=40.3
358  
359 0 ▶ if (!defined($self->{board}) || (scalar(@{$self->{board}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"board"} or scalar @{$self->{"board"};} == 0) 0 0 0
Condition0%0/3
not defined $self->{"board"} or scalar @{$self->{"board"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"board"} or scalar @{$self->{"board"};} == 0
not defined $self->{"board"} scalar @{$self->{"board"};} == 0
Truth table0%0/3
not(A) or B
A= not defined $self->{"board"}B= scalar @{$self->{"board"};} == 0
ABresult
1X1
011
000
360 0 push @{$self->{board}}, $tile;
361 0 $self->{board_l} = $tile->left;
362 0 $self->{board_r} = $tile->right;
363 0 $self->_action($tile);
364 0 $self->_next;
365 0 return;
366 }
367  
368 0 ▶ if ($self->{board_r} == $tile->left) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'board_r'} == $tile->left) { } 0 0 0
elsif ($self->{'board_r'} == $tile->right) { } 0 0 0
369 0 push @{$self->{board}}, $tile;
370 0 $self->{board_r} = $tile->right;
371 0 $self->_action($tile);
372 0 $self->_next;
373 0 return;
374  
375 }
376 elsif ($self->{board_r} == $tile->right) {
377 0 my $L = $tile->left;
378 0 my $R = $tile->right;
379 0 $tile->right($L);
380 0 $tile->left($R);
381 0 push @{$self->{board}}, $tile;
382 0 $self->{board_r} = $L;
383 0 $self->_action($tile);
384 0 $self->_next;
385 0 return;
386 }
387  
388 0 ▶ if ($self->{board_l} == $tile->left) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'board_l'} == $tile->left) { } 0 0 0
elsif ($self->{'board_l'} == $tile->right) { } 0 0 0
389 0 my $L = $tile->left;
390 0 my $R = $tile->right;
391 0 $tile->right($L);
392 0 $tile->left($R);
393 0 unshift @{$self->{board}}, $tile;
394 0 $self->{board_l} = $R;
395 0 $self->_action($tile);
396 0 $self->_next;
397 0 return;
398 }
399 elsif ($self->{board_l} == $tile->right) {
400 0 unshift @{$self->{board}}, $tile;
401 0 $self->{board_l} = $tile->left;
402 0 $self->_action($tile);
403 0 $self->_next;
404 0 return;
405 }
406  
407 0 return;
408 }
409  
410 sub _action {
411 0 ▶ my ($self, $tile) = @_;
Subroutine _action: not called CC=5 SCAR=34.0
412  
413 0 ▶ if (defined $self->{action} && scalar(@{$self->{action}}) == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'action'} and scalar @{$self->{'action'};} == 2) { } 0 0 0
Condition0%0/3
defined $self->{"action"} and scalar @{$self->{"action"};} == 2
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"action"} and scalar @{$self->{"action"};} == 2
defined $self->{"action"} scalar @{$self->{"action"};} == 2
Truth table0%0/3
A and B
A= defined $self->{"action"}B= scalar @{$self->{"action"};} == 2
ABresult
0X0
100
111
414 0 foreach (@{$self->board}) {
415 0 $_->color('blue');
416 }
417 0 $self->{action} = [ $tile ];
418 }
419 else {
420 0 push @{$self->{action}}, $tile;
421 }
422  
423 0 ▶ if ($self->current->name eq 'H') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current->name eq 'H') { } 0 0 0
424 0 $tile->color('green');
425 }
426 else {
427 0 $tile->color('red');
428 }
429 }
430  
431 sub _board {
432 0 ▶ my ($self) = @_;
Subroutine _board: not called CC=3 SCAR=24.8
433  
434 0 my $board = '';
435 0 ▶ if (scalar(@{$self->board})) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->board;}) { } 0 0 0
436 0 foreach (@{$self->board}) {
437 0 $board .= sprintf("<%s><bold>%s</bold><\/%s>==", $_->color, $_, $_->color);
438 }
439 }
440 else {
441 0 $board .= '<blue><bold>EMPTY</bold></blue>';
442 }
443  
444 0 $board =~ s/[\=]+\s?$//;
445 0 $board =~ s/\s+$//;
446 0 return Term::ANSIColor::Markup->colorize($board);
447 }
448  
449 sub _result {
450 0 ▶ my ($self, $title, $a, $b) = @_;
Subroutine _result: not called CC=1 SCAR=6.9
451  
452 0 my $result = sprintf("<blue><bold>%s ", $title);
453 0 $result .= sprintf("Final score [</bold></blue><green><bold>%d</bold></green>", $a);
454 0 $result .= sprintf("<blue><bold>] against [</bold></blue><red><bold>%d</bold></red>", $b);
455 0 $result .= '<blue><bold>].</bold></blue>';
456  
457 0 return $result;
458 }
459  
460 sub _line {
461 0 ▶ my ($self) = @_;
Subroutine _line: not called CC=1 SCAR=6.9
462  
463 0 return "="x81;
464 }
465  
466 sub _init {
467 1 ▶ my ($self) = @_;
Subroutine _init: called CC=3 SCAR=11.0
468  
469 1 $self->{stock} = $self->_prepare();
470 1 $self->{board} = [];
471 1 $self->{human}->save($self->_pick) for (1..7);
472 1 $self->{computer}->save($self->_pick) for (1..7);
473 1 $self->{current} = $self->{human};
474 }
475  
476 sub _pick {
477 14 ▶ my ($self) = @_;
Subroutine _pick: called CC=1 SCAR=0.0
478  
479 14 return shift @{$self->{stock}};
480 }
481  
482 sub _prepare {
483 1 ▶ my ($self) = @_;
Subroutine _prepare: called CC=4 SCAR=13.9
484  
485 1 my $tiles = [];
486 1 my $tile = Games::Domino::Tile->new({ left => 0, right => 0, double => 1 });
487 1 push @$tiles, $tile;
488 1 foreach my $R (1..6) {
489 6 my $L = 0;
490 6 my $D = 0;
491 6 ▶ while ($R >= $L) {
Branch: 1 branch
BranchTrueFalseTotal
if ($R >= $L) 27 6 33
492 27 ▶ ($R == $L)?($D = 1):($D = 0);
Branch: 1 branch
BranchTrueFalseTotal
$R == $L ? : 6 21 27
493 27 push @$tiles, Games::Domino::Tile->new({ left => $L, right => $R, double => $D });
494 27 $L++;
495 }
496 }
497  
498 1 $tiles = [shuffle @{$tiles}];
499 1 return $tiles;
500 }
501  
502 sub _next {
503 0 ▶ my ($self) = @_;
Subroutine _next: not called CC=2 SCAR=17.9
504  
505 0 ▶ if ($self->current->name eq 'H') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current->name eq 'H') { } 0 0 0
506 0 $self->current($self->computer);
507 }
508 else {
509 0 $self->current($self->human);
510 }
511 }
512  
513 sub _instructions {
514 0 ▶ my ($self) = @_;
Subroutine _instructions: not called CC=1 SCAR=6.9
515  
516 0 return qq {
517 _____ _____ _
518 / ____| _ _| __ \\ (_)
519 | | __ __ _ _ __ ___ ___ __ _(_|_) | | | ___ _ __ ___ _ _ __ ___
520 | | |_ |/ _` | '_ ` _ \\ / _ \\/ __| | | | | / _ \\| '_ ` _ \\| | ' \\ / \\
521 | |__| | (_| | | | | | | __/\\__ \\_ _| |__| | (_) | | | | | | | | | | (_) \|
522 \\_____|\\__,_|_| |_| |_|\\___||___(_|_)_____/ \\___/|_| |_| |_|_|_| |_|\\___/
523  
524 Tiles are numbered left to right starting with 1. Symbols used in this game are:
525 [C]: Code for the computer player
526 [H]: Code for the human player
527 [P]: Personal tile
528 [B]: Tile picked from the bank
529 [S]: Successfully found the matching tile
530 [F]: Unable to find the matching tile
531 [G]: All matched tiles so far
532  
533 Example:
534  
535 [C] [P]: [5 | 6] [S]
536 Computer picked the tile [5 | 6] from his own collection and successfully found
537 the matching on board.
538  
539 [H] [P]: [6 | 6] [S]
540 Human picked the tile [6 | 6] from his own collection and successfully found the
541 matching on board.
542  
543 [C] [B]: [2 | 6] [S]
544 Computer randomly picked the tile [2 | 6] from the bank and successfully found the
545 matching on board.
546  
547 [C] [B]: [3 | 4] [F]
548 Computer randomly picked the tile [3 | 4] from the bank and but failed to find the
549 matching on board.
550  
551 [H] [B]: [2 | 2] [S]
552 Human randomly picked the tile [2 | 2] from the bank and successfully found the
553 matching on board.
554  
555 [H] [B]: [3 | 6] [F]
556 Human randomly picked the tile [3 | 6] from the bank and but failed to find the
557 matching on board.
558 };
559 }
560  
561 =head1 AUTHOR
562  
563 Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>
564  
565 =head1 REPOSITORY
566  
567 L<https://github.com/manwar/Games-Domino>
568  
569 =head1 BUGS
570  
571 Please report any bugs or feature requests to C<bug-games-domino at rt.cpan.org>,
572 or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Domino>.
573 I will be notified, and then you'll automatically be notified of progress on your
574 bug as I make changes.
575  
576 =head1 SUPPORT
577  
578 You can find documentation for this module with the perldoc command.
579  
580 perldoc Games::Domino
581  
582 You can also look for information at:
583  
584 =over 4
585  
586 =item * RT: CPAN's request tracker (report bugs here)
587  
588 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Domino>
589  
590 =item * AnnoCPAN: Annotated CPAN documentation
591  
592 L<http://annocpan.org/dist/Games-Domino>
593  
594 =item * CPAN Ratings
595  
596 L<http://cpanratings.perl.org/d/Games-Domino>
597  
598 =item * Search CPAN
599  
600 L<http://search.cpan.org/dist/Games-Domino/>
601  
602 =back
603  
604 =head1 LICENSE AND COPYRIGHT
605  
606 Copyright 2012 - 2015 Mohammad S Anwar.
607  
608 This program is free software; you can redistribute it and / or modify it under
609 the terms of the the Artistic License (2.0). You may obtain a copy of the full
610 license at:
611  
612 L<http://www.perlfoundation.org/artistic_license_2_0>
613  
614 Any use, modification, and distribution of the Standard or Modified Versions is
615 governed by this Artistic License.By using, modifying or distributing the Package,
616 you accept this license. Do not use, modify, or distribute the Package, if you do
617 not accept this license.
618  
619 If your Modified Version has been derived from a Modified Version made by someone
620 other than you,you are nevertheless required to ensure that your Modified Version
621 complies with the requirements of this license.
622  
623 This license does not grant you the right to use any trademark, service mark,
624 tradename, or logo of the Copyright Holder.
625  
626 This license includes the non-exclusive, worldwide, free-of-charge patent license
627 to make, have made, use, offer to sell, sell, import and otherwise transfer the
628 Package with respect to any patent claims licensable by the Copyright Holder that
629 are necessarily infringed by the Package. If you institute patent litigation
630 (including a cross-claim or counterclaim) against any party alleging that the
631 Package constitutes direct or contributory patent infringement,then this Artistic
632 License to you shall terminate on the date that such litigation is filed.
633  
634 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
635 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
636 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
637 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
638 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
639 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
640 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
641  
642 =cut
643  
644 2 1; # End of Games::Domino
« Domino/Player.pm ↑ Summary Domino/Tile.pm »