in reply to Perl meets CoreWars
At one point, the launcher decided the game was over before any warrior had taken a turn.
A couple of random suggestions:
Anyway, here's my first attempt at a warrior...
;predecl # hoss1 # if the ratio of enemies warriors to the total num # of warriors is greater # then N, then attack. Otherwise, Spawn. my $ratio = 2 / 3; ;main # Check other warriors my $enemies = JProcRoutines::FindEnemyWarriors; my $all = JProcRoutines::FindWarriors; my $magic_num = (keys %$enemies) / (keys %$all); print "$me : ratio is $magic_num\n"; if ($magic_num > $ratio) { # Pick a random enemy to hit my $rand_enemy = (keys %$enemies)[rand(keys %$enemies)]; # Hit them. &JProcRoutines::Hit($rand_enemy); } else { # Replicate, and if we get an undef back, set up a wait &JProcRoutines::Replicate; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl meets CoreWars
by JPaul (Hermit) on Jan 28, 2002 at 21:00 UTC |