swarm-support
[Top][All Lists]
Advanced

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

Heatbug.java question


From: David Smith
Subject: Heatbug.java question
Date: Thu, 13 Jan 2000 12:15:34 -0700 (MST)

I am studying the jheatbugs-2.0.1 implementation to learn how the Java/Swarm 
code works. I have found the following piece of the Heatbug.java file very 
puzzling:
**********************************************************************
    // now ask the heatspace to tell us where the warmest or
    // coldest spot is The method call returns values back into
    // newX and newY.
        
    newX = x;
    newY = y;
    {
      HeatCell heatCell = new HeatCell (newX, newY);
          
      heat.findExtremeType$X$Y (((heatHere < idealTemperature)
                                 ? HeatSpace.hot
                                 : HeatSpace.cold),
                                heatCell);
      newX = heatCell.x;
      newY = heatCell.y;
    }
**********************************************************************

I have several qestions on how this works. 

First, the block enclosed by 
the {} doesn't belong to any function or operation. 

Second, the HeatSpace method findExtremeType$X$Y() is supposed to return 
a long value, but nothing is assigned that value within the block. 

Third, What do HeatSpace.hot and HeatSpace.cold do without at least an 
empty set of parameter ()'s following. I can't find a void function hot 
or cold in the HeatSpace class definition. According to convention, the 
way to get the value of hot or cold should be something like getHot and 
getCold. 

Fourth, Same question about heatCell.x and heatCell.y. HeatCell class has 
no x or y method either. It appears that it maybe supposed to assign the 
heatCell's x and y values to newX and newY. But even if it does that, the 
whole ghostly function doesn't do anything anyway. Just before the block 
begins, newX and newY are set to x and y, and nothing within the block 
changes the x and y of the heatCell newly-created with the same values.

So I don't see how this piece of code works. Could it be that it doesn't 
do anything because it isn't attached to anything? 

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.



reply via email to

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