Hi, so I’m trying to implement the “physic engine” of FB, and I think that I’m nearly done, except for one corner case:
- at the end of turn N, two entities are very close to each other, but not touching, so there is no collision. That’s fine. Then rounding takes place.
- at the beginning of turn N + 1, because of the rounding, the two entities are overlapping, so there is an immediate collision at t = 0. And my engine fails to make correct predictions here.
Example: https://www.codingame.com/replay/171812647
At the end of turn 66, wizards 1 and 3 are not colliding but very close.
Indeed they are here before rounding:
1 Point 13839.99 03129.64 Vector +0005.80 +0024.64
3 Point 13872.01 03929.36 Vector -0017.80 +0280.36
Distance between their centers: 800.3594586069449 > 800, so no collision.
Then at the beginning of turn 67, I get in input as expected:
1 Point 13840.00 03130.00 Vector +0004.00 +0018.00
3 Point 13872.00 03929.00 Vector -0013.00 +0210.00
And now the distance between their centers is 799.640544244725 < 800
So there is then an immediate collision at t = 0
Unfortunately my engine, which is doing correct predictions in all other cases, is failing here, and by quite a lot (first line is my prediction, second one CG input of next turn):
1 Point 13989.00 03369.00 Vector +0112.00 +0180.00
1 Point 13981.00 03169.00 Vector +0106.00 +0030.00
3 Point 13852.00 03975.00 Vector -0015.00 +0034.00
3 Point 13860.00 04175.00 Vector -0009.00 +0184.00
I’d like to have some hints on how to handle this corner case, either from CG staff who could look at the referee code, or from players who solved it in their engine, thanks in advance
Note : Magus discouraged me yesterday to handle these collisions at t = 0, and indeed I’m not sure the precision is worth the cost it’s going to induce in terms of performance, but I’d like to evaluate it before deciding to not handle them.