A Few Suggestions
The highlighted comment was created in this revision.
I was looking through the code of version 1.2, and I noticed some things you might want to fix in the next version. Here they are:
- I don't think the code in onBulletHit is doing what you think it's doing.
- The
while
loop in the radar code is unnecessary. Also, Double.POSITIVE_INFINITY is a byte cheaper than 1 / 0.
- Infinity Radar is sloppy enough even with setAdjustRadarForGunTurn. If I were you, I would get rid of that and replace it with setAdjustGunForRobotTurn.
- The
Math.min
call in your Energy Management code isn't really necessary.
- Finally, you can assign a new value to
d0
inline in your aiming code to save a byte.
That is some very good codesize saving advice. This nano was based off a relatively poor performing robot in the first place.
The onBulletHit
being wrong is possible, it was just getEnergy last time. However that looked like an error to me, since it was suppose to be detecting enemy energy drops, and I wanted to remove the possibility of
With my compiler, 1/0.0 has the same byte size as Double.POSITIVE_INFINITY.
As for the d0, note my comment "since I use this twice in the following, I am not sure which one is called first, if I figure it out I can shave another byte off". I assume its the most deeply nested one, but I could be wrong.