My AI for Sumerian Blood was acting weird on my Android but was working fine on my PC(Windows).
It made things worse that I don’t have debugging tools to directly debug the C++ part of the code on Android.
You need to realize that the code that was acting different on the Android vs the PC is the same code. In matter of fact, the exact same source file on the hard drive is used on both the Android and PC versions.
So what went wrong?
I was using “int abs(int)”, a C function, to calculate the absolute values of a double variable. Well, this seems wrong since you would think you need to use an absolute function that accepts double as a parameter and not int. For instance fabs.
However, if that was the case, I would have the same weird behaviour on the PC as it is on Android.
It turns out that MS have overloads for abs in C++ for convenience. So when I was using abs in my code, in the PC version it was using “double abs(double)”. But in Android this overloading does not exist so it was using “int abs(int)”.
This is an example of how the same identical code can behave different on different platforms.
I ended up converting the abs dealing with doubles into fabs.
(For reference http://msdn.microsoft.com/en-us/library/kw1ee768(v=vs.80).aspx)