7 use Moose::Autobox::Undef;
9 use autobox UNDEF => 'Moose::Autobox::Undef';
16 print("\n") unless ((++$count) % 3);
20 my $board = [ ('.') x 9 ];
24 my $choice = [ 1 .. 9 ]->any;
27 while ($board->any eq '.') {
30 print("Player ($player), enter the Position [1-9]: ");
33 unless ($in == $choice) {
34 print "\n\tPlease enter a value within 1-9\n\n";
39 if ($board->[$idx] ne '.') {
40 print "\n\tElement already entered at $in\n";
44 $board->[$idx] = $player;
50 [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ],
51 [ 0, 3, 6 ], [ 1, 4, 7 ], [ 2, 5, 8 ],
52 [ 0, 4, 8 ], [ 2, 4, 6 ],
55 my $row = $board->slice($_);
57 if (($row->all eq 'X') || ($row->all eq 'O')) {
58 print("\n\tPlayer ($player) Wins\n");
64 $player = $player eq 'X' ? 'O' : 'X';
72 tic_tac_toe.p6 - Tic-Tac-Toe
76 This is a Moose::Autobox port of a perl6 implementation
77 of the classic Tic-Tac-Toe game.
79 This uses a modified version of the one Rob Kinyon created
80 L<http://www.perlmonks.org/index.pl?node_id=451302>.
84 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
86 =head1 ACKNOLEDGEMENTS
88 This code was ported from the version in the Pugs examples/
89 directory. The authors of that were:
91 mkirank L<http://www.perlmonks.org/index.pl?node_id=451261>
93 Rob Kinyon L<http://www.perlmonks.org/index.pl?node_id=451302>
95 Stevan Little, E<lt>stevan@iinteractive.comE<gt>