Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

my 1krl final

26 views
Skip to first unread message

Xecutor

unread,
Aug 13, 2008, 1:40:23 AM8/13/08
to
I hope it's final ;)
1018 bytes in one line. pure perl.
colors removed :(
but now there is increasing with each turn on level chance that
enemy will move toward the player.
with this feature game is much more difficult, especially on later
levels.
windows users:
replace 'system clear' with 'system cls'
perl can be downloaded (for example) from www.activestate.com(18mb to
run 1kb program :))

Controls reminder:
Movement commands:
qwe
a d
zxc
Magic:
m
const 50 mana, kills all enemies around you (do not heal from this
kills).
Score when you win is number of kills/total number of turns.
Actually it is more of a challenge to win with least kills possible :)

packed code(should be onlined):
sub l:lvalue{$l[$_[0]][$_[1]]}sub r{int(rand($_[0]))}sub p{print@_}$h=
$m=100;$|=$x=$y=$d=1;p"Name:";chomp($n=<>);@a=-1..1;&gg;do{system
clear;p@$_,$/for@l;p"H$h M$m D$d\n>";$_=<>;$o=/[edc]/-/[qaz]/;$g=/
[zxc]/-/[qwe]/;if(/m/&&$m>=50){$m-=50;for$r(@a){for(@a){$f=\l($y+$r,$x+
$_);$$f eq'e'?$$f='.':0}}}l($y,$x)='.';$_=l($y+$g,$x+$o);if(/e/){$k++;
$h++;$_='.'}if(/\./){$x+=$o;$y+=$g}if(/>/){&gg;$d++;$x=$y=1}l($y,
$x)='@';for(@e){$p=$_->{y};$q=@$_{x};$f=\l($p,$q);if($$f ne'e'||@$_{d})
{@$_{d}=1;next}$$f='.';$g=r(3)-1;$o=r(3)-1;$g=($q<$x)-($q>$x),$o=($p<
$y)-($p>$y)if r(100)<$u/2;for$r(@a){for(@a){if(l($p+$r,$q+$_)eq'@'){$g=
$_;$o=$r}}}$s=\l($p+$o,$q+$g);$h-=r(10+$d)+5if$$s=~/@/;if($$s eq'.'){@
$_{x}+=$g;@$_{y}+=$o;$$s='e'}else{$$f='e'}}$t++;$u++;$m+=
$m<100}while($h>0&&$d<=10);$h>0?p"$n wins. Score $k/$t.\n":p"$n died.
\n";sub gg{for$r(0..19){l($r,$_)=$r&&$_&&$r<19&&
$_<19&&r(100)>20?'.':'#'for(0..19);}for(0..20+$d*5){$a=1+r(18);
$b=1+r(18);$e[$_]={x=>$a,y=>$b};l($b,$a)='e'}
$u=l(1,1)='@';l(2,2)=l(18,18)='.';l(19,19)='>'}

code readable (there is comment line with colored output):
sub l:lvalue{$l[$_[0]][$_[1]]}
sub r{int(rand($_[0]))}
sub p{print@_}
$h=$m=100;
$|=$x=$y=$d=1;
p"Name:";
chomp($n=<>);
@a=-1..1;
&gg;
do{
system clear;
# p map{$_ eq'e'?"\033[01;31me\033[00m":$_}@$_,$/for@l;
p@$_,$/for@l;
p"H$h M$m D$d\n>";
$_=<>;
$o=/[edc]/-/[qaz]/;$g=/[zxc]/-/[qwe]/;
if(/m/&&$m>=50)
{
$m-=50;
for$r(@a)
{
for(@a)
{
$f=\l($y+$r,$x+$_);
$$f eq'e'?$$f='.':0
}
}
}
l($y,$x)='.';
$_=l($y+$g,$x+$o);
if(/e/)
{
$k++;$h++;
$_='.'
}
if(/\./)
{
$x+=$o;
$y+=$g
}
if(/>/)
{
&gg;
$d++;
$x=$y=1
}
l($y,$x)='@';
for(@e)
{
$p=$_->{y};$q=@$_{x};
$f=\l($p,$q);
if($$f ne'e'||@$_{d})
{
@$_{d}=1;
next
}
$$f='.';
$g=r(3)-1;
$o=r(3)-1;
$g=($q<$x)-($q>$x),$o=($p<$y)-($p>$y)if r(100)<$u/2;
for$r(@a)
{
for(@a)
{
if(l($p+$r,$q+$_)eq'@')
{
$g=$_;
$o=$r
}
}
}
$s=\l($p+$o,$q+$g);
$h-=r(10+$d)+5if$$s=~/@/;
if($$s eq'.')
{
@$_{x}+=$g;
@$_{y}+=$o;
$$s='e'
}else
{
$$f='e'
}
}
$t++;$u++;
$m+=$m<100
}while($h>0&&$d<=10);
$h>0?p"$n wins. Score $k/$t.\n":p"$n died.\n";
sub gg
{
for$r(0..19)
{
l($r,$_)=$r&&$_&&$r<19&&$_<19&&r(100)>20?'.':'#'for(0..19);
}
for(0..20+$d*5)
{
$a=1+r(18);
$b=1+r(18);
$e[$_]={x=>$a,y=>$b};l($b,$a)='e'
}
$u=l(1,1)='@';
l(2,2)=l(18,18)='.';
l(19,19)='>'
}

Deveah

unread,
Aug 13, 2008, 8:03:58 AM8/13/08
to
On 13 Aug, 08:40, Xecutor <konstantin.stup...@gmail.com> wrote:
> I hope it's final ;)
> 1018 bytes in one line. pure perl.
> colors removed :(
> but now there is increasing with each turn on level chance that
> enemy will move toward the player.
> with this feature game is much more difficult, especially on later
> levels.
> windows users:
> replace 'system clear' with 'system cls'
> perl can be downloaded (for example) fromwww.activestate.com(18mbto
> run 1kb program :))
>
> Controls reminder:
> Movement commands:

Can you add an executable, so I add it to the site, or should I just
upload the source?

Xecutor

unread,
Aug 14, 2008, 1:38:17 AM8/14/08
to
> Can you add an executable, so I add it to the site, or should I just
> upload the source?
I belive for perl source is just fine :)
For some reason binary produced by perlcc doesn't work.
0 new messages