Maths issues from 1.24 to 1.39 :'(

BlitzMax Forums/BlitzMax Programming/Maths issues from 1.24 to 1.39 :'(

BlitzProg(Posted 2010) [#1]
[Solved - Post #10 and #11]

Hi there! I've been coding in BlitzMax 1.24 because technical issues prevented me from upgrading further (1.26 made my projects glitch hard and 1.30 couldn't support MaxGui no matter how hard I tried)

I've coded a whole game in Blitzmax 1.24 . It supports a nice replay system that allow you to record yourself so you can watch what you exactly did during your game.

But now I decided to attempt upgrading again and guess what, i'm up to date with version 1.39 without a problem.

This is where the true problem arise, however... My replay system means the code have to be run again with the exact same conditions and results each time. This however isn't possible with the following example:

value=30

a=4
b=1

value=value-  3*(a-b)^2

Print value


Blitzmax 1.39 returns 3. But 1.24 returns 2!

That's because Blitzmax 1.24 finds 27.000000000000004 for 3*(a-b)^2. the final value end up being slightly lower than 3... and truncated to 2. >_<

So my question is: Is there a way for to recode this "mistake" in order to resync my replays?

Thanks for reading. I hope you don't need to reinstall a 1.24 to answer this =(

I hope I was clear.


Czar Flavius(Posted 2010) [#2]
Floats are not guaranteed to be the same between different computers, ever, so using them to store deterministic replays is a bad idea. You should use ints wherever possible and possibly look into an arbitrary precision maths module for when you must use decimals.

I hope you are using Strict!


BlitzProg(Posted 2010) [#3]
It's not a game I plan to sell, I just want to make it accessible. I can't sell, anyway, because it's an accurate remake of a copyrighted game. The lead developper told me it was fine to have it available for free.

If you are curious:
Original game:http://www.youtube.com/watch?v=L737X5lbQ04 (actual game recording)
My remake:http://www.youtube.com/watch?v=UvgOPuB2q4Y (replay data recording)

That's the only game i forgot to use strict... But I always do well without that anyway, after all, I started on Blitz Basic when I was 7 years old and it didn't have a such feature.

---
A first version of the game was released two months ago, and everyone who played it are still waiting for an update. It would be wise to build using BMAX 1.39 but I can't because it would make the replays out of sync. :(


Jesse(Posted 2010) [#4]
why don't you just add the error to the equation:
value=value-  3*((a-b)^2 + 0.000000000000001!)

this should not make a noticeable difference in any computer.

I don't understand why you would want the error in the replay calculations if there is not in your actual game play calculations.


BlitzProg(Posted 2010) [#5]
Quote: "I don't understand why you would want the error in the replay calculations if there is not in your actual game play calculations."

^ It's a question of hard logic, i agree :
the problem is: the replays are built from thoses errors. If Blitzmax 1.39 doesn't get the errors, then, naturally, it won't end up with the same results, ending up generating a different level. ;)

^ adding the error :
I wish it was a constant error :'( Not only it isn't (the error vary from -0.000000000000005 to +0.000000000000005 and i don't have any clue about what makes it vary. worse: I also need to know weither or not BMax 1.24 can still be correct: you get 2 if you started with 30, but you would still get 33 if you started with 60!!!


TaskMaster(Posted 2010) [#6]
Just tell your customers that their old replays are not compatible with the new version of the software.


Corum(Posted 2010) [#7]
Or consider to embed a silent conversion procedure, in order to keep old replays up to date. ;)


xlsior(Posted 2010) [#8]
guess what, i'm up to date with version 1.39 without a problem


...Except the latest version is 1.41. :-?


Czar Flavius(Posted 2010) [#9]
The lead developper told me it was fine to have it available for free.
Is he also a lawyer? You cannot copyright a game mechanic, only a particular implementation of that mechanic (the code) and any artistic works.

In other words, you can make a game with the exact same game mechanics, but just uses your own original artwork (graphics, music, etc) and storyline.

If you are using the graphics etc from the original game, then it most certainly isn't fine. Who cares what the lead developer says, it's what the company which owns the copyright thinks that matters. Have they given you formal written permission to use their artwork? If your program can load and use their artwork, but doesn't come bundled with it itself, (ie a player needs to own the original game and then puts your program only into its folder which then loads the artwork already there) then that might be ok. I'm not too sure about that situation.

On the other hand, if you use your own original artistic content and storyline, go ahead and sell it. Don't let some other guy keep you out of money to reduce the competition.

http://www.out-law.com/page-7896

Disclaimer: I am not a lawyer and I take no responsibility for any consequences of following the above advice.


markcw(Posted 2010) [#10]
Hi GC, nice remake btw!

I suspect your problem is the pow function. I compared blitz_cclib.c with a diff tool (1.24 with 1.40) and it showed only one change (see below). So try copying blitz_cclib.c 1.24 over blitz_cclib.c 1.39 and then from cmd do "bmk makemods -a brl.blitz" and see if that works.

blitz_cclib.diff



BlitzProg(Posted 2010) [#11]
I didn't even realise I could access the pow function from here! I don't want to replace the file with another one that was giving me mistakes though. lol

Instead I just looked at the function and came up with

Function sq124:Double(x)
	If x>0 Return Exp(2*Log(x))
	If x=0 Return 0
	Return Exp(2*Log(-x))
End Function


That return x to the power of 2.

Using it in the code

value=30

a=4
b=1

value=value-  3*sq124(a-b)

print value


I get 2! yay, never been so much happy to get a wrong result :D

I tried in the game and I got it working! My most important replay finally successfully replayed until the end without a problem. Thanks you so much!


---------------


...Except the latest version is 1.41. :-?

Almost up to date then...? sorry, i don't check for updates so often :$

---------------


Is he also a lawyer? You cannot copyright a game mechanic, only a particular implementation of that mechanic (the code) and any artistic works.

In other words, you can make a game with the exact same game mechanics, but just uses your own original artwork (graphics, music, etc) and storyline.

If you are using the graphics etc from the original game, then it most certainly isn't fine. Who cares what the lead developer says, it's what the company which owns the copyright thinks that matters. Have they given you formal written permission to use their artwork? If your program can load and use their artwork, but doesn't come bundled with it itself, (ie a player needs to own the original game and then puts your program only into its folder which then loads the artwork already there) then that might be ok. I'm not too sure about that situation.



I know what's i'm doing.


On the other hand, if you use your own original artistic content and storyline, go ahead and sell it. Don't let some other guy keep you out of money to reduce the competition.



I have no artistic skill, and severely lack imaginative skills. I'm also inefficient at teamworking, so basically, I work alone, spend thousands of hours alone in my projects with absolutly no aim to make any profit out of it. It's called passion. :P


Czar Flavius(Posted 2010) [#12]
Combine passion with profit and there's no going back :)


BlitzProg(Posted 2010) [#13]
If only it was that easy X_X 90% of my creations are private personnal remakes I banned from public releases because it was containing copyrighted content.

the other 10% was released quietly with audio i didn't own as free download to a few internet friends.

Basically this game is the only exeption because it's way more popular than anything I created.


Czar Flavius(Posted 2010) [#14]
Make or hire someone to make new graphics for them and then release your remakes :D