so at the risk of being called a grave digger xD i'm putting here the new approch that jumped to my mind when i was porting the code to the SVN version
------------------ old approch
for the previous version i talked about "accuracy pilotated bisection"
which at every iteration halves the interval discarding the sensitivity which had the worst accuracy
this in 6 steps led to reducing the length of the original interval to 1/64 of it
which is enough accurate for the purpose, the problem was that this approach required extensively trying steps*3 sensitivityes, in this case 18 different sensitivityes
it took approximately 30 minutes to finish all the procedure. plus the final value was subject to error introduced by progressively adapting to the tested sensitivityes
--------------------------- new approch
i best fit a parabola (y=x*x*c2+x*c1+c0) using Least Squares Minimization (for more info read note 1) to this 4 points:
X Y
s*(1-h) accuracy_0
s*(1-h/3) accuracy_1
s*(1+h/3) accuracy_2
s*(1+h) accuracy_3
with:
s = starting sensitivity
h = 0.6
X = sensitivityes
Y = corresponding accuracyes
doing this i obtain a function that near to the given points approximates the player accuracy curve under different sensitivityes
then to get the actual final sensitivity value
i just have to find the parabola vertex (actually only the X coordinate of it) and make sure that c2 is less than 0 ( so that the vertex is the highest point and not the lowest)
if c2>0 no solution is given, in this case the convergence failed and most probably the reason is that you started from a value that was too far from your optimun
all this can be simplified to this:
denom=15.0*(acc[3]-acc[2]-acc[1]+acc[0])
vertex=S*(denom-(6.0*acc[3]+2.0*acc[2]-2.0*acc[1]-6.0*acc[0])*h)/denom
if(denom<0) sensitivity=vertex
(S = starting senstivity value)
the difference is that this new approch requires only trying 4 sensitivityes instead of 18 (~30 minutes compared to ~5 minutes)
it hasnt got the problem that the player progressively adapts to the testing sensitivityes (you only try 4 different values none of which is your original sensitivity)
plus it's many times more accurate since the (approximate) solution is achieved by finding the maximun of the approximated player accuracy curve
note 1:
The method of least squares is a standard approach to the approximate solution of overdetermined systems, i.e., sets of equations in which there are more equations than unknowns. "Least squares" means that the overall solution minimizes the sum of the squares of the errors made in solving every single equation. (Wikipedia)
Complete method derivation and source code here:
http://forum.cubers.net/thread-3814-post...l#pid69347