Converting a String to a Seed number!

Pepso

Chieftain
Joined
Aug 4, 2003
Messages
4
This is what I think about the conversion from de String Seed to the Number Seed.

As i discovered there is a formula to transform a string into numbers, although I don’t know if this is 100% accurate.

The formula is just like the conversion from binary to decimal except it uses power’s of 33 instead of 2. I don’t know if I’m making myself clear but instead of having, for example 2^4 it’s 33^4.

When converting from binary to decimal we have for example:
1 0 1 0 0 1 (bin)
5 4 3 2 1 0

as you can see we have 6 digits and we start counting from right to the left, numbering each digit, so the formula to this case will be:
(2^5 * 1) + (2^4 * 0) + (2^3 * 1) + (2^2 * 0) + (2^1 * 0) + (2^0 * 1) = 41 (dec)

The reason I just did that is to show the analogy between one formula and the other.
Now back to civ3, when we want to convert for example the string “Civ”, we must use the following table to convert each string to a number.



  • ------------------------------------------------------------------------------
    String - Number | String - Number | String - Number
    ------------------------------------------------------------------------------
    a - 97 || A - 65 | 0 - 48
    b - 98 || B - 66 | 1 - 49
    c - 99 || C - 67 | 2 - 50
    d - 100 | D - 68 | 3 - 51
    e - 101 | E - 69 | 4 - 52
    f - 102 | F - 70 | 5 - 53
    g - 103 | G - 71 | 6 - 54
    h - 104 | H - 72 | 7 - 55
    i - 105 | I - 73 | 8 - 56
    j - 106 | J - 74 | 9 - 57
    k - 107 | K - 75
    l - 108 | L - 76 | ! - 33
    m - 109 | M - 77
    n - 110 | N - 78
    o - 111 | O - 79
    p - 112 | P - 80
    k - 113 | K - 81
    r - 114 | R - 82
    s - 115 | S - 83
    t - 116 | T - 84
    u - 117 | U - 85
    v - 118 | V - 86
    w - 119 | W - 87
    x - 120 | X - 88
    y - 121 | Y - 89
    z - 122 | Z - 90
    -------------------------------------------------------------------------------
    Note: I will soon update this with rest of the special chars.

Now we start numbering the string:
C i v
2 1 0

C = 67
i = 105
v = 118


the formula will be (33^2 * 67) + (33^1 * 105) + (33^0 * 118) = 76546 (seed number).

One other thing, when we use only numbers as a string the seed number will be the same, example: “289450” = 289450 (seed number), on the other hand the string “Civ3” witch is different from “Civ”(obviously), the char “3” now as a number associated to it (see the table above).

The result will be:
C i v 3
3 2 1 0

C = 67
i = 105
v = 118
3 = 51

the formula will be (33^3 * 67) + (33^2 * 105) + (33^1 * 118) + (33^0 * 51) = 2526069 (seed number).

After spending almost two hours trying to find the logic between this conversion I think I finally discover it. I started some games with the strings “aa”, “ab”, “ac”,”ba”.

  • "aa" = 3298
    "ab" = 3299
    "ac" = 3300
    "ad" = 3301
    "ae" = 3302
    .
    .
    .
    "ba" = 3331
    "bb" = 3332
As you all can see the seed is sequential, after making various types of calculations I reached the point (using the string “ab”) where I tried to subtract the value of the last letter to seed number 3299 - 98 = 3201 , and the result of that I divided by the value of the first letter 3201 / 97 , leading my to the number 33. After that was a matter of time until I figured out that was power’s of 33.

I just hope this explanation hasn’t been confusing, and forgive me about my poor english ;).
 
Top Bottom