This involves some encoding/decoding schemes.
//fires at random double bearingOffset = Math.signum(e.getVelocity()) * (Math.random() * 10 - 2) / 11.0 * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing); setTurnGunRightRadians(Utils.normalRelativeAngle(enemyAbsoluteBearing - getGunHeadingRadians() + bearingOffset)); setFire(2 + bearingOffset); .. public void onBulletHit(BulletHitEvent e) { double visitedBearingOffset = e.getBullet().getPower() - 2; out.println("hit: " + visitedBearingOffset); }I once encoded bearingOffset like this:
setFire(bearingOffset * 100);But it varied BulletTravelTime. You can encode informations whatever you want like this way. e.g. using truncation, fraction digit range x-y is velocity, x2-y2 is heading, etc. Tricky!! Hahaha! But after some test, this method is proved unuseful by me at the moment. This is sort of ActualBullets? (contrary to VirtualBullets) and slow learing.
You can minimize side effects by reducing magnitude of the data. For example, instead of
setFire(2 + bearingOffset);,
setFire(2 + bearingOffset / 100);And when retrieving,
visitedBearingOffset = (e.getBullet().getPower() - 2) * 100;
-- Stelokim
That would limit you to about 30 or so angles, as bullet power is stored as a number with a single decimal place between 0.1 and 3. --Chase-san
Not really. Bullet power has not only a single decimal place. Its minimum is 0.1 but it has type double
's precision. Also check out MaxEscapeAngle. And use divisor 1000, 10000, or 100000, etc. No hard limit!! -- Stelokim
Then why don't you start with an integer and use binary to store all the data you need into it, and then cast it toa double and set it as below the decil line. such that if it was 65535, you do (double)65535/1000000d = 0.065535, then you can still have your power management. Look in FoldedPatternMatcher for implimentation (it turns it into a symbol). You can look [here] for more information on bitwise operators. --Chase-san
Thank you for good information. -- Stelokim