  Wc3C.net [SNIPPET] PseudoRandom_Index
 User Name Remember Me? Password
 Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar  12-14-2011, 08:00 AM #16 Bribe User   Join Date: Mar 2010 Posts: 233 Submissions (1)   It just makes the game not able to be reloaded? I thought it was something more obscure and harder to detect. Ok, that's easy enough to test. I will do that tonight (German time).   12-14-2011, 06:03 PM   #17
master of fugue

Join Date: Jun 2007
Posts: 2,453

Submissions (5)      Quote:
 Originally Posted by tamisrah I would totally prefer a small tutorial on how to create those functions over this snippet. xD

Ok lets start with circular modulo groups.
For this to work we need a base 2 size.
Let us pick 2^3 = 8 as base size for our example.

We need to create a circular pseudorandom function for numbers: 0 1 2 3 4 5 6 7
First index (seed) is always 1.
We need a multiplicator M and addition factor A
Our function always looks like this: seed = (seed * M + A) mod B
Let us try M == 3 and A == 1
seed = 1
seed = 1*3 + 1 = 4
seed = 4*3 + 1 = 13 // we got a number over 8 so we do 13 mod 8 = 5
seed = 5*3 + 1 = 16 // 16 mod 8 = 0
seed = 0*3 + 1 = 1

We have reached 1 and completed our circle.
But it is not a full circle because we only got indexes: 1 4 5 0 (half circle)
We can never create indexes 2 3 6 7 with this function, it is not good.

We need to experiment a little more.
Lets try M == 5 and A == 1
seed = 1
seed = 1*5 + 1 = 6
seed = 6*5 + 1 = 31 -> 7 // remember the modulo 8
seed = 7*5 + 1 = 36 -> 4
seed = 4*5 + 1 = 21 -> 5
seed = 5*5 + 1 = 26 -> 2
seed = 2*5 + 1 = 11 -> 3
seed = 3*5 + 1 = 16 -> 0
seed = 0*5 + 1 = 1

Yeah we got full circle.

Things to remember:
B - Base should be power of 2. (2 4 8 16 32 64 128 ...)
M - Multiplicator should be odd number. (1 3 5 7 9.....)
A - Addition factor should be odd number. (1 3 5 7 9.....)

You always start with seed 1 and test until you go back to seed 1.
function always looks like this: seed = (seed * M + A) mod B
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c. Last edited by cohadar : 12-14-2011 at 06:03 PM.   Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off

All times are GMT. The time now is 03:05 AM.

 -- Night Elf -- Tauren -- Troll -- Pandaren -- Underworld -- Blood Elf -- Northrend -- Lightning ---- Light-ning -- Arcane -- Diablo III -- Protoss -- Mobile Version Wc3campaigns - Archive - Top 