swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Heatbugs bug error (simple fix)


From: Catherine Dibble
Subject: Heatbugs bug error (simple fix)
Date: Sun, 04 Oct 1998 11:13:34 -0700

hi folks,

Now that the version dust is settling a bit, here is the simple fix
for the Heatbugs bug error I'd mentioned this spring. Briefly,
the error is that a heatbug that is happy to stay put will *ALWAYS*
move randomly if it can, despite all. This is because it sees its own
cell as occupied and thus tries to move randomly.

I'd mentioned this to Alex at SwarmFest and he promptly patched it
with (beginning at line 188 of Heatbug.m):

if (unhappiness == 0)
{
// only update heat - don't move at all if no unhappiness
[heat addHeat: outputHeat X: x Y: y];
}

This is nice, but the problem applies not only to Heatbugs who are
*perfectly* happy, but also to Heatbugs who are as happy as possible
where they are, even if it isn't bliss. After this fix, heatbugs only try to
move randomly if some some *different* destination cell is occupied --
they stay properly put if they plan to "move" to their current cell.

Here's the full patch -- just add the
(newX != x || newY != y) &&
to the random move test in line 197 of Heatbugs.m, as below:

else
{
tries = 0;
// only do this if we have determined that we really do want to move
while ( (newX != x || newY != y) &&
[world getObjectAtX: newX Y: newY] != nil && tries < 10)
{
newX = (x + [uniformIntRand getIntegerWithMin: -1L withMax: 1L] +
worldXSize) % worldXSize;
newY = (y + [uniformIntRand getIntegerWithMin: -1L withMax: 1L] +
worldYSize) % worldYSize;


tries++; // don't try too hard.
}

If you put one bug in the middle of the landscape and test this fix, you
may still see some peculiar behavior when diffuseConstant > 0.1 or so,
thanks to something going on in the diffusion/update logic (the bugs
will swap back and forth between two horizontal neighbors). This too
needs some detective work to track down in the Heatspace.m
hereIsBetter (I see this with diffuseConstant = 1,
minIdealTemp = maxIdealTemp = 17,000 and
with minOutputHeat = maxOutputHeat = 100).

The moral of this story is to double-check and completely understand
the behavior of our model components before we toss them all into
a model and expect to explain its behavior.

Catherine Dibble
*-----------------------------------------------------------------------*
| Catherine Dibble | |
| Department of Geography | The most exciting phrase to hear in |
| University of California | science, the one that heralds new |
| Santa Barbara, CA 93106 | discoveries, is not "Eureka!" (I found |
| | it!) but "That's funny..." |
| address@hidden | |
| www.econ.ucsb.edu/~cath | -- Isaac Asimov |
*-----------------------------------------------------------------------*
================================== Swarm-Support is for discussion of the technical details of the day to day usage of Swarm. For list administration needs (esp. [un]subscribing), please send a message to <address@hidden> with "help" in the body of the message. ==================================

reply via email to

[Prev in Thread] Current Thread [Next in Thread]