Thread history

From Talk:Main Page
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
08:33, 11 October 2011 Skilgannon (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
17:40, 5 October 2011 Skilgannon (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
16:10, 5 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
07:26, 5 October 2011 Skilgannon (talk | contribs) Comment text edited (<pre> not <code>)
07:21, 5 October 2011 Skilgannon (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
05:04, 5 October 2011 Ultimatebuster (talk | contribs) Comment text edited  
05:04, 5 October 2011 Ultimatebuster (talk | contribs) Comment text edited  
05:03, 5 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
00:39, 5 October 2011 GrubbmGait (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
18:15, 4 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
05:48, 4 October 2011 Voidious (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
04:34, 4 October 2011 Ultimatebuster (talk | contribs) Comment text edited  
04:34, 4 October 2011 Ultimatebuster (talk | contribs) Comment text edited  
04:33, 4 October 2011 Ultimatebuster (talk | contribs) Comment text edited  
04:25, 4 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
03:58, 4 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
03:18, 4 October 2011 Voidious (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
03:03, 4 October 2011 Ultimatebuster (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
00:28, 4 October 2011 Rednaxela (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
00:28, 4 October 2011 Skotty (talk | contribs) New reply created (Reply to Virtual bullet doesn't line up with real bullets)
23:56, 3 October 2011 Ultimatebuster (talk | contribs) New thread created  

Virtual bullet doesn't line up with real bullets

I have a virtual gun that fires a virtual bullet, for some reason it's just slightly off when i actually fire.

MisalignedVirtualBullet.png

What's the proper way to align and fire? I think my timing is just off.

Ultimatebuster23:56, 3 October 2011

I would guess this is the result of the Robocode idiosyncrasy where a bullet is fired before the gun is turned (so if you do setTurnGunRightDegrees(10), setFire(3), execute(), the bullet is fired before the gun is turned right 10 degrees). So your actual aim is probably the aim from the previous turn, while your predicted is from the current turn.

Skotty00:28, 4 October 2011
 

Well... can't really tell without more information what's wrong, but my first guess about what's wrong, is that perhaps you're not accounting for how within a tick, firing happens before gun turning does. The angle you fire at when you call setFire() is the angle resulting from the prior tick's setTurnGun() type call.

Rednaxela00:28, 4 October 2011
 

Yeah that's correct, the setFire is from the last tick.

What's a typical pattern for robocode as to code placement? I'm currently placing the gun turning code in the while true loop and the firing code in onScannedRobot

and it's wrapped with if (getGunHeat() == 0.0)

Should I change that layout? (also add && getGunTurnRemaining() == 0.0 to the fire wrap?)

Ultimatebuster03:03, 4 October 2011
 

Using onScannedRobot or run is totally just a matter of preference - for 1v1 it won't make any difference, really. It could also be an off-by-1 error in the bullet source location - it should be your location on the tick you called setFire. Or your target angle was farther than your gun could move during that tick, in which case the getGunTurnRemaining == 0 check would solve it.

Voidious03:18, 4 October 2011
 

I know if i combined the 2 logics in 1 function, the code would fail (for me at least) Nevermind i figured it out.

(Also Voidious: I'm testing my bot against yours now because it has pretty debugging graphics and I can see my weaknesses :P Also I perform better against your bot (diamond) if i don't fire :P)

Ultimatebuster03:58, 4 October 2011
 

Also, am I suppose to, with my virtual guns, determine the fire direction using last tick's information, since gun turns after bullet fires...

Right now this would f with my simulated hit rate, as sometimes a bullet might hit but not a virtual bullet, or vice versa.

Ultimatebuster04:25, 4 October 2011
 

Yep, you should, though the impact is probably quite minor.

Voidious05:48, 4 October 2011
 

Hm. Even last turn's angle doesn't match with the actual fired one. Idk what's going on, also I think the virtual bullets also hits better..

Anyway to compensate the gun turn after the bullet fire?

Ultimatebuster18:15, 4 October 2011
 

My bullets were not lined up either, until in March this year, I finally solved the problem with GresSuffurd 0.2.28. It turned out that when using the estimated bearing of the next tick (firing tick) position iso the bearing this tick (aiming tick), my real bullets indeed lined up with my (correct) virtual bullets. It gained me 0.2 APS, but I reached spot #11 with slightly misaligned bullets, so it is really not that important. Also keep in mind you have to aim at the opponents next tick position.

GrubbmGait00:39, 5 October 2011
 

Wait i'm not sure if i understand what you mean by the next tick's position. How do I accomplish that?

Here's what I roughly have:

   while (true){
       if (getGunHeat() == 0.0){
           fireVirtualBullet(enemyCurrentAbsoluteBearing); // Just use Head on targeting as an example because it's simple
           fire(2);
       }
   
       turnGunRightRadians(enemyRelativeGunHeading);
   }

I know this would be wrong. I just don't know how to fix it =S

Ultimatebuster05:03, 5 October 2011
 

He means something like:

Point2D.Double myNextLocation = project(myLocation,getVelocity(),getHeadingRadians());
Point2D.Double enemyNextLocation = project(enemyLocation,e.getVelocity(),e.getHeadingRadians());
double nextAbsBearing = absoluteBearing(myNextLocation,enemyNextLocation);

I've tried this, and using it to predict the enemy location didn't help me, although it did help for my own location. I think it depends on the way you define wave hits and starting locations in your gun. In DrussGT I wait until my gun-turn remaining at the beginning of the tick is 0, then fire. I put my bullet on the wave from last tick. As long as you make the same assumptions everywhere it should be ok.

Skilgannon07:21, 5 October 2011
 

Yeah that doesn't help me either, predicting my next location and then aiming via that doesn't make it line up either. I also wait until gun turn is complete.... Still not aligning..

Also, how does bullets collision work? I thought it's a line segment that's between last tick's location and this tick's location (length of the velocity). Whatever the line segment intersect will be collided (other bullet lines or robots)

Ultimatebuster16:10, 5 October 2011

Maybe try staying still while shooting to see if that is the problem? If it still doesn't line up, it is some sort of gun alignment issue.

Skilgannon08:33, 11 October 2011
 

Yes, that is how bullet collisions work. Maybe take your last aim and align the bullet to that? What I do is mark my previous wave as having a bullet the moment setFireBullet() returns a non-null result.

Skilgannon17:40, 5 October 2011