minj / foxtrick

FoxTrick is a browser extension for the Hattrick online football manager game, currently available for Firefox, Google Chrome, as well as for Opera.
https://www.foxtrick.org
GNU General Public License v3.0
69 stars 48 forks source link

[math.js] Fix Predict.stamina for players at exactly 8.00 stamina #1719

Closed dominiquelee closed 7 months ago

dominiquelee commented 7 months ago

Players at exactly stamina 8.00 (that is, 33 y.o. players) are well-known to be displayed as having 7.98 stamina in MatchLineupTweaks, despite having a visible 8 stamina in Hattrick. Tweaking the formula impacts players at 8.00 stamina and those slightly above. For instance, energyAt90 === 0.88699 are upgraded from a computed stamina of 7.9989 to 8.0111, which may or may not be correct, but at least is in 8+ territory. It should also be noted that the formula change does not try to keep the function continuous at its breakpoint, as Foxtrick.Predict.stamina(0.88499) now returns 7.978677159, while it most likely should be way closer to 8.00.

minj commented 7 months ago

could you provide a link to some sort of discussion related to this?

dominiquelee commented 7 months ago

It's not too satisfying, but here's someone talking about it in the forums: https://www.hattrick.org/goto.ashx?path=/Forum/Read.aspx?t=17552577&v=0&a=1&n=7 Also, you can check this player recent history: https://www.hattrick.org/goto.ashx?path=/Club/Players/PlayerStats.aspx?PlayerID=440531865 - clearly, Hattrick reported him at stamina 8 since he's 33, but if you look at the matches, Foxtrick reports 7.98 every time. Just to be clear, I'm not pretending that the updated formula is more correct than the legacy one. But I do believe it makes more sense near 8.00.

Finally, debugging that player, to show the 0.885 value: image

minj commented 7 months ago

I get the problem now but I am not sure the solution is to change the formula cut off only. This was based on a study whose details I do not recall any more but having it continuous makes sense.

We have always displayed 8.63+ for energy=1 until now, and the new cut off change the evaluation to 8.64. Do you know if it is possible to adjust the 2 linear functions to meet at 0.885 but still give more or less the same values rounded to 2 decimals that we had before, except around 8?

Trying to have more precision than that is too ambitious anyway imho

dominiquelee commented 7 months ago

Ah, indeed, that's not ideal. I'm not good enough at maths to get a somewhat matching formula (that ideally would also align the 34yo and 35yo values), but maybe we could do something like

energyAt90 < 0.885 --> legacy formula 0.885 <= energyAt90 < 0.887 --> 8.00 0.887 <= energyAt90 --> legacy formula

0.885 to 0.887 would all appear as the same actual 8 stamina and we'd have a small jump at 0.888 (stamina 8.0056), but maybe that's good enough.

minj commented 7 months ago

yeah, why not... could you please add [post=17552577.7] as a comment as well?

minj commented 7 months ago

Thank you