Example client: Try fixing erratic movement

This commit is contained in:
Petr Baudis 2011-12-09 14:52:28 +01:00
parent 23f2fce7ff
commit 452c4a0744

View file

@ -80,7 +80,7 @@ sub take_action($%) {
[0, -2], [1, -2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2], [1, 2], [0, 2], [-1, 2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2], [-1, -2], [0, -2], [1, -2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2], [1, 2], [0, 2], [-1, 2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2], [-1, -2],
); );
my $max = $dirs[1]; my $max = $dirs[0];
# Default direction in case of nothing interesting in the vicinity # Default direction in case of nothing interesting in the vicinity
# is [1, -1]. # is [1, -1].
@ -116,7 +116,7 @@ sub take_action($%) {
} }
} }
print "moves ".join(", ", @move)." => ($max->[0],$max->[1])\n"; print "moves ".join(", ", @move)." => (".dirindex($max).":$max->[0],$max->[1])\n";
if ($attack[dirindex($max)]) { if ($attack[dirindex($max)]) {
print $socket "attack_dir $max->[0] $max->[1]\r\n"; print $socket "attack_dir $max->[0] $max->[1]\r\n";