Post news Report RSS Switching to Integers

Recently I have switched 2aw's simulation to pure integer maths. This makes math computation the same on all platforms. It does not matter how the compiler orders floating point instructions, the integer ones always follow same order and produce the same result. It would not even matter which CPU architecture it's running on, whether it be x86, x64, PPC, A4 or some other breed.

Posted by on

Recently I have switched 2aw's simulation to pure integer maths. This makes math computation the same on all platforms. It does not matter how the compiler orders floating point instructions, the integer ones always follow same order and produce the same result. It would not even matter which CPU architecture it's running on, whether it be x86, x64, PPC, A4 or some other breed.

https://media.indiedb.com/images/articles/1/57/56683/auto/mainframe.png

Syncing was a huge road block that is now behind us. We are now playing the actual game, not the game of finding more and more de-syncs. The integer maths allows me to conquer the sync problems once and for all and be 100% sure that sync problems are not caused by a floating point error. This allows me to go and fix the real problem.

https://media.indiedb.com/images/articles/1/57/56683/auto/grid.png

The first thing I had to switch was the grid coordinates. Before, the game used 1km scale. So I get distances such as 1.345km, 67.794km, 0.345km. I had to convert all of that to a meter scale. So distances became 1345m, 67794m, 345m. With the integer system ships cant occupy a half meter but that is okay because most ships are 20m to 2000m in length.

https://media.indiedb.com/images/articles/1/57/56683/auto/abacus.png

But still in some places such as angles I needed smaller numbers. There I am using fixpoint math. Fixed point math is integers with a scale. So if I use 1000 scaling - 1 becomes 1000 and 2 becomes 2000 and .3 becomes 300 and .007 becomes just 7. I have to be carefull were I multiply and divide to scale back the number. So 1000*1000 = 1,000,000 but I need to scale it back once by my scale 1/1000th so I get 1000 back. 1000 with 1000scale is 1.000 - and that is correct 1.000 * 1.000 = 1.000. I actually did not use "1000" as scale but "1024." The reason I used 1024 is because its very fast to divide by that number in binary. To divide "100101011010100111" by a 1024 on just has to shift it by 10 spaces yielding "10010101."

Post comment Comments
ogikarma
ogikarma - - 14 comments

I have no idea what you just said but it sounded really cool.

Just kidding, awesome stuff.

Reply Good karma Bad karma+2 votes
Elementalist
Elementalist - - 732 comments

Haha, I love the use of the Abacus. xD Good stuff, glad to see you're making progress. Besides the movement part which really isn't a con due to the size of the ships as you said, do you think you'll find any issues from switching to integers?

Reply Good karma Bad karma+1 vote
Su[)az][mA
Su[)az][mA - - 364 comments

as of yet no :)

Reply Good karma Bad karma+1 vote
dsi1
dsi1 - - 157 comments

My avatar feels very fitting right now...

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: