Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 02:52:55 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)[deleted]
Pages: 1 [2] 3
Print
Author Topic: [deleted]  (Read 7902 times)
J. Kyle Pittman
Level 6
*


PostCount++;


View Profile WWW
« Reply #20 on: January 27, 2010, 04:24:22 PM »

The number 0.1 is especially problematic, as its binary representation is non-terminating.  You'll see the same problem on any platform.
Logged

John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #21 on: January 27, 2010, 04:31:04 PM »

Never use == to compare floating point numbers:
http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #22 on: January 27, 2010, 05:48:44 PM »

I found it highly informative to read about how floating point numbers work. It gave me a much better understanding of why rounding errors occur and how to avoid/compensate for them.
Logged

st33d
Guest
« Reply #23 on: January 28, 2010, 01:49:58 AM »

I guess this points out the danger of using the random key method for storing data in memory.

For an int it's fine because you can XOR it. But with a float, unless you can pop it into an integer format inexpensively, you may find the value drifting if you simply add it to a random key to store it in memory and subtract that key to retrieve it.
Logged
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #24 on: January 28, 2010, 02:17:27 AM »

Reverse engineering guys. You can assign whatever score you want in the parts that do that.
Coin grab: unhash points -- points = points + 5 -- hash points;
to
Coin grab: unhash points -- points = points + 500000 -- hash points;

And recording everything is really prohibitive:
Most servers allow your scripts to run for 30 to 60 seconds. Replaying a 15 minute game  (probably takes 10-30 seconds) for 5 consecutive users (If your game has 7000 visits a day, that's like ~5 users per minute)... can lead to trouble.
Well, that is if you don't have a dedicated server that costs you $500 per month.

Using Gauss' normal distribuition (filtering by level number, bullets used, etc) could be useful to determine which scores are widely out of realistic bounds.
On the downside if someone is a really really good player, it will be marked as a hacker.

Regards
Logged

Working on HeliBrawl
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #25 on: January 28, 2010, 06:46:23 AM »

For an int it's fine because you can XOR it. But with a float, unless you can pop it into an integer format inexpensively, you may find the value drifting if you simply add it to a random key to store it in memory and subtract that key to retrieve it.

You can XOR a float by stuffing its raw value into an integer. For example, if you know int is the same size as float on the architecture you're compiling for, you can do this:

Code:
union {int i; float f;} u;

u.f = myFloat;
obfuscatedInt = u.i ^ key;

Or this:

Code:
obfuscatedInt = *((int *) &myFloat) ^ key;

(Of course, this assumes you're writing in C or C++...)
Logged

st33d
Guest
« Reply #26 on: January 28, 2010, 07:14:20 AM »

Yea, even Java allows me to turn a float into a raw int at speed. That's how you can do the Quake 3 inverse square root hack in Java and still get a speed increase.

I tried doing it in Flash and was forced to rout it through the ByteArray class. The result was correct, but so slow as to be utterly worthless.
Logged
raigan
Level 5
*****


View Profile
« Reply #27 on: January 28, 2010, 11:20:26 AM »

I've generally found Flash's Number to be fucking horrendous at even the most basic math. Fucking up simple things such as just removing 0.1 from a value that was an integer to start with.

Are you telling me it's a platform thing?

Yeah, as others have pointed out this is just a fundamental problem with how floats work -- there are some numbers that look normal in decimal that can't be exactly represented in floats (e.g 0.9 turns into 0.89999998). AFAIK this is no different than how the result of (10/3) isn't exactly representable as a decimal (with a finite number of digits anyway).

Here's an online tool I found that lets you see how any given decimal will be represented in single and double-precision floating point: http://babbage.cs.qc.edu/IEEE-754/Decimal.html
Logged
PsySal
Level 8
***


Yaay!


View Profile WWW
« Reply #28 on: January 28, 2010, 12:06:27 PM »

It's easy to understand if you just remember that floats are base 2. So where a decimal number can be thought of as fractions like D[0]/1 + D[1]/10 + D[2]/100 + D[3]/1000, etc. (i.e., the 1's plus the tenths plus the hundredths plus the thousandths...) a float or double is the same but over 2, so it's: B[0]/1 + B[1]/2 + B[2]/4 + D[3]/8 (i.e., the 1's plus the halves plus the quarters plus the eighths and so on.) Or if you prefer it, in binary it's B[0]/1 + B[1]/10 + B[2]/100 + B[3]/1000. In each case remember that B[] is a binary digit at the N-th place to the right of the decimal and D[] is a decimal digit. Ahem.

Then floating point numbers have an exponent which tell you how far to shift them, this is in binary as well.

If you need decimal precision, for example in a financial application, you need to use a "Demical" data type which encodes each digit and performs math *decimally*; this will be (as you might imagine) rather slow but will work as expected: 0.1 + 1.0 = 1.1 every time exactly.
Logged
PsySal
Level 8
***


Yaay!


View Profile WWW
« Reply #29 on: January 28, 2010, 12:09:30 PM »

.... ANND if your confused as to why doing math "decimally" versus "binarily" should be different, remember that you are talking about a representation of a number as either a series of fractions summed together where every denominator is some power of 10, or as a series of binary fractions summed together where every denominator is some power of 2. These are not the same things, and just like 1/3rd cannot be represented finitely this way (i.e., it's 0.333333... which never ends) other numbers that in decimal are quite simple (1/10th, or 0.1) cannot be represented finitely this way.
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #30 on: January 28, 2010, 12:16:54 PM »

lo-fi solutions to this problem:

1) manually check the hi score list yourself and delete scores that are obviously fake; preferably block those ip addresses and usernames so they can't submit scores anymore

2) clear the high score list daily or even hourly, so that the high score is only the highest score of that day. typeracer does this. hackers won't bother if their high score is only going to be up there for a few hours.

3) make the leaderboard only display a list of that player's friends, so it'd be a 'local high score list' for the users that person knows, much like the 'friends' hi score lists on xbox. i actually prefer that because i don't care about some guy in singapore who has 10000000 points, i care whether my pals beat my own score of 40000 points
« Last Edit: January 28, 2010, 12:20:39 PM by Paul Eres » Logged

BrianSlipBit
Level 1
*



View Profile WWW
« Reply #31 on: January 28, 2010, 12:46:57 PM »

3) make the leaderboard only display a list of that player's friends, so it'd be a 'local high score list' for the users that person knows, much like the 'friends' hi score lists on xbox. i actually prefer that because i don't care about some guy in singapore who has 10000000 points, i care whether my pals beat my own score of 40000 points

Which is why (I'd imagine) even most retail games today default to that display mode for their leaderboards, with the option to view global if you want.  Even the big boys are having trouble with this.  Take a look at the top of the global Modern Warfare 2 leaderboards on the PS3 or 360...they're hacked to hell.
Logged

Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #32 on: January 29, 2010, 07:45:43 AM »

3) make the leaderboard only display a list of that player's friends
(...)i don't care about some guy in singapore who has 10000000 points, i care whether my pals beat my own score of 40000 points

This approach is awesome, but only really appliable in social network games (like facebook's).
Logged

Working on HeliBrawl
BrianSlipBit
Level 1
*



View Profile WWW
« Reply #33 on: January 29, 2010, 08:33:04 AM »

3) make the leaderboard only display a list of that player's friends
(...)i don't care about some guy in singapore who has 10000000 points, i care whether my pals beat my own score of 40000 points

This approach is awesome, but only really appliable in social network games (like facebook's).

I disagree.  Let's say the game is not a social site game (i.e. it's stand alone) and you've already got leaderboards coded up - I could be wrong, but I can't imagine coding up some additional (basic) "friend" functionality would be that much more work.  Of course the devil is always in the details, but I think it's certainly doable.
Logged

jotapeh
Level 10
*****


View Profile
« Reply #34 on: January 29, 2010, 08:38:58 AM »

3) make the leaderboard only display a list of that player's friends
(...)i don't care about some guy in singapore who has 10000000 points, i care whether my pals beat my own score of 40000 points

This approach is awesome, but only really appliable in social network games (like facebook's).

I disagree.  Let's say the game is not a social site game (i.e. it's stand alone) and you've already got leaderboards coded up - I could be wrong, but I can't imagine coding up some additional (basic) "friend" functionality would be that much more work.  Of course the devil is always in the details, but I think it's certainly doable.

This assumes that nobody can share names, or if they can, that your users each have unique accounts... a lot of leaderboards are nothing more than a text file with initials or a meaningless name that could change each time the player plays. So it could be quite a bit more work, unless you already have unique user IDs assigned to each player (eg., for a battle.net type of service).. then you could use those IDs to pair up 'friends'.

Still.. it's a good idea! Certainly something I would enjoy seeing.
Logged
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #35 on: January 30, 2010, 04:11:06 AM »

Well, nobody is going to do data-entry just to compare scores with his friends. I know I wouldn't, that's why I said it Smiley

With social networks API, you just get the global unique ids from the friends on your lists (at least in facebook), and do a high-score table with that.

Logged

Working on HeliBrawl
BrianSlipBit
Level 1
*



View Profile WWW
« Reply #36 on: January 30, 2010, 07:03:03 AM »

Well, nobody is going to do data-entry just to compare scores with his friends. I know I wouldn't, that's why I said it Smiley

Audio-Surf says otherwise. Smiley
Logged

Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #37 on: January 31, 2010, 03:08:27 PM »

Not to keep bitching, but all games are not Audio surf.
Would you data-entry all your contacts (assuming from 10 to 50) for each game you play?
Logged

Working on HeliBrawl
BrianSlipBit
Level 1
*



View Profile WWW
« Reply #38 on: January 31, 2010, 03:29:15 PM »

Not to keep bitching, but all games are not Audio surf.
Would you data-entry all your contacts (assuming from 10 to 50) for each game you play?

I wouldn't call it bitching.  It's a valid point.  And as developers, I think it's worth the discussion.  For the right game yes, I'd probably take the time to enter some friend user names.  For anything else, probably not.  So for me, it really just depends on the game itself.

The ideal scenario is having a service like Live with an API that would support a centralized friend mechanism.  That would be cool.
Logged

Rob Lach
Level 10
*****



View Profile WWW
« Reply #39 on: February 01, 2010, 11:54:51 AM »

I already use a stomp stopper class:

Code:
Bunch of Code

The stomp method relies on using a utility like Cheat Engine to modify memory addresses.

You find those memory addresses by searching for a particular value in memory.

But if that value can only be extracted by subtracting a random number from it, that value can never be tracked. The value itself never exists in memory, it has to be combined with the random number to utilise it.

Since we started using this method in conjunction with encypted highscore submission, we stopped seeing ridiculous highscores on our games.

I did something similar once. I made keeping track of the score a floating point number and everytime I changed it I randomly added a number less than 0.0001 or something like that. Then when I reached the point of displaying the score you just cast it as an int and it cuts off the randomly small number past the decimal. You do keep piling on error everytime though.
Logged

Pages: 1 [2] 3
Print
Jump to:  

Theme orange-lt created by panic