The secret behind Scopely's "random number" generator
Jan 13, 2016 19:34:54 GMT
BossLady and marius like this
Post by jumpingdead on Jan 13, 2016 19:34:54 GMT
Edit on Feb 3 2016: I've since broken the code completely. What is posted below is now outdated, and many assumptions I made in there were wrong (tho the result numbers were right). Please read my other post here: rts-revolt.proboards.com/thread/49/odds-long-time-finally
In the process of working on the code, and from what started as an interest as to why my rolls sucked so hard, I took an interest in not only making a hack, but also understanding the code. They sort of go hand in hand. You cannot effectively get inside the skin of something you don't really understand.
Since Scopely pulled the rug out from under me on the 'More Teams' thing (Way to go Scopely, honestly. About time something the players actually want got added. Try not to nerf it from 10 teams total to 2, ok?), it would be pointless to add that to the hack, I thought I'd look in another direction. Someone had suggested trying to make the drop rate of Survivors better in higher levels. I never thought about it, but it is silly that it's more efficient (and less fun) to farm level 6-something for survivors because the survivor to energy ratio is so much better there.
Ok, so lets start seeing where they are loaded. Looks like the same exact code that is rolled when you do a pull from the store is called. Cool. Lets get under the hood.
So here's what I've found. This is actually the second time I'm writing this, because halfway through I checked out a few hunches and I confirmed a suspicion I had. Without getting into the hardcore details, the character roller is on a curve. It's actually pretty slick how they do it. At first I thought the rolls were completely rigged - for reasons I cannot comprehend, there is a function that appears to generate a random number, and 80% of the code in it is completely worthless and does nothing. The number it returns is based on the input number, and it's changed a bit, while a ton of worthless processing goes on around it. Maybe some other part of the game uses that code. I don't see how, it appears to shuffle meaningless numbers. Anyway.
So the game takes this input number (more on that in a moment) and returns a "result". If the result is higher than the target number, your "reward" number goes down. I won't say better, because some tables seem to have the better items at the top of the chart. Suffice it to say, target number, make "roll", if roll is less, target goes up. If less, target goes up. This happens back and forth a bunch of times until all options are exhausted. The last possible one is your result.
So, in a random drawing of 64 characters, you start on #32. Beat the target number? Halve it. Again. And again. From what I've seen, the big prize character is almost always 0 on the list, and the worst crap is the highest number.
So assuming 50/50 odds, you have to win 6 times in a row. So, about 1.56% chance of getting the big character.
But thats not how it works. Each 'drawing' is, um... backwards. The devs can set your win chances. Remember that 'input number' I mentioned up above? That is set by the drawing type. For example, on a lotto pull for Gary the 9000th new Yellow character to be released, the game can be rigged so that the initial pull is always 90%, a guaranteed failure. Now, the RESULT from that number does change, it drops with each roll (or at least, every time I looked to be sure, it dropped. It may go up too, I just wanted to verify it changed). If it didn't, you'd always either get the highest or lowest reward.
The thing that is, or appears to be, random, is the target number. Not expecting the target number to be the thing that changed so much, I didn't spend a ton of time investigating where it comes from. At least for characters. For mystery bags I'm almost positive I know. I haven't yet looked however.
The result of this is that, at least for character pulls, the lower the target number, the better your result. So I messed with it, a lot.
Glen is currently up right now. There are 64 possible results. The range on the random numbers for this pull appears to be 0-100,000.
If odds were perfectly even, a target of 50,000 SHOULD get you a #32.
However, since it's a curve, it doesnt work that way. A 43,000 (if you divide by 1000, 43%) got reward 49. Way over halfway up the list. But thats ok, it's a curve. Rarity and all that.
I'm running short on time and I have a lot of work to do. I'll get down to the meat of it.
Everyone always says "we want real numbers" and "Hey Jumpingdead, your 1000 pulls is not enough of a sample size, we want the REAL numbers."
Well here it is:
A) Without extensive retries, or at a minimum, spending hours figuring out the math, which is extremely complicated when viewed at the assembly code level, I cannot give a number more exact than "I set the chance at this number, and this is the result I got." So, basically, I cannot say X = 5. What I can say is X is less than or equal to 6. Cool?
B) It's different, or rather, it can be for every event. They tweak one single number, the odds will slip just a tiny bit. It's actually a pretty ingenious system. There's no restriction on some table, and some number ranges. You make a list of target prizes, and move the slider until you like the curve for that list of prizes. I'm impressed enough to steal the idea the next time I need a computerized random list of stuff that can be tweaked ever so slightly.
C) Observing my "target number" or, what I guess must now be called the roll, as this system works backwards, the hopefully randomly generated target number ranged as high as 98,000 as I was testing. 94,000 got me prize # 62. So I'm assuming the range here is 0-100,000. Meaning divide by 1000, thats your percentage chance.
D) This current event example is bullshit. They advertise 2x chances for Epic Glenn and his melee attack, but show a picture of ranged Glenn.
When I set the target to 300, I pulled the advertised Red Glenn.
At 400 I pulled the melee Green Glenn.
At 350 I still got the Green Glenn.
At 525 I got Green glenn.
At 600 I got 5* Lee.
Remember, divide by 1000 to get the percent.
If they mean that RED GLENN is double chances, your DOUBLED chances are less than .35%. If they were being cute and your "double chances" include getting the OTHER Glenn, melee, as an alternative, your chances are at least .525% but less than .6%
There's your real fucking numbers. Not guessing, not conjecture, not from any sample size. Real, actual, confirmed in the code numbers. If I'm feeling really bored later I'll post the actual assembly code and explain whats going on in it. But I gotta get REALLY bored to do that.
(Oh, I got a 4* at 8k and under, but I stopped after I got up to 8,000. It got boring and I have other stuff to do. It's probably around 10% like I reported it was before)
In the process of working on the code, and from what started as an interest as to why my rolls sucked so hard, I took an interest in not only making a hack, but also understanding the code. They sort of go hand in hand. You cannot effectively get inside the skin of something you don't really understand.
Since Scopely pulled the rug out from under me on the 'More Teams' thing (Way to go Scopely, honestly. About time something the players actually want got added. Try not to nerf it from 10 teams total to 2, ok?), it would be pointless to add that to the hack, I thought I'd look in another direction. Someone had suggested trying to make the drop rate of Survivors better in higher levels. I never thought about it, but it is silly that it's more efficient (and less fun) to farm level 6-something for survivors because the survivor to energy ratio is so much better there.
Ok, so lets start seeing where they are loaded. Looks like the same exact code that is rolled when you do a pull from the store is called. Cool. Lets get under the hood.
So here's what I've found. This is actually the second time I'm writing this, because halfway through I checked out a few hunches and I confirmed a suspicion I had. Without getting into the hardcore details, the character roller is on a curve. It's actually pretty slick how they do it. At first I thought the rolls were completely rigged - for reasons I cannot comprehend, there is a function that appears to generate a random number, and 80% of the code in it is completely worthless and does nothing. The number it returns is based on the input number, and it's changed a bit, while a ton of worthless processing goes on around it. Maybe some other part of the game uses that code. I don't see how, it appears to shuffle meaningless numbers. Anyway.
So the game takes this input number (more on that in a moment) and returns a "result". If the result is higher than the target number, your "reward" number goes down. I won't say better, because some tables seem to have the better items at the top of the chart. Suffice it to say, target number, make "roll", if roll is less, target goes up. If less, target goes up. This happens back and forth a bunch of times until all options are exhausted. The last possible one is your result.
So, in a random drawing of 64 characters, you start on #32. Beat the target number? Halve it. Again. And again. From what I've seen, the big prize character is almost always 0 on the list, and the worst crap is the highest number.
So assuming 50/50 odds, you have to win 6 times in a row. So, about 1.56% chance of getting the big character.
But thats not how it works. Each 'drawing' is, um... backwards. The devs can set your win chances. Remember that 'input number' I mentioned up above? That is set by the drawing type. For example, on a lotto pull for Gary the 9000th new Yellow character to be released, the game can be rigged so that the initial pull is always 90%, a guaranteed failure. Now, the RESULT from that number does change, it drops with each roll (or at least, every time I looked to be sure, it dropped. It may go up too, I just wanted to verify it changed). If it didn't, you'd always either get the highest or lowest reward.
The thing that is, or appears to be, random, is the target number. Not expecting the target number to be the thing that changed so much, I didn't spend a ton of time investigating where it comes from. At least for characters. For mystery bags I'm almost positive I know. I haven't yet looked however.
The result of this is that, at least for character pulls, the lower the target number, the better your result. So I messed with it, a lot.
Glen is currently up right now. There are 64 possible results. The range on the random numbers for this pull appears to be 0-100,000.
If odds were perfectly even, a target of 50,000 SHOULD get you a #32.
However, since it's a curve, it doesnt work that way. A 43,000 (if you divide by 1000, 43%) got reward 49. Way over halfway up the list. But thats ok, it's a curve. Rarity and all that.
I'm running short on time and I have a lot of work to do. I'll get down to the meat of it.
Everyone always says "we want real numbers" and "Hey Jumpingdead, your 1000 pulls is not enough of a sample size, we want the REAL numbers."
Well here it is:
A) Without extensive retries, or at a minimum, spending hours figuring out the math, which is extremely complicated when viewed at the assembly code level, I cannot give a number more exact than "I set the chance at this number, and this is the result I got." So, basically, I cannot say X = 5. What I can say is X is less than or equal to 6. Cool?
B) It's different, or rather, it can be for every event. They tweak one single number, the odds will slip just a tiny bit. It's actually a pretty ingenious system. There's no restriction on some table, and some number ranges. You make a list of target prizes, and move the slider until you like the curve for that list of prizes. I'm impressed enough to steal the idea the next time I need a computerized random list of stuff that can be tweaked ever so slightly.
C) Observing my "target number" or, what I guess must now be called the roll, as this system works backwards, the hopefully randomly generated target number ranged as high as 98,000 as I was testing. 94,000 got me prize # 62. So I'm assuming the range here is 0-100,000. Meaning divide by 1000, thats your percentage chance.
D) This current event example is bullshit. They advertise 2x chances for Epic Glenn and his melee attack, but show a picture of ranged Glenn.
When I set the target to 300, I pulled the advertised Red Glenn.
At 400 I pulled the melee Green Glenn.
At 350 I still got the Green Glenn.
At 525 I got Green glenn.
At 600 I got 5* Lee.
Remember, divide by 1000 to get the percent.
If they mean that RED GLENN is double chances, your DOUBLED chances are less than .35%. If they were being cute and your "double chances" include getting the OTHER Glenn, melee, as an alternative, your chances are at least .525% but less than .6%
There's your real fucking numbers. Not guessing, not conjecture, not from any sample size. Real, actual, confirmed in the code numbers. If I'm feeling really bored later I'll post the actual assembly code and explain whats going on in it. But I gotta get REALLY bored to do that.
(Oh, I got a 4* at 8k and under, but I stopped after I got up to 8,000. It got boring and I have other stuff to do. It's probably around 10% like I reported it was before)