After running the following code 100000 times, I found that there is roughly a 17% probability that extra hit wall events will be generated:
public void run()
{
turnLeft(getHeading() - 180);
ahead(Double.POSITIVE_INFINITY);
turnRight(90);
ahead(Double.POSITIVE_INFINITY);
turnRightRadians(Math.random() * Math.PI / 2);
ahead(Double.POSITIVE_INFINITY);
}
public void onHitWall(HitWallEvent e)
{
System.out.println("Hit Wall");
}
The only effect of this problem is the generation of extra hit wall events due to trig rounding issues. Teleporting does NOT result; thus, I don't think this bug needs immediate attention. Also, very few (if any) robots are affected due to the nature of the problem.
The following code, if inserted at line 344, should solve the trig precision issue:
x = (HALF_WIDTH_OFFSET >= x) ? HALF_WIDTH_OFFSET : ((getBattleFieldWidth() - HALF_WIDTH_OFFSET < x) ? getBattleFieldWidth() - HALF_WIDTH_OFFSET : x);
y = (HALF_HEIGHT_OFFSET >= y) ? HALF_HEIGHT_OFFSET : ((getBattleFieldHeight() - HALF_HEIGHT_OFFSET < y) ? getBattleFieldHeight() - HALF_HEIGHT_OFFSET : y);
Logged In: YES
user_id=1653970
Originator: YES
Using a similar test in the upper left corner of a 5000 height battle field, I found that 49% of 100000 tries failed.
Logged In: YES
user_id=1653970
Originator: YES
After figuring out how to download and compile the robocode source files using Eclipse, I experimented with this fix. As far my tests can tell, these two lines eliminate Wall collision problems.
Logged In: YES
user_id=1249353
Originator: NO
This has been fixed in the current 1.2.2 Beta release