[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Heatbug.java question
From: |
David Smith |
Subject: |
Re: Heatbug.java question |
Date: |
Wed, 19 Jan 2000 09:59:23 -0700 (MST) |
On 18 Jan 2000, Marcus G. Daniels wrote:
> >>>>> "DS" == David Smith <address@hidden> writes:
>
> DS> OK, here are the diffs:
>
> Ok, the problem is that you've dropped the modulus on bestCell, so
> the coordinates go outside of the Discrete2d boundaries and memory
> dereferences end up being invalid, and a segfault occurs.
>
It seems to me that this uncovers a bug in HeatBug.java source. Here is a
snip from the source in the Swarm CD:
// After choice of ideal spot is made, there's a chance of
// random move. (Note the normalization of coordinates to [0,
// worldSize). The current space library does not enforce
// boundary conditions.)
if ((Globals.env.uniformDblRand.getDoubleWithMin$withMax (0.0, 1.0))
< randomMoveProbability)
{
// pick a random spot
newX =
x + Globals.env.uniformIntRand.getIntegerWithMin$withMax (-1, 1);
newY =
y + Globals.env.uniformIntRand.getIntegerWithMin$withMax (-1, 1);
// normalize coords
newX = (newX + worldXSize) % worldXSize;
newY = (newY + worldYSize) % worldYSize;
}
See where the closing brace is? With it there, the coords never get
normalized unless they were picked up from the random move. I moved the
"}" up above "// normalize coords" and no more crashes.
David Smith
==================================
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.
- Heatbug.java question, David Smith, 2000/01/13
- Re: Heatbug.java question, Marcus G. Daniels, 2000/01/13
- Re: Heatbug.java question, David Smith, 2000/01/13
- Re: Heatbug.java question, Marcus G. Daniels, 2000/01/13
- Re: Heatbug.java question, Benedikt Stefansson, 2000/01/13
- Re: Heatbug.java question, David Smith, 2000/01/13
- Re: Heatbug.java question, Marcus G. Daniels, 2000/01/13
- Re: Heatbug.java question, David Smith, 2000/01/18
- Re: Heatbug.java question, Marcus G. Daniels, 2000/01/18
- Re: Heatbug.java question,
David Smith <=
- Re: Heatbug.java question, Marcus G. Daniels, 2000/01/19