しつこいがパックマンを一から作り直してみた。
操作方法は上のと一緒。
Usage: perl pacman map.txt
sub u{$m[$_[0]]=$_[1]}sub w{$_[0]+=$c if$_[1]==1&&$_[0]%$c==1;$_[0]-=$c if$_[1]
==4&&$_[0]%$c==0;$m[$_[0]+$n[$_[1]]]eq'#'or$_[0]+=$n[$_[1]]}@e=(25,45,439,459);
$p=357;@g=('.')x4;@m=('',map{chomp;split//}<>);$c=23;$l=21;sub e{exit}while(@n=
(0,-1,$c,-$c,1)){u$p,'P';u$e[$_],'E'for 0..3;$e=grep/\./,@m;print$m[$_],($_%$c?
'':"\n")for 1..@m;print"REST:$e\n> ";e if!$e;$p==$_&&e for @e;u$p,' ';u$e[$_],
$g[$_]for 0..3;$g=<>%5||e;w($p,$g);for(0..3){$p==$e[$_]&&next;w($e[$_],1+int
rand 4);$g[$_]=$m[$e[$_]]}}
---map.txt----
#######################
#..........#..........#
#.###.####.#.####.###.#
#.....................#
#.###.#.#######.#.###.#
#.....#....#....#.....#
#####.#### # ####.#####
#.# #.#
#####.# ####### #.#####
. # # .
#####.# ####### #.#####
#.# #.#
#####.# ####### #.#####
#..........#..........#
#.###.####.#.####.###.#
#...#.............#...#
###.#.#.#######.#.#.###
#.....#....#....#.....#
#.########.#.########.#
#.....................#
#######################