1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Civ1 exploit: design flaw in randomness

Discussion in 'Civ1 - General Discussions' started by darkpanda, Sep 16, 2013.

  1. Kras

    Kras Chieftain

    Joined:
    Nov 8, 2005
    Messages:
    8
    Do you think that developers could resort to this simple solution while making Civilization 2?
     
  2. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    Well, the exploited trick here is really a design flaw: developers could very well have temporarily stored the random seeds, then re-seed the generator for displaying the city, and then rollback the seeds to their value before the city was shown.

    My point is that it is not really a "simple" solution - seed-based randomness is really widespread and classic. But it is very much possible that the same flaw exists in other versions of Civ (WinCiv, CivNet, ...) or even Civ2.
     
  3. jarvisc

    jarvisc Chieftain

    Joined:
    Oct 24, 2012
    Messages:
    50
    LOL. Well, thanks for the response darkpanda. Yeah, I understood that if one were trying to figure this out by hand, one might be limited to "Okay, this city name works well when attacking a phalanx with a chariot... and I hope I found a seed that works for all the veteran and defense bonus combinations!"

    I will say though that this is interesting information and affects my gameplay -- but not in the way you think! I have previously had my own skepticism about the CIV randomness generator to the point that I decided for a "pure" game by my own standards, I would play the game from start to end without even closing/reloading CIV, because I didn't know how deep the state goes on the random generator. I now know it's totally useless because that state is wiped just about every turn, so there's no point thinking that a game from beginning to end is any different from a game that is closed and resumed.

    Anyway, thanks again as always (it will be interesting to see how huts work, too)

    Jarvis
     
  4. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600

    CIV RANDOM HACK - Huts table



    Of course, in the wake of the random hack attack table I posted earlier, it did not take long to find out how to leverage the randomness for Hut rewards... I've had the table below on my disk for 2 weeks, and although I was waiting for a nice way to present it, now I think it's just been too long. So I'm just posting it as is, with necessary explanations.

    How to read the table below?

    The Huts table below is based on the Attack table and method presented in this post: CIV RANDOM HACK - Attack table

    In the tabe below, the 4 numbers separated by slahes (/) represent the minimal number of "screen refreshes" (i.e. single random calls) after which the next call to random(4) will return, respectively, 0, 1, 2 or 3. Those random(4) results form the basis of the Tribal huts visit outcomes routine presented in this thread: Civ1 explained: tribal huts visit outcomes

    For example, take a city of size 4 with 2 buildings:
    • the hut table below contains 0/3/1/10
    • the attack table contains P0 and +0
    • this means that, if your 4-pop 2-building city is named "P0", then after displaying its city view:
      • you will get an immediate win if attacking (+0 from attack table)
      • the immediate next random(4) will return "0" (first value "0" from hut table), which may result in a new city (Advanced tribe), a new unit (Skilled mercenaries) or 50$ when visiting hut
      • after 3 random calls, typically 3 screen refreshes (press 'C' key in map screen), the next random(4) will return "1" (second value "3" from hut table), which may result in a Civ Advance (Scrolls of ancient wisdom) or 50$
      • after 1 random call, the next random(4) will return "2" (third value "1" from hut table), which will result in 50$
      • after 10 random calls, the next random(4) will return "3" (fourth and last value "10" from hut table), which may result in a new unit (Skilled mercenaries) or a horde of barbarians

    Hut table


    Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12 Column 13 Column 14 Column 15 Column 16 Column 17
    Buildings -> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    Size 1 1/8/0/5 0/2/7/1 0/2/5/1 0/2/1/7 1/3/2/0 0/2/1/7 4/0/3/1 0/2/4/1 0/4/7/1 0/6/2/1 0/2/6/1 0/2/3/1 0/6/1/3 1/0/4/2 0/7/1/2 0/3/8/1
    Size 2 0/5/4/1 0/6/8/1 0/2/17/1 0/4/1/6 3/1/8/0 0/2/1/10 0/7/6/3 0/7/5/1 0/4/3/1 0/2/1/7 0/4/6/1 0/2/1/5 0/3/1/2 0/2/1/9 1/5/0/3 5/4/2/0
    Size 3 0/2/3/1 0/10/1/2 0/7/6/1 0/5/1/9 0/3/1/4 0/2/9/1 0/9/1/2 0/16/2/1 0/2/1/3 0/5/7/1 0/6/4/1 0/7/1/2 0/3/1/2 0/2/4/1 0/2/1/8 0/4/2/1
    Size 4 3/0/4/27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/1/3 0/5/1/2 0/10/1/6 1/8/0/4 0/2/5/1 0/3/1/9
    Size 35 0/3/1/15 0/4/9/1 0/2/7/1 0/9/1/2 0/4/1/2 0/2/1/5 0/2/13/1 0/20/1/6 0/4/6/1 0/7/1/6 0/13/1/5 0/2/7/1 0/2/5/1 0/2/1/7 0/2/8/1 2/1/8/0
    Size 36 0/2/7/1 0/4/1/2 0/6/2/1 0/2/1/4 0/3/1/4 0/20/1/6 0/3/1/12 0/5/2/1 0/11/1/6 0/9/1/2 0/4/6/1 0/4/3/5 3/4/2/0 5/0/6/1 2/1/0/3 0/5/1/2
    Size 37 0/2/5/6 0/6/2/1 0/4/1/2 0/2/3/1 0/3/1/4 0/5/1/2 3/1/0/13 0/11/1/6 0/2/13/1 0/2/1/4 0/3/6/1 0/7/1/6 5/0/1/9 0/5/1/3 0/4/9/1 0/5/1/3
    Size 38 0/5/1/3 0/4/1/3 0/2/3/1 0/4/1/7 0/3/1/4 0/3/5/1 0/2/1/9 0/11/1/5 0/2/1/4 0/6/5/1 0/5/4/1 0/3/8/1 2/8/0/3 0/6/1/5 0/3/1/9 0/2/5/1
    Size 39 0/5/1/11 0/3/1/4 0/2/3/1 0/7/4/2 0/4/1/7 0/2/9/1 0/11/1/5 0/11/1/6 0/2/13/1 0/5/1/13 0/7/1/6 0/13/1/3 1/0/3/2 0/3/11/1 0/3/4/1 2/9/1/0
    Size 40 0/3/1/4 0/5/2/1 0/4/1/7 4/0/6/1 0/11/1/6 0/2/4/1 0/4/2/1 0/11/1/5 4/1/3/0 0/2/13/1 2/1/0/4 0/3/4/1 0/8/3/1 0/3/1/7 0/9/4/1 0/6/1/2

     
  5. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600

    Unsinkable triremes



    Just a quick post about random hacking triremes to be unsinkable: as stated elsewhere, there is 50% chance for a trireme to sink when it is away from coast.

    The actual code makes a call to random(2), and if the result is different from 0, checks whether it is next to coast: if not, it sinks.
    Conversely, if the random result is 0, then the check above is skipped, and thus the trireme does not sink.

    So you just have to follow instructions for the CIV RANDOM HACK - Attack table, and the next random(2) call will return 0, thus your trireme will not sink.
     
  6. oddahc

    oddahc Chieftain

    Joined:
    Oct 20, 2014
    Messages:
    10
    i'm playing Early Conquest game on a pangea continent but, being a noob, i can't get the huts to produce as i'd like them to...

    so maybe i'll describe what i'm doing so that someone could point out my error. :)

    since i'm still in build up mode most / all of my cities are at 1 / 2 population and are producing more settlers to make more cities. it would be great to reliably start new cities far away without having to produce and move them there one square at a time!

    goal: produce "Advanced Tribes" on suitable-land-type huts.

    so i rename the 1/ 2 attacking city pross / orkenypuszta (from attack table, +0)
    then i click in the city to view it
    then i "attack" the hut with my chariot.

    as i understand it i should get a predictable result every time, and hopefully an Advanced Tribe if the hut is on suitable land type...

    but i don NOT. i get mixed results... barbarians / tech / 50 coins.


    so what am i doing wrong? :confused::confused:
     
  7. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    If you get mixed results, then you're not doing it right...

    But anyhow let's start at the beginning: what's your version of Civ? (not that it should have any impact, though, just to be sure)

    Next, here is how you should proceed, step by step:

    Objective: force result of Huts to "Advanced Tribe"
    1. Look at the Huts random hack table in this post: http://forums.civfanatics.com/showpost.php?post=12825192#post12825192
    2. Each cell contains 4 numbers, which are the number of random calls to execute so that the next random call (random(4)) returns 0, 1, 2 or 3
    3. Look at this post then, that describes which random value you need depending on which hut outcome you want: http://forums.civfanatics.com/showthread.php?t=510312
    4. You see that for Advanced Tribe, you need the random(4) to return 0
    5. From the Huts random hack table, you will then be looking at the first of the 4 values from each table cell
    6. Assuming you only have cities with 0 buildings and size 1 or 2, the table tells you you need 1 additional random call after showing city view (size 1) or 0 random call after city view (size 2)

    That's for the theory, now here's how to proceed:
    1. Get one of your units (e.g. chariot) right next to a hut you want to visit
    2. Take a note of which direction your unit will need to move to enter the hut (will be useful to perform a "blind move", i.e. moving the unit without seeing it on screen)
    3. Go to your size-1 or size-2 city, properly renamed as explained in the Random attack table; that is pross for size-1 cities, or orkenypuszta for size-2 cities
    4. Open the city screen then display the City View
    5. WARNING: from now on be careful where you click! because each click on the map screen will make the map refresh and trigger 1 additional random call...
    6. Exit the city screen
    7. If you city was size 2, DO NOT CLICK ANYWHERE, but make your unit (e.g. chariot) visit the hut by pressing the arrow in the correct direction (noted at step 2 above)
    8. If your city was size 1, we need 1 more random call before visiting the hut, so typically, press "C" ONLY ONCE to center the view on the chariot (this will refresh the map and thus call random() once), and then visit the hut

    If you still cannot achieve your objective with the detailed steps above, then you'll need to provide more details about what you're doing - or why not a video?
     
  8. oddahc

    oddahc Chieftain

    Joined:
    Oct 20, 2014
    Messages:
    10
    is there a hack to lower the threshold at which the hut will produce an Advanced Tribe?

    currently it will only produce an Advanced Tribe if the "map value" is 13 or greater, whatever that is. is there a table for "map value?"

    in practice i can only get an Advanced Tribe on shielded-plains (not empty plains) and straight rivers (not river curves... or maybe it's all about the hidden shield which is either there or not...) update: nope, shielded curved river hut will only give me the 50 coins, even with city view. :(

    still waiting on my TerraForm Key... not that i would use it overmuch for normal play but there are a few scenarios i'd like to play out... even scenarios it for some reason doesn't supply like a map filled with the "game" special resource. :)

    unrelated question: i noticed that i get more food from a city if i irrigate (and possibly railroad) the square before i build it. what is needed for this and what isn't?
     
  9. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    No table, this is hard-coded in CIV.EXE, but probably easy to patch. I'll have a look later, maybe.

    In the meantime, you can take a look at JCivED.

    But be advised: "special resources" are controlled with a hard-coded formula in CIV.EXE, you cannot edit them in savegames...
    See these threads for more details:


    If building a city on plains/grassland/river, the square will automatically be irrigated and roaded at the same time.
    But CIV 1 has a known bug that Cities cannot be railroaded after their creation - unless the railroad was already there built before the city is built, which is the situation you describe.
    Fortunately, a patch exists to "fix" this bug! See here: City square behaviour - patch suggestion
    The patch is also available in JCivED.
     
  10. Svetkavitsa

    Svetkavitsa Chieftain

    Joined:
    Sep 12, 2010
    Messages:
    46
    Location:
    Utah, USA
    I came back to civ (it will always have a special place in my heart) while waiting for BE to get patched, and this thread has made my day/week/month. As a programmer/software tester, I can easily see how this could make it into the game and remain undetected for so long. But taking the design flaw and turning it into an exploit that you always win your battles still makes me laugh every time I think about it. I applaud your work reverse engineering civ and all the things you've uncovered from it.
     
  11. reddishrecue

    reddishrecue Chieftain

    Joined:
    Nov 16, 2009
    Messages:
    5,210
    Gender:
    Male
    Really? I've noticed new cities start out with railroads instead of roads after railroad has been researched.
     
  12. Tristan_C

    Tristan_C Chieftain

    Joined:
    Aug 16, 2006
    Messages:
    1,439
    But you can't railroad the tiles of any cities founded before the discovery of Railroad. Usually I've founded at least one city prior to discovering Railroad.
     
  13. GoldBerg

    GoldBerg CivDosPlayer of '91

    Joined:
    Aug 20, 2003
    Messages:
    564
    Gender:
    Male
    Location:
    Palace Improvement
    Well, some hut squares are on hills,
    i am sure there never was a city given from a hut
    in the non-hacked game.
     
  14. humbe

    humbe Chieftain

    Joined:
    Nov 23, 2005
    Messages:
    168
    Haha.. Awsome info darkpanda.. (Though I'm a latecomer to thread)

    Stupid of implementors to screw seed on showing city, but then again, it's not a multi-player game, so it's no big deal really.

    Seeing that a roll of 1 always create a tech, I have been looking at how to get specific techs by getting the second roll to roll appropriately on d72. As most of the interesting techs early on have low numbers, it's way too often you get the lowest one.

    Basically, you commonly have a size 1 city with no buildings ('cept maybe palace), so given a name for that city, how many refreshes do one have to do to get 1 for tech and then a good d72 roll. Tedious to figure out having to figure out by manually testing though.

    Is that java code that reproduce the algorithm something you could share?

    Anyhow, I found another strangety. For a city of size 1 with no buildings (possibly 'cept palace), named pross, I seem to get in one of two seeds depending on some other unknown attribute. Either I'm getting a tech after 8 refreshes, or I get one after 7 or 9 refreshes. I'll have a look at the city view and see if I can see anything different in graphics when it happens to explain it.
     
  15. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    There is Java code simulating the random routine of Civ. It is part of JCivED since the latter uses it to generate random maps: https://sourceforge.net/p/jcived/code/HEAD/tree/tags/jcived-0.0.17a/src/dd/civ/logic/CivRandom.java

    I did write some separate code to generate the random attack tables, but they are not published with JCivED as far as I remember, I need to check.

    Now, re-reading your post, I am not sure I understand what you mean by "refresh" ? On which context are you attempting to obtain a tech ?
     
  16. humbe

    humbe Chieftain

    Joined:
    Nov 23, 2005
    Messages:
    168
    Following your hut table, one see how to roll a d1 for the hut in order to always gain a tech when one enter a hut. However, after doing that 0-3 random roll for the hut, a 0-72 roll is then made to see what tech you found according to the linked post above with tribal hut outcomes. I'm trying to figure out how to get that 0-72 roll to roll my way.

    A detailed example to avoid any confusion: Having a unit ready to enter a hut, entering a size 1 no buildings city named pross, your table says that if you go into city view, press esc twice to get out in map, then hit c or click map 8 times, and then move into hut, you will roll a 1 in the 0-3 random roll and get a tech. From what I observe you will then roll a d72 of somewhere in the range 46-53 (At the time I received tech #53, but I would have done so on any roll in the 46-53 range so I dunno the exact number rolled).

    If instead of hitting c or clicking map 8 times (which I called refresh), you do it 10 times, you will also get a tech, but now the random roll is somewhere in the 8-10 range (A specific one, I just don't know exact yet).

    Of course, clicking 'c' 412 times to get the 0-72 roll to go your way is impractical, so it would be nice to figure out what one should name the city in order to create a get tech outcome on hut, that rolls a specific number for what tech after. Not really needed to know it for all city sizes and number of buildings. It's easy to have a size 1 city without buildings, so if that works, that is enough for me.

    I figured that if you had some simulation code you used to generate the table of city names, and see how many times you had to roll to get a 1 result when entering a hut, that maybe it could be extended to check what d72 roll will be made for tech afterwards.
     
  17. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    Ok, now I get your point :)

    I will try to put some time on this and get back to you in a couple of days.
     
  18. humbe

    humbe Chieftain

    Joined:
    Nov 23, 2005
    Messages:
    168
    As to the two separate results I get for the same city sizes/buildings, it seems like they are likely just skewed one roll.

    My current theory is that sometimes rand() is called when moving cavalry into hexes that are expensive to move into, and that explains why I have to refresh screen one time less sometimes. I'll try to verify when I take further huts if it's only happens then moving into expensive tiles.

    Optimizing a bit for what tech I get from huts, in my emperor game here, I invented RailRoads in 3020 BC, and at that time I'm a Democracy that recently built J.S. Bach cathedral. Probably my best start so far at least.. Though mangling with the random number generator would be called cheating by most, it's interesting to see what's possible if one were incredibly lucky :)
     
  19. humbe

    humbe Chieftain

    Joined:
    Nov 23, 2005
    Messages:
    168
    This also works to control where a civ starts when you destroy another. The invasion screen when you invade their last city, resets random seed to show the city screen with given name, so it will be the same each time you try it. But when you get into the city screen you can alter the name and enter city view. When you leave the city screen and get a report the civ is destroyed, the new civ will be placed based on the seed you just created.

    Have tried out quite a few different names to see if I could control it, but the same locations seem to repeat. Either, only a dozen or so tiles are likely targets, or it's an effect like techs, that you are likely to pick an invalid tile, and there is some procedure to move to closest legal one or something, where lots of tiles map to a small set of closest legal tiles. Extra tedious to check though, as you don't see on the map where they reappear.
     
  20. Posidonius

    Posidonius Civherder

    Joined:
    Jun 28, 2015
    Messages:
    196
    Location:
    US of gawldarn A
    Hmmm, there are more powerful forces at work than rand() calls in this process. It is possible to take complete control of respawns with reliability, without re-seeding the rand function. Suitability and date matter more. But you are correct, i saw that rand() does play a role. What it looks like, from the luser POV, is that if you allow a variance then a variance can occur. But it is a pittance of effort to eliminate variants.
     

Share This Page