Skip to content

Commit

Permalink
[examples] Fixed up tic_tac_toe for Rakudo
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.pugscode.org/pugs@30960 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
svatsan committed May 29, 2010
1 parent a79e668 commit c284e19
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/games/tic_tac_toe.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use v6;

sub print_board (@b) returns Void {
sub print_board (@b) { # returns Void {
say "+---+---+---+";
for @b -> $x, $y, $z {
say "| $x | $y | $z |";
Expand All @@ -10,7 +10,7 @@

my %player = ( X => 'Player 1', O => 'Player 2' );
my $entered = any();
my $choice = any(0 .. 8);
my $choice = one(0 .. 8);

my $player = 'X';
my @board = (1..9);
Expand All @@ -22,10 +22,10 @@

my $idx = $*IN.get - 1;

if (not ($idx == $choice)) {
if (!($idx eq $choice)) {
say "*** Please enter a value within 1-9";
}
elsif $idx == $entered {
elsif $idx eq $entered {
say "*** Some one already played at { $idx + 1 }";
}
else {
Expand All @@ -38,7 +38,7 @@
[ 1, 4, 7 ], [ 2, 5, 8 ],
[ 0, 4, 8 ], [ 2, 4, 6 ]
) -> @c {
if @board[@c] ~~ (<X X X> | <O O O>) {
if @board[@c] eq (<X X X>||<O O O>) {
print_board @board;
say "*** %player{$player} Wins!\n";
exit;
Expand Down

0 comments on commit c284e19

Please sign in to comment.