Civ1 explained: tribal huts visit outcomes

darkpanda

Dark Prince
Joined
Oct 28, 2007
Messages
823
Due to popular demand (actually only kirkham7 asked for it, I think) while trying to hack CIV randomness without altering CIV.EXE, I have gone through the "Tribal Hut" reward algorithm, and I lay it below for everyone to see:

  • If the Civ searching the hut is Barbarians OR the Unit searching the hut is category 1 (air) -> nothing happens; interestingly, this means that enemy Civs also benefit from tribal huts visits...
  • Compute the distance to the nearest city (any owner)
  • Random call: 0, 1, 2 or 3
    • If 0:
      • If distance to nearest city is equal to or larger than 4:
        • If Map square land value is equal to or above 13 => You have discovered an advanced tribe
        • Else => You have discovered valuable metal deposits worth 50$
      • Else => You have discovered a friendly tribe of skilled mercenaries
        • 50% chance of getting Legion or Cavalry
    • If 1:
      • If current turn is 0 (year 4000 BC) OR current year is later than 1000 AD => You have discovered valuable metal deposits worth 50$
      • Else You have discovered scrolls of ancient wisdom:
        • Randomly select a Civ Advance ID among the 72 of them
        • If the player already has it OR doesn't have all prerequisistes to that tech, increment to next Advance ID (modulo 72) and loop back to previous step (do this for a maximum of 1000 loops)
        • Else give the Advance to the Civ
    • If 2: => You have discovered valuable metal deposits worth 50$
    • If 3:
      • If the distance to the nearest city is less than 4 OR if the Civ has no city yet => You have discovered a friendly tribe of skilled mercenaries
        • 50% chance of getting Legion or Cavalry
      • Else => You have unleashed a horde of barbarians!
    • If 4: => You have discovered a friendly tribe of skilled mercenaries (this can actually never happen since random values are only in the range {0 .. 3})

Obviously, some kind of random cheating is possible to control the huts outcomes, but as you can see, the result also depends on other game factors that are more difficult to control...
So to answer a few questions:
  • kirkham7: Is it possible that huts always give a new city? -> No, since it also depends on proximity to another city, and land value of the hut square; kind of makes sense, you wouldn't to build a city on a mountain or hill, I guess, although the value threshold could have been lower than 13...
  • urbancaver: Is it possible to always get an Advance? How many advance can you get? -> YES, and technically speaking, you could get ALL advances through huts, provided you visit enough huts before 1000 AD... I need to try this one out, seems too good to be true...

And as far as hacking CIV.EXE, there are plenty of possibilities: change the default units for Skilled Mercenaries, disable the possibility of barbarians, bypass the advance "pre-requisite" check so you could discover Space Flight in 3980 BC (some kind of StarGate or Atlantis mode :))
 
It's good to finally know the formula. I've wanted to know this for years now. I'd tried figuring it out by experiment, but this formula is too complex for that.

I've got to clarify something about the tech picking formula. If it picks a random number, then cycles through the list to find a discoverable tech, then some techs will be many times more likely than others. Also, since it picks a number up to 72, and there are only 68 techs, 4 numbers at the top must never match (and therefore always carry over). So, if I have Alphabet and Bronze Working, apparently I'm 31 times more likely to get Code of Laws than Currency.

What we really need is a screenshot of "ancient scrolls of Future Tech".
 
If it picks a random number, then cycles through the list to find a discoverable tech, then some techs will be many times more likely than others. So, if I have Alphabet and Bronze Working, apparently I'm 31 times more likely to get Code of Laws than Currency.

Well of course, this "iterating" logic makes some Advances more likely than others, I am not sure you can do anything about... Except for a CIV.EXE hack to make it truly random, e.g. re-select another random Advance.

Also, since it picks a number up to 72, and there are only 68 techs, 4 numbers at the top must never match (and therefore always carry over).

Indeed, and the reason for this is that those 4 last techs refer Tech ID 127 as a pre-requisite, but there is no such Tech with ID 127, so you can never discover them. Even by changing this data, I suspect that CIV will crash by lack of appropriate related tech resources (data, PIC, etc.).

What we really need is a screenshot of "ancient scrolls of Future Tech".

Won't be happening: Future Techs are not part of the "Civ Advance" data (Gowron mentioned those data lists in another thread, look for "Data Tables"), so they can never be selected by this process.
Instead, what happens (I just tested it) is that you get the popup message "You have discovered scrolls of ancient wisdom", but then the popup ends without any Advance being discovered... Although twice before that I discovered Nuclear Fusion and Chivalry.
 
That explains a lot! Thanks! When we were youngers we would experiment with the game in various ways. Sometimes we didn't built any cities and we would just move around the map collecting the huts. Without a city every "barbarian pop" would mean new troops. We used those soldiers to eradicate players before they grew in power. It was possible to win before 2000 BC. Now I know the mechanics that stand behind this. Oh, and if you would kill last enemy unit just one turn before an auto-save then after loading it, you could play solo, without computer players.

Indeed, and the reason for this is that those 4 last techs refer Tech ID 127 as a pre-requisite, but there is no such Tech with ID 127, so you can never discover them. Even by changing this data, I suspect that CIV will crash by lack of appropriate related tech resources (data, PIC, etc.).

I don't know if patch affects this (anyone else knows?) but sometimes something weird happens and other players get techs like Rocketry or Space Flight in ages where we barely started to use Knights. What I've noticed is that sometimes I could get from AI players techs named simply '1', '2', '3' and '4'. This bug could be solely connected to one specific alorythm but I doubt it's this one. Usually when I get this bug, other weird things start to happen.
 
I'd say knowing this algorithm is covered under popular demand as there are/were multiple luck manipulators around.

Based on thousands (upon thousands) of trials, I knew that cities generated only when a certain distance away. I was not prepared to see two conditions for mercenaries based on proximity.

As for discovering advances, I don't know about all of them, but it's quite viable to visit all huts before 1000 AD and make them all generate favorable outcomes (except with save-swapping, in my experience). It's even viable to lock other civs out of their huts, though such requires aggressive pre-scouting and luck manipulation (e.g. make all civs spawn on the Asia super-continent and then make respawned civs generate there as well).

I'd imagine most people would take 1-5 NONE Calvary for scouting purposes with the remainder being split between cities and tech. I believe hut tech is immune to the hiding feature of the advances list.
 
Just noticed this thread. Fascinating! One almost feels like a chump for not knowing these basic rules before...

A couple questions though regarding the decision tree darkpanda laid out, what about nomad settlers? That is, you find a hut which instead of giving a city, gives settlers. Also don't I remember some huts giving 100 gold instead of 50? Does this depend on version or am I crazy?

Granted I haven't been popping huts much in my games the past year, partly due to fear from barbarians. Now I know if I have a city close I don't need to worry about that, at least!

I had pretty much already known that you won't get barbarians from your first hut or two, at least, if you haven't founded your capitol yet. Interesting.

- - -

On further reflection I might be remembering Civ2 regarding nomad settlers etc. Gosh! Strange to be confused about that given I haven't played Civ2 for 10+ years. Also Whelkman I wasn't sure exactly what you meant by "It's even viable to lock other civs out of their huts..." and am curious if you care to elaborate a little more.
 
The easiest way to lock other civs out of their huts is to force them to spawn on the EARTH super-continent and use the save-swapping trick to overrun them with a single militia before they have a chance to move more than 1 tile away from their home cities. Save-swapping is tedious, though, and is an extreme method. Fortunately, it can still be done with "normal" luck manipulation, save for other cities claiming a handful of huts very close to home cities.

Start by forcing an EARTH game where all other civs spawn on the super-continent and preferably nearby in the case of two candidates, most notably Babylonians over Zulus. This is possible even with 7 civs. Personally, I play as the Romans, which makes overrunning the other European and nearby tribes trivial.

Assuming Romans, you will be able to kill the Germans or French with the 2nd settler before they fortify. The Greeks, Babylonians, and Egyptians can be taken out with a militia. During this early campaign, luck manipulate a hut into generating a cavalry and use that to take down the Mongols or Indians and the Chinese.

The alternative civs that spawn in random places will likely develop too slowly to claim a significant number of huts, but you can guarantee their inaction by checking the map in TerraForm or JCivED and ensuring they spawned on the super-continent and hunting them down with the cavalry (or two or three).

Several techniques described will be unsavory to some players, but claiming the majority of the huts should still be doable within normal means (in the lower difficulty levels, at least). Simply checking the in-game lists will reveal which civilizations spawned, and overrunning the four nearby tribes should not pose a problem. Where luck is involved is getting a cavalry early and having it survive the fights with Mongolia/India and China. Of course if you choose fewer civs, and all of them end up in Europe, then the job is even easier, though do remember to be mindful of the respawns.
 
Hi,
This is fascinating. If I understand you right then, by forcing the random call always to produce a 0, you will always get a new city providing that ((you are 4 sqares away) and (it is a decent square you're on)). Easily accomplished if you know where the multiplier is stored. I envy your knowledge about the inner workings of CIV.
 
Hi,
This is fascinating. If I understand you right then, by forcing the random call always to produce a 0, you will always get a new city providing that ((you are 4 sqares away) and (it is a decent square you're on)). Easily accomplished if you know where the multiplier is stored.

Yes, but you can force random calls output without hacking CIV.EXE at all, in order to control battle outcomes, huts outcomes, and even prevent triremes from sinking... Everything is explained here:

I envy your knowledge about the inner workings of CIV.

And I envied Dack's and Gowron's knowledge about the inner workings CIV, which is why I undertook the deciphering of MAP format, SVE contents and reverse analysis of CIV assembly... It is a long road, but very rewarding, if you care to put enough effort and patience :)
 
Top Bottom