Project FAQ
How is the distance calculated?
Suppose the robot is on (4,4) and the flag is on (1,2), then the distance
is abs(4 - 1) + abs(4 - 2) = 5. Apparently this was confusing,
sorry about that; other interpretations also make sense, but we must agree
on one so that our implementation will work together, so this is the
definition we will use.
Should I ever use Thread.stop()?
No, you should never use this method. Nor should you use
Thread.suspend() or Thread.resume(); all of these methods
have been deprecated by Sun and they are not thread-safe.
What order should the coordinates be: (x,y) or (y,x)?
This is rather unfortunate, but when I created the m_maze
matrix, I designated the first index as row (which is y)
and the second index as column (which is x); this is
because I visualize arrays in my head vertically. As a result of this
decision, you must access m_maze as (y,x), but everywhere
else in the program you should use (x,y). If this bothers you, feel
free to swap all m_maze coordinates in the existing code to
make it consistent.
(15.01.2002)
What happens if two robots build a bridge on the same cell?
In this case, the last built bridge will win, which means that the
first robot's bridge will be overwritten, unless the first robot
has already moved onto the cell. In this case, the second
createBridge() will throw an exception because it is not
possible to build a bridge over a robot.
(15.01.2002)
Does each robot have a bridge counter?
No. The games starts with INITIAL_BRIDGE_COUNT initial bridges
total for all robots. Any robot can use these bridges, but when the initial
bridges are used, then every robot will be penalized
BRIDGE_DELAY_FACTOR milliseconds.
(14.01.2002)
Should I use sleep() for the bridge delay factor?
No. (It is possible to use sleep(), but you should not!)
You can, however, use sleep() for the move delay factor, but be
careful where you use it.
(14.01.2002)
How do I access m_occupant in Cell?
You should add a method (e.g., setOccupant(Robot r)) that is used to
set the m_occupant value; I forgot to add this method when I created
the starter kit. You do not need a getOccupant() method.
(14.01.2002)
How do I get the positions of the robots?
The robots' homes are defined in WorldActivatorService.startGame();
the homes are the initial positions of the individual robots. If you want to
keep track of the robots' positions you will likely need to record these
"initial" positions from within startGame(), perhaps using an array
or something similar, and then update these locations as the robots move.
(14.01.2002)
How do I start more than one robot at a time?
The component framework only allows one component from one URL, so in order
to load more than one robot you need to use different URLs. The simplest
way to do this is to make a copy of your robot.jar file and give it a
different name, such as robot2.jar. After this, you should be able to load
both robot.jar and robot2.jar by specifying the appropriate URL for each.
(14.01.2002)