What is wrong with my gravity calculations

3 views
Skip to first unread message

Peter Smit

unread,
Feb 3, 2012, 1:48:48 PM2/3/12
to Queue-ICPC
When I play against the standard java player, with the standard map
("java -jar ../coercion/coercion.jar -player syncpipe 2 python bot.py
-player java -cp ../coercion/java_example Migrate"), than the
following locations and velocities are reported for the 6th marker
(index 5)

Turn marker[5].x .y .velo.x .velo.y
0 25.0000 55.0000 0.0000 0.0000
1 24.9894 55.0040 -0.0211 0.0079
2 24.9683 55.0119 -0.0317 0.0119
3 24.9367 55.0237 -0.0422 0.0158
4 24.8945 55.0396 -0.0528 0.0198

That this marker is moving is because of gravity (no collisions). If
I'm correct, the gravity is applied twice before the first turn. Is
this intended behaviour? Also, I believe that with the reported
velocities, the locations should look like this: (new locations, old
velocities)


0 25.0000 55.0000 0.0000 0.0000
1 24.9894 55.0040 -0.0211 0.0079
2 24.9578 55.0159 -0.0317 0.0119

Can someone confirm that I'm on the right track here and that it is a
bug in the software? Or am I doing something wrong?


Thanks in advance,

Peter


----
Just to make sure, marker[5] is in the region defined by
corners=Vector(20.00,40.00,0.00),Vector(40.00,60.00,5.00),Vector(20.00,60.00,-3.00)

Claus Makowka

unread,
Feb 5, 2012, 7:11:15 PM2/5/12
to Queue-ICPC
You appear to be misinterpreting how the simulation works. I had a
similar confusion in the beginning.

Gravity is applied _before_ every turn including turn 0. (See game
rules, subsection Gravity.) The game starts at turn 0.

To be specific, in the information provided at "turn n" has the
current position and the velocity the marker will have for the
upcoming turn, with gravity and friction already applied. So, absent
any collisions, the turn n+1 position will be the turn n position plus
the velocity at turn n.

Pushers are similar, except that there is no friction and the
acceleration you provide as turn n input will be added to the pusher
velocity prior to computing the motion. That is, the position at turn
n+1 will be the position at turn n plus the velocity at turn n plus
the acceleration provided as turn n input. Note that the velocity at
turn n already includes the impulse due to gravity for the turn, just
as for the marker.

Using the -view trace option to generate a file of the engine outputs
and acceleration inputs for the game demonstrates this. From this
file for the default map (the players don't matter, since no
collisions are likely this soon), the marker 5 positions are:
0 25.0000 55.0000 -0.0106 0.0040
1 24.9894 55.0040 -0.0211 0.0079
2 24.9683 55.0119 -0.0317 0.0119
3 24.9367 55.0237 -0.0422 0.0158
4 24.8945 55.0396 -0.0528 0.0198

With the exception of the time 0 velocities, this corresponds exactly
with your values. Not sure why you show a different velocity, unless
your turn 0 output preceded reading the turn 0 marker input.

Having the velocities already updated for the impact of gravity makes
life a little simpler to write the game player (avoids needing to know
the gravity at the current position).

Reply all
Reply to author
Forward
0 new messages