Game Logic should use Precision Math

Where applicable in PHP, such as float types, or values that could become float types. Given the dynamic typing of PHP, it would be wise to do so to prevent possible and most likely probable weird ass bugs during and after development. Even with the performance decrease, I would rather know that I covered enough systems that a potential bug won’t cause minor cheating mechanisms to be abused by players.

I remember a while back that there was a floating precision bug in Kingdom of Chaos that would allow for two for the price of one (or something of the lines where the number would ceil instead of floor). Their solution (if I remember correctly) was to floor, but I think if they had used bcmath or one of the others, it would have solved the problems of adding two float type numbers.

One problem with the solution, is that bcmath or any of the others can’t be counted to be installed on all PHP installations. Falling back to built in PHP floating math, is okay, because it might be the only solution that doesn’t involve superior complexity.

Possibly Related Posts:


Tags:

Comments are closed.