[Col] Decoding Colonization SAV files (1994 / Old / Classic)

I think that's a reasonable idea. At first I thought they should be made Petty Criminals so you would have to spend resources to educate them rather than (if you're lucky) just sending them as Indentured Servants to the Indian capital nearby. But the optics of that! "Improving" the Indians by literally turning them into criminals is a very bad look. Maybe it should be indentured servants.

Edit: Or maybe the script should offer the option?
 
Last edited:
I think that's a reasonable idea. At first I thought they should be made Petty Criminals so you would have to spend resources to educate them rather than (if you're lucky) just sending them as Indentured Servants to the Indian capital nearby. But the optics of that! "Improving" the Indians by literally turning them into criminals is a very bad look. Maybe it should be indentured servants.

Edit: Or maybe the script should offer the option?

It's still in slow progress: the code needs to be refactored to add new features.

But I have a better idea about indian converts: it is possible to convert them to armed braves or mounted warriors, who will fight by my (player's) side!
 
Now that's thinking outside the box! Maybe that should be an option. I suspect though that the game won't let you promote braves to mounted warriors, and if they're defeated in battle I bet the computer will just delete them.

If you allow creation of armed braves or mounted warriors (or even mounted braves), maybe that should cost the colony muskets and horses, as appropriate. (And maybe the option shouldn't be available / shouldn't work if the colony doesn't have the needed guns/muskets.)
 
Last edited:
Now that's thinking outside the box! Maybe that should be an option. I suspect though that the game won't let you promote braves to mounted warriors, and if they're defeated in battle I bet the computer will just delete them.
Yes, the game won't let direct promotion - I can't edit the game's executable, only save files. But I can "emulate" it by manually setting their type to "mntd warrior" or "armed brave" inside a save file. I've tried it already and yes, you are right: they die instantly when defeated. Another thing: they are not shown at gates on the colony screen, so it will be impossible to manually disarm them and revert to converts. But I don't think it's critical.

If you allow creation of armed braves or mounted warriors, maybe that should cost the colony muskets and horses, as apporpriate.

That's for sure! Converting them to armed units will cost muskets and horses, just like regular soldiers. I don't want to make a cheat ulitily - it's boring. I just want to upgrade the beloved game)

Other things I'm thinking of:

1. Growing forests near colonies. Sometimes the AI clears all the forest squares near the colony so that you cannot build anything when capture it. It's so dumb. So I think it will be ok to "grow" forest nearby. It may cost some lumber and/or tools.

2. AI's colonies are often so poorly managed, even on higher difficulties. So it may be ok to manually upgrade AI's colonies: clear colony's square of forest and plow it (the AI never does it...), "build" useful buildings, fortifications, set proper specialists and so on. The goal is to make AI more challenging, the siege of it's colonies more tough and capture of them more rewarding.
 
Replacing forests! That'd be brilliant--since even in cheat mode there's no way to replant or replace them. Yes please.

Tinkering with the AI's colonies? Sure--I don't see doing that myself, but others might want the option to do it.

Do you think it might be possible to write a utility that will show Indian settlements with coordinates, tribe, visited/not visited, and what they teach if anything? It could crawl through the save file and then pop up a text file or something? That way you could look up a given settlement to see if your scouts missed it, or "which was the one that teaches Tobacco Planter?", and so on. Having to send a scout specifically to find that sort of thing can be incredibly inconvenient.
 
Replacing forests! That'd be brilliant--since even in cheat mode there's no way to replant or replace them. Yes please.
Ok, working on it)

Do you think it might be possible to write a utility that will show Indian settlements with coordinates, tribe, visited/not visited, and what they teach if anything? It could crawl through the save file and then pop up a text file or something? That way you could look up a given settlement to see if your scouts missed it, or "which was the one that teaches Tobacco Planter?", and so on. Having to send a scout specifically to find that sort of thing can be incredibly inconvenient.
Hmm, seems that there is a utility from this thread: https://forums.civfanatics.com/threads/colsaves-updates.678126/ It shows Learned/Scouted status. Haven't you tried it?
Another thing is, as far as I know, no one still knows where the info about teaching speciality is located inside a .SAV files structure. Neither do I.
 
Thanks, I've changed the link on my page. I'll see about submitting a pull request to touch up the readme, as you request there. One question, what does "koeffs" mean?
Thanks! You can edit readme and post it here as an attachment if you are not familiar with github. If it is ok, post it in main thread please. "koeffs" is "coefficients")

Also, another option for Indian converts might be to give them horses to make them Scouts.
Scouts, not mounted braves?
 
D'ohhh, that'd be the same thing, wouldn't it? Or--wait, would it? Would mounted braves function as scouts? Or would they simply attack Indian settlements?

I have been active in GitHub elsewhere (as peyre), but I forget just now how to set up a pull request. Here's the file, for now. I had to change the extension to .txt for civfanatics to accept it.
 

Attachments

  • README.txt
    7.9 KB · Views: 20
Last edited:
Um, hello, guys. Is there a way to circumvent the hardcap imposed by the game on the number of colonies we can found? I mean, 38 is too little a number to satisfy the avid Col gamer.
I'd like to play a long game well into the 1700's ((which I've never done) but the 38 colonies limit is a bummer. The software you outline here does it help with this crippling limitation?
 
Um, hello, guys. Is there a way to circumvent the hardcap imposed by the game on the number of colonies we can found? I mean, 38 is too little a number to satisfy the avid Col gamer.
I'd like to play a long game well into the 1700's ((which I've never done) but the 38 colonies limit is a bummer. The software you outline here does it help with this crippling limitation?

Hi! Could you please post here a SAV file with 38 colonies? I'll try to check whether it is possible to increase this number. I'm an old Col fan too, but I had never had so many colonies - it always annoys me to manage them all.

And plus one question: is it still possible to capture AI's colonies after you reach colonies limit?
 
Last edited:
Like others before me I was hoping to get information from the savefile of which Indian camp teaches which profession (especially cotton planters and tobacco planters, I usually get enough fur trappers and sugar planters). I tried to look for some pattern myself, but I quickly gave up when the same Inca town in the exact same spot on the America map gave 2 different jobs in 2 different games. (I never get fisherman on the America map, so it could be location related. But it could also be a small sample size.)

It wouldn't be so bad if the self teaching thingy happened more often, but my last viceroy game I've had a colonist plant tobacco for about 200 years and by the time I won he was still a free colonist.

I was also curious about the prime resources location, and I do think I got something there.

Thanks to Pifou42's suggestion about creating a map with nothing but forests I found that there's a repeating pattern going 5, 6, 9, 6, 9, 6, 5, 10, repeat. The non-forest primes follow the exact same pattern, but 4 locations to the left. Giving you something like this (G - ground & ocean, F - forests):
G---F-G---F--G---F-----G---F--G---F-----G---F--G---F-G---F------G---F-G---F--G---F-----G---F--G---F-----G---F--G---F-G---F------G---F

On line 1 of the map you start somewhere in this string based on a seed in the savefile and going down the map it rotates 28 characters, 4, 16, 4, repeat.

If an F is on a non-forest, there's no prime. If a G is in the ocean too far from the coast, there's no prime. If a G is on a forest, it will show up after clearing the forest.

Using pbsite's enc_decode_sav.py utilty I got a field called prime_resource_seed containing two bytes. It looks like the first byte is always 00, I have no idea what the first half of the second byte does (lost city?), the second half of the second byte is some kind of offset for the prime pattern on line 1.

I never use python and had to look up everything, this can probably be done easier and/or faster. Run it with "python3 script.py [0-15] > filename.txt" to get the pattern for the complete map in a textfile. The 0 - 15 matches with 0 - F in the second half of the second byte of the prime_resource_seed field. Any other input probably gives an error.

I checked it with multiple savefiles and I'm pretty sure it's correct.

Since there's only 16 versions of the pattern I thought about just dumping it all here, but 16 patterns times 70 lines would be an awful lot of spam.

For the people who just want to know the trick(s) to find primes hidden in a forest while in a game, there's two (as far as I know):
1. As mentioned by Pifou42, there's always a ground prime 4 steps left from a forest prime.
2. Also mentioned by Pifou42, but a bit more detailed: for every forest prime on an even line (2, 4, 6, etc.) there's a ground prime directly to the south.

In theory both also work the other way around, except you can't plant forests in a regular game.

Python:
import sys

def rotate(input, r):
    return input[r:] + input[:r]

offset = 4 * int(sys.argv[1])
pattern = '1      1         1      1         1      1     1          1     '
pattern = rotate(pattern, offset)
for i in range(70):
    output = list(' ' * 56)
    for f in range(56): # forest prime resource
        if pattern[f] == '1':
            output[f] = 'F'
    pattern = rotate(pattern, 4)
    for g in range(56): # ground (and ocean) prime resource
        if pattern[g] == '1':
            output[g] = 'G'
    print(''.join(output))
    # rotation is actually 36, 60, 48, 60, repeat, but we already rotated 4
    match i % 4:
        case 0:
            pattern = rotate(pattern, 32)
        case 1:
            pattern = rotate(pattern, 56)
        case 2:
            pattern = rotate(pattern, 44)
        case 3:
            pattern = rotate(pattern, 56)
 
Hi @Skye!

That's an interesting investigation, thank you! At first I tought that there was a list inside each SAV file with coordinates of each prime resource tile. But @Pifou42 shown that they are scattered according to some pattern that has some kind of staring seed. That's why it is not possible to make all the colony's nearby tiles prime. Since then I've lost interest to this subject)
I tried to look for some pattern myself, but I quickly gave up when the same Inca town in the exact same spot on the America map gave 2 different jobs in 2 different games. (I never get fisherman on the America map, so it could be location related. But it could also be a small sample size.)
For now I gave up too. My best conclusion is that a village's teaching spec somehow depends on the tribe, nearby terrain and prime resources (not just closest). If you still have SAV files from these 2 different games you could manually set the same prime_resource_seed value and check whether this town still teaches different specs or same.

Thanks to Pifou42's suggestion about creating a map with nothing but forests I found that there's a repeating pattern going 5, 6, 9, 6, 9, 6, 5, 10, repeat. The non-forest primes follow the exact same pattern, but 4 locations to the left. Giving you something like this (G - ground & ocean, F - forests):
G---F-G---F--G---F-----G---F--G---F-----G---F--G---F-G---F------G---F-G---F--G---F-----G---F--G---F-----G---F--G---F-G---F------G---F
Nice one!
If a G is in the ocean too far from the coast, there's no prime.
Yes, that's because MAP section has a special marker for these far ocean tiles suppressing prime fish.
It looks like the first byte is always 00
Its LSB can sometimes be 1. It influence only City Rumors positions!
UPD: My mistake. First byte is always 00. It is 5th bit of the second byte that affects LCR pos.

BTW what about City Rumors? Do they follow the same pattern or some other?
For the people who just want to know the trick(s) to find primes hidden in a forest while in a game, there's two (as far as I know):
1. As mentioned by Pifou42, there's always a ground prime 4 steps left from a forest prime.
2. Also mentioned by Pifou42, but a bit more detailed: for every forest prime on an even line (2, 4, 6, etc.) there's a ground prime directly to the south.
Useful tips, thanks.
 
Last edited:
Didn't look into the lost city stuff, don't really care about the placing of those. I might check out if it's similar to the prime pattern later.

As for the Indian jobs, changing prime_resource_seed does nothing. Changing unknown39b does, sometimes. Checked out the Inca's on America again. Finally saw some ore miners and fisherman, even got 1 weaver and 1 fur trapper (who doesn't show up on this list: https://civilization.fandom.com/wiki/Incas_(Col)). Got mostly silver miners. Could be the surrounding terrain, could be because their job table just has loads of silver miners, could also be some kind of default fallback.
 
Theory:
  • The RNG fix makes it so that villages' jobs are somewhat random on each visit and also changes the random layout of a colony each time it is entered, it seems to me like those values are randomized but depend on a constant seed in the base EXE. So for that, the same seed will be used on every check, resulting in the same outcome, but for the RNG-fixed EXE, a different seed is created each check.
  • Maybe the villages derive the offered job from one of their surrounding tiles. Which one is random but is determined based on the seed, so in the regular EXE it stays constant (or changes only when the tile is deforested). As this seed is recreated with the RNG fix all the time, in the fixed EXE it changes around but still only offers jobs based on surrounding tiles (and based on which jobs the tribe can even teach).
 
  • The RNG fix makes it so that villages' jobs are somewhat random on each visit and also changes the random layout of a colony each time it is entered, it seems to me like those values are randomized but depend on a constant seed in the base EXE. So for that, the same seed will be used on every check, resulting in the same outcome, but for the RNG-fixed EXE, a different seed is created each check.
Nice catch. I've never tried RNG-fixed version.

  • Maybe the villages derive the offered job from one of their surrounding tiles. Which one is random but is determined based on the seed, so in the regular EXE it stays constant (or changes only when the tile is deforested). As this seed is recreated with the RNG fix all the time, in the fixed EXE it changes around but still only offers jobs based on surrounding tiles (and based on which jobs the tribe can even teach).
It's definitely not ONE tile: with my enc_decode_sav utility i tried altering village's several surrounding tiles (forest, deforest, vary base terrain type) and the teaching spec changed almost every time. (To be more precise: it always changed when I de/reforest nearby tiles or vary terrain type of tiles without forest. But it never (?) changed when I vary terrain type of forested tiles) So it seems that some hash based on several surrounding tiles is used.
 
Last edited:
Just read this thread; it's a shame the indian education options are generated randomly based on the game's RNG combined with the surrounding map tiles. You'd have thought that if they store the village locations in the save they could store the education options along with them. Then they could've made sure there was at least 1 or 2 of each new-world-only specialty in each generated map. It's really annoying to spend ages exploring the whole map and there's not one village teaching master tobacco planter! Maybe a tool could be made that could use the same algorithm as Colonization, with the original RNG (so it stays the same), determining each village's specialty on a given save game? At least then I could get a count of how many there are of each one and abandon new games where there's none of a certain specialty! Presumably getting at this algorithm would be quite challenging. I could have a go in the DOSBox debugger but I'm pretty sure I wouldn't be able to figure out what was going on.
 
Last edited:
Top Bottom