I think my problem with warriors not getting a
"turn" may have had to do with having
$JProcRoutines::MaxProcs set too low ...
i bumped it up to 20, and now it works great.
We can rebuild him, stronger, faster, better...
;predecl
# hoss2
#
# if there are less then $bromin brothers, spawn.
# else: if pid is even, attack
# if pid is odd, spawn
#
# only check our brother list periodicly to save time
# use a wait counter if spawning was prevously unsuccesful
#
my $brothers = undef;
my $bromin = 10;
my $browait = 0;
my $spawnwait = -1;
#
;main
#
if ($browait <= 0) {
$brothers = &JProcRoutines::FindBrotherWarriors();
$browait = 5;
}
if ( (0 > $spawnwait)
and
((scalar(keys %$brothers) < $bromin)
or
($$ % 2 == 1))
) {
# spawn
if ( ! defined &JProcRoutines::Replicate()) {
$spawnwait = 5;
}
} else {
# attack!
my $warriors = &JProcRoutines::FindEnemyWarriors();
if (keys %$warriors > 0) {
# Pick a random enemy to hit
my $rand_enemy = (keys %$warriors)[rand(keys %$warriors)];
# Hit them.
&JProcRoutines::Hit($rand_enemy);
}
}
# cycle counters...
$spawnwait--;
$browait--;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.