同じ軸上に居たら敵が追いかけてくるよう改良。
http://boobar.hoops.ne.jp/pacmaso.tar.gz ($n,$p,@e)=split/,/,<>;$c=@m=split//,<>;push@m,map{split//}<>;sub w{(*z,$g)=@_;
$z+=(0,!($z%$c)?$c-1:0,$z+$c>$#m?-$#m-1:0,$z-$c<1?$#m+1:0,$z%$c==$c-2?-$c+1:0)[
$g];$m[$z+$n[$g]]eq'#'or$z+=$n[$g]}sub u{@m[@e,$p]=@_}@n=($t=0,-1,$c,-$c,1);@g=
('.')x@e;while($m[$p]ne'o'or$t+=$n){u(('m')x@e,$d?'D':'C');$e=grep/[.o]/,@m,@g;
print@m,"R:$e P:$t >";$e&&($t||!$d)||exit;u @g,' ';w *p,<>%5||exit;for(@e){($w=
$_)==$p&&next;int$w/$c==int$p/$c&&w *w,$w<$p?4:1;$w%$c==$p%$c&&w *w,$w<$p?2:3;w
*w,1+int rand 4while grep$w==$_,@e;$_=$w}@g=@m[@e];$d=grep $p==$_,@e;$t--if$t}
この辺が限界かな?