15 puzzle game: Difference between revisions
m
→{{header|Perl 6}}: Update for recent proto requirement for overridden core subs
(→{{header|Go}}: Replace with a more idiomatic solution.) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Update for recent proto requirement for overridden core subs) |
||
Line 3,727:
=={{header|Perl 6}}==
{{works with|Rakudo|
Most of this is interface code. Reused substantial portions from the [[2048#Perl_6|2048]] task. Use the arrow keys to slide tiles, press 'q' to quit or 'n' for a new puzzle. Requires a POSIX termios aware terminal. Ensures that the puzzle is solvable by shuffling the board with an even number of swaps, then checking for even taxicab parity for the empty space.
<lang perl6>use Term::termios;
Line 3,816:
}
multi move('up') {
map { @board[*;$_] = reverse slide reverse @board[*;$_] }, ^n;
}
multi
map { @board[*;$_] = slide @board[*;$_] }, ^n;
}
multi
map { @board[$_] = reverse slide reverse @board[$_] }, ^n;
}
multi
map { @board[$_] = slide @board[$_] }, ^n;
}
|