Talk:Darkcanuck/VelocityTest
Contents
Using 1.7.1.3
Scratch that last posted result -- was using the method from 1.7.1.2 Beta by accident. Here's the corrected test result:
Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=3.0 remain=0.0 4 velocity=1.0 remain=-1.0 5 velocity=-0.75 remain=-0.25 6 velocity=-0.25 remain=0.0 7 velocity=0.0 remain=0.0
Still a problem here:
- at tick 3 the bot should have stayed at velocity 2 then decelerated to 1 to hit the target
- the bot then overshoots and takes its time to get on target
- this should have been a 4-tick move...
--Darkcanuck 05:22, 15 July 2009 (UTC)
For another (worse) example of the above, try starting at 0 with a target of 10.
Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=4.0 remain=0.0 5 velocity=2.0 remain=-2.0 6 velocity=0.0 remain=-2.0 7 velocity=-1.0 remain=-1.0 8 velocity=-2.0 remain=1.0 9 velocity=-0.0 remain=1.0 10 velocity=1.0 remain=0.0 11 velocity=0.0 remain=0.0
Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-2.0 remain=1.0 5 velocity=-0.0 remain=1.0 6 velocity=1.0 remain=0.0 7 velocity=0.0 remain=0.0
Starting from an overshoot condition, the velocity formula causes a second, unnecessary overshoot. --Darkcanuck 05:45, 15 July 2009 (UTC)
And here's a sample of what odd negative velocities can produce:
Starting velocity=-1.9 distance=10.0 1 velocity=1.8074999999999999 remain=8.1925 2 velocity=2.8075 remain=5.385000000000001 3 velocity=3.8075 remain=1.5775000000000006 4 velocity=1.8075 remain=-0.22999999999999954 5 velocity=-0.22999999999999954 remain=0.0 6 velocity=0.0 remain=0.0
--Darkcanuck 05:49, 15 July 2009 (UTC)
Voidious Version
Here's the same tests done with the changes made by Voidious:
Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=3.0 remain=0.0 4 velocity=1.0 remain=-1.0 5 velocity=-0.5 remain=-0.5 6 velocity=-0.5 remain=0.0 7 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=0.0 remain=-2.0 3 velocity=-2.0 remain=0.0 4 velocity=-0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.050000000000000044 remain=9.95 2 velocity=1.05 remain=8.899999999999999 3 velocity=2.05 remain=6.849999999999999 4 velocity=3.05 remain=3.799999999999999 5 velocity=2.8999999999999995 remain=0.8999999999999995 6 velocity=0.8999999999999995 remain=0.0 7 velocity=0.0 remain=0.0
That seems to fix all the problems I've found so far, except for the tricky 0,6 case. --Darkcanuck 06:12, 15 July 2009 (UTC)
There's a bug here: in the 4,0 case, how is the bot able to get from velocity 2 to 0 to -2? Surely it should be:
Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=-0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0
--Skilgannon 09:53, 15 July 2009 (UTC)
It was late, and I missed that. =) Here's the newest version's results:
Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=1.5 remain=1.5 4 velocity=1.5 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.050000000000000044 remain=9.95 2 velocity=1.05 remain=8.899999999999999 3 velocity=2.05 remain=6.849999999999999 4 velocity=3.05 remain=3.799999999999999 5 velocity=2.8999999999999995 remain=0.8999999999999995 6 velocity=0.8999999999999995 remain=0.0 7 velocity=0.0 remain=0.0
Looks ok to me, now I have to find some more numbers to break it... --Darkcanuck 15:42, 15 July 2009 (UTC)
Skilgannon Version
And for comparison's sake:
Darkcanuck's VelocityTest Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=2.0 remain=1.0 4 velocity=1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=2.5 remain=1.5 5 velocity=1.5 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=-0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.10000000000000009 remain=9.9 2 velocity=1.1 remain=8.8 3 velocity=2.1 remain=6.700000000000001 4 velocity=3.1 remain=3.600000000000001 5 velocity=2.3500000000000005 remain=1.2500000000000004 6 velocity=1.2500000000000004 remain=0.0 7 velocity=0.0 remain=0.0
A few bugfixes and a 'smooth decel' predictor later... --Skilgannon 08:30, 16 July 2009 (UTC)
Voidious + Positive getMaxVelocity
Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=2.5 remain=0.5 4 velocity=0.5 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=-0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.10000000000000009 remain=9.9 2 velocity=1.1 remain=8.8 3 velocity=2.1 remain=6.700000000000001 4 velocity=3.1 remain=3.600000000000001 5 velocity=2.8000000000000007 remain=0.8000000000000003 6 velocity=0.8000000000000007 remain=-4.440892098500626E-16 7 velocity=-4.440892098500626E-16 remain=0.0
Passes all tests except doesn't account for max velocity yet. The nice thing about this one so far is it's use of round velocity numbers. I like it!
"Hijack" Version (Skilgannon+Positive+Voidious)
Starting velocity=8.0 distance=22.8 1 velocity=8.0 remain=14.8 2 velocity=6.7 remain=8.100000000000001 3 velocity=4.7 remain=3.4000000000000012 4 velocity=2.7000000000000006 remain=0.7000000000000006 5 velocity=0.7000000000000006 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=8.0 distance=22.5 1 velocity=8.0 remain=14.5 2 velocity=6.625 remain=7.875 3 velocity=4.625 remain=3.25 4 velocity=2.625 remain=0.625 5 velocity=0.625 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=8.0 distance=-200.0 max=7.0 1 velocity=6.0 remain=-206.0 2 velocity=4.0 remain=-210.0 3 velocity=2.0 remain=-212.0 4 velocity=-0.0 remain=-212.0 5 velocity=-1.0 remain=-211.0 6 velocity=-2.0 remain=-209.0 7 velocity=-3.0 remain=-206.0 8 velocity=-4.0 remain=-202.0 9 velocity=-5.0 remain=-197.0 10 velocity=-6.0 remain=-191.0 11 velocity=-7.0 remain=-184.0 12 velocity=-7.0 remain=-177.0 13 velocity=-7.0 remain=-170.0 14 velocity=-7.0 remain=-163.0 15 velocity=-7.0 remain=-156.0 16 velocity=-7.0 remain=-149.0 17 velocity=-7.0 remain=-142.0 18 velocity=-7.0 remain=-135.0 19 velocity=-7.0 remain=-128.0 20 velocity=-7.0 remain=-121.0 21 velocity=-7.0 remain=-114.0 22 velocity=-7.0 remain=-107.0 23 velocity=-7.0 remain=-100.0 24 velocity=-7.0 remain=-93.0 25 velocity=-7.0 remain=-86.0 26 velocity=-7.0 remain=-79.0 27 velocity=-7.0 remain=-72.0 28 velocity=-7.0 remain=-65.0 29 velocity=-7.0 remain=-58.0 30 velocity=-7.0 remain=-51.0 31 velocity=-7.0 remain=-44.0 32 velocity=-7.0 remain=-37.0 33 velocity=-7.0 remain=-30.0 34 velocity=-7.0 remain=-23.0 35 velocity=-7.0 remain=-16.0 36 velocity=-7.0 remain=-9.0 37 velocity=-5.0 remain=-4.0 38 velocity=-3.0 remain=-1.0 39 velocity=-1.0 remain=0.0 40 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=2.5 remain=0.5 4 velocity=0.5 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=-0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.10000000000000009 remain=9.9 2 velocity=1.1 remain=8.8 3 velocity=2.1 remain=6.700000000000001 4 velocity=3.1 remain=3.600000000000001 5 velocity=2.8000000000000007 remain=0.8000000000000003 6 velocity=0.8000000000000007 remain=-4.440892098500626E-16 7 velocity=-4.440892098500626E-16 remain=0.0 Starting velocity=0.0 distance=Infinity 1 velocity=1.0 remain=Infinity 2 velocity=2.0 remain=Infinity 3 velocity=3.0 remain=Infinity 4 velocity=4.0 remain=Infinity 5 velocity=5.0 remain=Infinity 6 velocity=6.0 remain=Infinity 7 velocity=7.0 remain=Infinity 8 velocity=8.0 remain=Infinity 9 velocity=8.0 remain=Infinity 10 velocity=8.0 remain=Infinity Starting velocity=0.0 distance=-Infinity 1 velocity=-1.0 remain=-Infinity 2 velocity=-2.0 remain=-Infinity 3 velocity=-3.0 remain=-Infinity 4 velocity=-4.0 remain=-Infinity 5 velocity=-5.0 remain=-Infinity 6 velocity=-6.0 remain=-Infinity 7 velocity=-7.0 remain=-Infinity 8 velocity=-8.0 remain=-Infinity 9 velocity=-8.0 remain=-Infinity 10 velocity=-8.0 remain=-Infinity
Yet another version that passes all my tests so far. Definitely the smallest code, with no iterative routines and mostly understandable. --Darkcanuck 15:22, 16 July 2009 (UTC)
"Hijack-2" with no free accel
Starting velocity=8.0 distance=22.8 1 velocity=8.0 remain=14.8 2 velocity=6.7 remain=8.100000000000001 3 velocity=4.7 remain=3.4000000000000012 4 velocity=2.7000000000000006 remain=0.7000000000000006 5 velocity=0.7000000000000006 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=8.0 distance=22.5 1 velocity=8.0 remain=14.5 2 velocity=6.625 remain=7.875 3 velocity=4.625 remain=3.25 4 velocity=2.625 remain=0.625 5 velocity=0.625 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=8.0 distance=-200.0 max=7.0 1 velocity=6.0 remain=-206.0 2 velocity=4.0 remain=-210.0 3 velocity=2.0 remain=-212.0 4 velocity=-0.0 remain=-212.0 5 velocity=-1.0 remain=-211.0 6 velocity=-2.0 remain=-209.0 7 velocity=-3.0 remain=-206.0 8 velocity=-4.0 remain=-202.0 9 velocity=-5.0 remain=-197.0 10 velocity=-6.0 remain=-191.0 11 velocity=-7.0 remain=-184.0 12 velocity=-7.0 remain=-177.0 13 velocity=-7.0 remain=-170.0 14 velocity=-7.0 remain=-163.0 15 velocity=-7.0 remain=-156.0 16 velocity=-7.0 remain=-149.0 17 velocity=-7.0 remain=-142.0 18 velocity=-7.0 remain=-135.0 19 velocity=-7.0 remain=-128.0 20 velocity=-7.0 remain=-121.0 21 velocity=-7.0 remain=-114.0 22 velocity=-7.0 remain=-107.0 23 velocity=-7.0 remain=-100.0 24 velocity=-7.0 remain=-93.0 25 velocity=-7.0 remain=-86.0 26 velocity=-7.0 remain=-79.0 27 velocity=-7.0 remain=-72.0 28 velocity=-7.0 remain=-65.0 29 velocity=-7.0 remain=-58.0 30 velocity=-7.0 remain=-51.0 31 velocity=-7.0 remain=-44.0 32 velocity=-7.0 remain=-37.0 33 velocity=-7.0 remain=-30.0 34 velocity=-7.0 remain=-23.0 35 velocity=-7.0 remain=-16.0 36 velocity=-7.0 remain=-9.0 37 velocity=-5.0 remain=-4.0 38 velocity=-3.0 remain=-1.0 39 velocity=-1.0 remain=0.0 40 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=2.5 remain=0.5 4 velocity=0.5 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=-0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.050000000000000044 remain=9.95 2 velocity=1.05 remain=8.899999999999999 3 velocity=2.05 remain=6.849999999999999 4 velocity=3.05 remain=3.799999999999999 5 velocity=2.8999999999999995 remain=0.8999999999999995 6 velocity=0.8999999999999995 remain=0.0 7 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=19.9 1 velocity=1.0 remain=18.9 2 velocity=2.0 remain=16.9 3 velocity=3.0 remain=13.899999999999999 4 velocity=4.0 remain=9.899999999999999 5 velocity=5.0 remain=4.899999999999999 6 velocity=3.4499999999999993 remain=1.4499999999999993 7 velocity=1.4499999999999993 remain=0.0 8 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=Infinity 1 velocity=1.0 remain=Infinity 2 velocity=2.0 remain=Infinity 3 velocity=3.0 remain=Infinity 4 velocity=4.0 remain=Infinity 5 velocity=5.0 remain=Infinity 6 velocity=6.0 remain=Infinity 7 velocity=7.0 remain=Infinity 8 velocity=8.0 remain=Infinity 9 velocity=8.0 remain=Infinity 10 velocity=8.0 remain=Infinity Starting velocity=0.0 distance=-Infinity 1 velocity=-1.0 remain=-Infinity 2 velocity=-2.0 remain=-Infinity 3 velocity=-3.0 remain=-Infinity 4 velocity=-4.0 remain=-Infinity 5 velocity=-5.0 remain=-Infinity 6 velocity=-6.0 remain=-Infinity 7 velocity=-7.0 remain=-Infinity 8 velocity=-8.0 remain=-Infinity 9 velocity=-8.0 remain=-Infinity 10 velocity=-8.0 remain=-Infinity
--Darkcanuck 16:02, 16 July 2009 (UTC)
Original (1.6.1.4)
For comparison purposes, I mashed the 1.6.1.4 code into a similar getNewVelocity() function and ran the same tests. All passed except for the three caveats raised by Simonton plus the case that Voidious mentioned (0, 19.9) due to taking an extra tick:
Starting velocity=8.0 distance=22.8 1 velocity=8.0 remain=14.8 2 velocity=6.0 remain=8.8 3 velocity=5.0 remain=3.8000000000000007 4 velocity=3.0 remain=0.8000000000000007 5 velocity=1.0 remain=-0.1999999999999993 6 velocity=-0.1999999999999993 remain=0.0 7 velocity=0.0 remain=0.0 FAIL Starting velocity=8.0 distance=22.5 1 velocity=8.0 remain=14.5 2 velocity=6.0 remain=8.5 3 velocity=4.0 remain=4.5 4 velocity=3.0 remain=1.5 5 velocity=1.0 remain=0.5 6 velocity=0.5 remain=0.0 7 velocity=0.0 remain=0.0 FAIL Starting velocity=8.0 distance=-200.0 max=7.0 1 velocity=7.0 remain=-207.0 2 velocity=5.0 remain=-212.0 3 velocity=3.0 remain=-215.0 4 velocity=1.0 remain=-216.0 5 velocity=-1.0 remain=-215.0 6 velocity=-2.0 remain=-213.0 7 velocity=-3.0 remain=-210.0 8 velocity=-4.0 remain=-206.0 9 velocity=-5.0 remain=-201.0 10 velocity=-6.0 remain=-195.0 11 velocity=-7.0 remain=-188.0 12 velocity=-7.0 remain=-181.0 13 velocity=-7.0 remain=-174.0 14 velocity=-7.0 remain=-167.0 15 velocity=-7.0 remain=-160.0 16 velocity=-7.0 remain=-153.0 17 velocity=-7.0 remain=-146.0 18 velocity=-7.0 remain=-139.0 19 velocity=-7.0 remain=-132.0 20 velocity=-7.0 remain=-125.0 21 velocity=-7.0 remain=-118.0 22 velocity=-7.0 remain=-111.0 23 velocity=-7.0 remain=-104.0 24 velocity=-7.0 remain=-97.0 25 velocity=-7.0 remain=-90.0 26 velocity=-7.0 remain=-83.0 27 velocity=-7.0 remain=-76.0 28 velocity=-7.0 remain=-69.0 29 velocity=-7.0 remain=-62.0 30 velocity=-7.0 remain=-55.0 31 velocity=-7.0 remain=-48.0 32 velocity=-7.0 remain=-41.0 33 velocity=-7.0 remain=-34.0 34 velocity=-7.0 remain=-27.0 35 velocity=-7.0 remain=-20.0 36 velocity=-7.0 remain=-13.0 37 velocity=-6.0 remain=-7.0 38 velocity=-4.0 remain=-3.0 39 velocity=-2.0 remain=-1.0 40 velocity=-1.0 remain=0.0 41 velocity=0.0 remain=0.0 FAIL Starting velocity=0.0 distance=6.0 1 velocity=1.0 remain=5.0 2 velocity=2.0 remain=3.0 3 velocity=2.0 remain=1.0 4 velocity=1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=10.0 1 velocity=1.0 remain=9.0 2 velocity=2.0 remain=7.0 3 velocity=3.0 remain=4.0 4 velocity=3.0 remain=1.0 5 velocity=1.0 remain=0.0 6 velocity=0.0 remain=0.0 Starting velocity=4.0 distance=0.0 1 velocity=2.0 remain=-2.0 2 velocity=0.0 remain=-2.0 3 velocity=-1.0 remain=-1.0 4 velocity=-1.0 remain=0.0 5 velocity=0.0 remain=0.0 Starting velocity=-1.9 distance=10.0 1 velocity=0.10000000000000009 remain=9.9 2 velocity=1.1 remain=8.8 3 velocity=2.1 remain=6.700000000000001 4 velocity=3.1 remain=3.600000000000001 5 velocity=2.0 remain=1.600000000000001 6 velocity=1.600000000000001 remain=0.0 7 velocity=0.0 remain=0.0 Starting velocity=0.0 distance=19.9 1 velocity=1.0 remain=18.9 2 velocity=2.0 remain=16.9 3 velocity=3.0 remain=13.899999999999999 4 velocity=4.0 remain=9.899999999999999 5 velocity=5.0 remain=4.899999999999999 6 velocity=3.0 remain=1.8999999999999986 7 velocity=1.0 remain=0.8999999999999986 8 velocity=0.8999999999999986 remain=0.0 9 velocity=0.0 remain=0.0 FAIL Starting velocity=0.0 distance=Infinity 1 velocity=1.0 remain=Infinity 2 velocity=2.0 remain=Infinity 3 velocity=3.0 remain=Infinity 4 velocity=4.0 remain=Infinity 5 velocity=5.0 remain=Infinity 6 velocity=6.0 remain=Infinity 7 velocity=7.0 remain=Infinity 8 velocity=8.0 remain=Infinity 9 velocity=8.0 remain=Infinity 10 velocity=8.0 remain=Infinity Starting velocity=0.0 distance=-Infinity 1 velocity=-1.0 remain=-Infinity 2 velocity=-2.0 remain=-Infinity 3 velocity=-3.0 remain=-Infinity 4 velocity=-4.0 remain=-Infinity 5 velocity=-5.0 remain=-Infinity 6 velocity=-6.0 remain=-Infinity 7 velocity=-7.0 remain=-Infinity 8 velocity=-8.0 remain=-Infinity 9 velocity=-8.0 remain=-Infinity 10 velocity=-8.0 remain=-Infinity
--Darkcanuck 22:55, 16 July 2009 (UTC)
- [View source↑]
- [History↑]