Games::Sokoban::Controller - sokoban controller
use strict; use warnings; use Games::Sokoban::Controller; my $c = Games::Sokoban::Controller->new; $c->set_data(<<'LEVEL'); ####### #@ . # # $ # # # ####### LEVEL my @replaced = $c->go_down; for (@replaced) { my $char = $c->get($_->[0], $_->[1]); if ($char eq '@') { ... } # me if ($char eq '+') { ... } # me on a goal if ($char eq '$') { ... } # box if ($char eq '*') { ... } # box on a goal if ($char eq '.') { ... } # goal if ($char eq ' ') { ... } # floor } if ($c->solved) { print "SOLVED!\n"; }
This is a plain Sokoban controller. If you want to play Sokoban, you'll need some front-end.
creates an object.
set puzzle data (level). See Games::Sokoban for available formats.
returns an unique id of the puzzle.
(re-)initializes the puzzle.
return width and/or height of the puzzle.
returns a character of the (0-based) coordinate.
move the player (and a box if applicable), and return an array of coordinates where you need to update because of the move.
usually returns the direction of the player (left, right, up, down). You may want to use this if you create a graphical front-end.
left
right
up
down
returns true if everything is placed correctly.
Games::Sokoban
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2011 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Games::Sokoban::Controller, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Sokoban::Controller
CPAN shell
perl -MCPAN -e shell install Games::Sokoban::Controller
For more information on module installation, please visit the detailed CPAN module installation guide.