Civ3's random number generator

Discussion in 'Civ3 - General Discussions' started by Plume, Dec 9, 2002.

  1. Lt. 'Killer' M.

    Lt. 'Killer' M. Deity

    Joined:
    Dec 5, 2001
    Messages:
    7,469
    take my current game as an example: it is only 10 battles, but it totally screws me that the AI can exchange 1 Archer for 1 fortified, walled, Great Wall, elite Hoplite!

    they attack him twice and he's dead - wtf??????? Three of these and 2 Swordsmen (same town, fortified) and my attack force is toast after it already suffered heavy 8but OK) losses when taking the town.


    Now I start to wonder if the AI knows results beforehand - after all they COULD have attacked with the 6 archers the turn before. Instead, i was attacked by the next civ and they had trouble killing my exposed hoplites - other way round I'd still have ten healthy hoplites...... :mad:
     
  2. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    It is well known that the AI always has full knowledge of your army and the world map at all times, but knowing the future numbers from the RNG - now that's getting freaky. Personally I doubt it, but if you find out for sure please let us know!
     
  3. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    ...And I just realised that this is the equivalent of reloading :lol:
     
  4. DANGERBOY

    DANGERBOY SCAdian Fencer

    Joined:
    Nov 5, 2002
    Messages:
    149
    Speaking of the streakyness of random results:

    I was taking a probabilities course in college. One of the assignments was to flip a coin 100 times, keeping track of the results and the order, so as to come up with certain stats such as longest streak (each result), longest alternating pattern (hthththt), and overall numbers.

    I got 142 tails in a row. I switched coins after 70 or so, tried different methods of flipping, anything I could think of to remove the "loaded die" scenario. I eventually called up my roommate to verify my results (part of the reason I kept going after 100, the other was I was not going to stop until I got heads). I finally gave up. I should still have somewhere that sheet with my roommate's signature.

    My roommate then flipped said coin, got expected results (I think it was 9 heads and 6 tails in a 15 flip trial)
     
  5. Plume

    Plume Chieftain

    Joined:
    Mar 4, 2002
    Messages:
    35
    Wow, never seen so many people in a thread I started before. Thanks guys.

    (TheNiceOne:) << Because I do think the randomness factor is a bit too high during the ancient age when there are very few units, and taking/loosing one city is much more important than later. During later ages the random factor is perfectly fine IMO.

    BTW, if you flip a coin 10 times, you will get a streak of 4+ heads/tails almost 50% of the time, so real world randomness is streaky.

    To sum up: There's two different things we're discussing.
    * Whether the chance of a weak unit beating a stronger unit is too high (too much randomness)
    * Whether the results are too streaky, that there are too many good or bad results in a row.

    The first is subjective, and those that answer yes can do something about this by increasing the number of HP and/or increasing the A/D factors of stronger units.

    The second is a basic result of true random results, and there's no way of taking away streakiness from results without adding a memory (i.e. increasing the chance of a good result after a bad one and vice versa). >>

    Long quote, I know. But that's exactly it. The second thing shows up because the events (numbers) given by the RNG are independent from one another. That's why you can get streaky results. My point is that such results are a good model for flipping a fair coin but for a combat simulation between hundreds of (virtual) people seems somewhat wrong to me. Don't get me wrong, I'm not saying it's a big deal; I've been playing civ3 for more than a year and I still love it. I just think it could be improved. Moreover, I KNOW the law of large numbers and I know that after a while it should even out. I'm saying that this "evening out" takes far too many events to happen and that in the ancient age, there generally aren't enough units for this to happen.

    There's been some talk earlier about how this could be "exploited". Wait a minute here. If you attack a fortified infantry with 4 warriors, loose all 4 (surprise!) this "system" wouldn't make you win the next fight with another warrior! It simply means that if your odds are 50/50 and you lose say 3 times in a row, then you'd get say 60% of winning the next fight. You could still lose it, but you'd be given a small bonus. Note that this would also happen the other way around. But I must say, there is some room for exploit. Like TheNiceOne said, set up a few unimportant battles somewhere and when you've been unlucky, attack on the major city (or carry out any important battle). Mmm.

    Another point: philosophy. I just won't go there (but some of posts were quite interesting).

    Quote (Four Four Seven) << If, in real life, I send an army to battle with a 50% chance of winning, and it loses (assume "losing" means all armies don't return and there's no knowledge gained), and I send another army to fight the same foe (again, assume the other army gains no knowledge), they will again have a 50% chance of winning. It does not get higher just because of a loss by an independent army. >>

    Well, that's the whole point. I don't think that "units" in civ3 should be completely independent. What you consider an army is, I think, something like the american army fighting in WW1 and the american army fighting in WW2. Those are completely independent. I agree. But in civ3, units sitting on the same square should not be completely independent. Especially if they all attack on the same turn.

    Now to go back on the exploit issue, I think this "memory" effect should only take place at specific places. Quite frankly, I'm not sure anymore how to implement this (at least not in a simple way). But maybe there is a better (and even simpler) way. Consider this modification, "every time a unit is attacked in a given turn (and wins of course), for the remaining of this turn, the defense rating of this unit decreases by 10 or 15%. Similarly, if a unit attacks multiple times in a turn, its attack rating should decrease every time by similar amounts."

    This has the advantage of leaving the RNG alone (I knew I was opening up a can of worms when I first posted...). It gives a little bit of memory to combats in a way that I think is realistic. Let's say one hp means one thousand soldiers. A 4hp swordman attacks a 4hp spearman and loses, 2hp remaining on the spearman. This means 2 thousand speamen actually died and the other 2 thousand are tired, they've lost their friends and all that. If, in the same turn, the attacker sends another 4hp swordman at the spearman, then they should have a better chance of winning than against a 2hp spearman who hasn't seen any action this turn (right?). By the way, the actual numbers would have to be worked out because this way, the attacker would have too much of an advantage with the numbers in the game now.

    This is not a new idea, it was in Panzer general II (and probably other games too). And I've just realised I'm completely off topic from the thread I started myself... oops. One last thing, nice to see other mathematicians here (well, I'm just a PhD student but I'm getting there...).
     
  6. sumthinelse

    sumthinelse civ investigator

    Joined:
    Mar 20, 2002
    Messages:
    1,333
    Location:
    Austin Texas USA
    I like to play with increased hit points (6 for conscript instead of 3, 8 for veteran etc.) because it can "smooth out" the rough edges of the RNG. can.

    In the case of a stack of swordsmen attacking a fortified spearman in a city, there are 2 ways to look at what "should" happen. In each individual attack, the spearman is more likely to win, so if the swordsman wins it's kind of an "upset." And if the attacker and defender both have 6 hit points instead of the normal 3 for regular, the defender has an even greater advantage. So on the level of a single combat, the added hit points make the chance of the expected result (the spearman winning) greater.

    However, when I attack with 3 swordsmen, I expect to take the city most of the time and have at least 1 swordsman survive. We calculated in a previous post in this thread that should happen about 4/5 of the time. But with 6 points for regular, the chance of the 3 swordsmen all dying increases to 29%. So for the question of whether the city will fall, the upset result is more likely!

    So does the RNG produce "smoother" or "rougher" results if I increase all hit points?

    Some of these issues are very subjective, as TNO correctly notes! :) :)

    Doubling the hit points of all experience levels certainly changes the game.

    For example, if I attack a 6-hp spearman fortified on a mountain with a stack of 3 6-hpswordsmen, I will kill the spearman about 1/2 of the time. But if I have a bunch of catapults I can bombard the poor spearman down to 1 hp. If I can do that, I will attack a 1hp spearman with my 6hp swordsmen. If I played an unmodded game and bombarded the 3hp spearman down to 1, I would only have a 3hp vs. 1hp advantage. Yes, catapults work most of the time unless you are bombarding a town or city (in which case they suck)!!!
     
  7. Lt. 'Killer' M.

    Lt. 'Killer' M. Deity

    Joined:
    Dec 5, 2001
    Messages:
    7,469
    and it goes on and on:

    Swordsmen attack hoplites, 3 vs. 3.3 and all vet. Ai wins all fight loosing a single HP on one Swordsman!

    the combat calc gives 0.1% for this!


    Then, as my turn proceeds, it takes an average of 1.7 Swordsmen to kill a defending, fortified, veteran Pike in a size 12 city :confused: I had counted on loosing lots!
     
  8. Suki

    Suki you will get nothing

    Joined:
    Oct 23, 2002
    Messages:
    509
    Location:
    canada
    @plume: but one thing I've noticed about civ 3 is that it doesn't start with a time based random seed I think this because I used to play above my level and found myself reloading a lot, I don't do it anymore, but I found that if I reloaded to right before I fought a battle or popped a hut the results would be exactly the same attack for attack unless I moved my units differently or changed something else first, which makes me think that the initial random seed in the discription you gave depends not on time but the state of the game

    and if my suggestion were true then this would almost be possible. I don't think the AI, as far as combat goes knows anything more than the combat calculator, if even that, if it had this foreknowledge it would be the equivalent of letting the AI use the reload cheat! which would be sick and wrong.

    @sumthinelse: adding more hitpoints makes it more statistical, and so in a longer run you expect the average more often. think of rolling a d6(6 sided die), you have euual chances of getting any of the numbers but on average you'll get 3.5. if you roll 2d6 you have a 6/36 chance to get a 7 but a 1/36 chance to get a 2 or 12, it still averages out to 7 but because there are more trials you expect the average more often.
     
  9. DANGERBOY

    DANGERBOY SCAdian Fencer

    Joined:
    Nov 5, 2002
    Messages:
    149
    The initial seed (as in, the first number) is generated by the time. Each subsequent action causes the RNG to move to the next number, which is based solely on the current one. For example, say I have 60 lists of numbers, one for each minute of the hour. At 23.2 minutes after the hour, I start up the RNG based upon list 24 (since I am in the 24th minute). After each action, I move to the next number on the list. Doesn't matter at this point what the time of day is, as long as I keep checking the same list and remember where I've stopped.

    That's essentially what a RNG is: a set of lists of numbers. Obviously, more complicated than that, I've kept it simple so I could understand myself (let alone other people understanding my babble).

    If you uncheck the 'Preserve Random Seed' flag at the game set-up screen, you start a new 'list' every time you reload.
     
  10. Lt. 'Killer' M.

    Lt. 'Killer' M. Deity

    Joined:
    Dec 5, 2001
    Messages:
    7,469
    anarres: about the AI knowing the future RNG results: it might know the next result (i.e. the seed atm), but then it would need to be programed to make suicide attacks..... still, it is kinda strange! I see the AI using Spearmen to cover Archers all the time. Suddenly a lone Archer approaches my city. Surprise, surprise, two 4 HP Med Inf die trying to kill him (1.9% each). Why oh why does the Ai NEVER expose Archers - but did in this case????? BTW, reloading and not attacking saw the Archer easily take out my fortified Pikeman in the city :(
     
  11. barron of ideas

    barron of ideas Barron

    Joined:
    Nov 7, 2002
    Messages:
    695
    Location:
    Seattle, WA
    With dice, I think there is an ESP factor, you can call them and get the number you want. Or a bunch of people can control them to avoid you getting the number you want. This may be off topic, but I saw a friend in Colonial miniatures game take a critical hit on a steamboat, he needed a six to patch it, and due to the way the game was designed had something like 50 dice to roll to get just one six. And, Mike didn't. And he kept rolling atleast another 50 times and did not get a single six. This is way beyond normal, so I attribute it to someone controlling the dice mentally.
     
  12. sumthinelse

    sumthinelse civ investigator

    Joined:
    Mar 20, 2002
    Messages:
    1,333
    Location:
    Austin Texas USA
    I get 0.9% for one swordsman winning without losing a single hit point, 0.06% for all 3 winning without losing any hps. I'd like to see a saved game.

    "An average of 1.7 Swordsmen ...." You are testing this many times I guess? How many times did you retry this? I would expect to lose about 10 swordsmen.

    This is a good argument for increasing the hit points.
     
  13. Lt. 'Killer' M.

    Lt. 'Killer' M. Deity

    Joined:
    Dec 5, 2001
    Messages:
    7,469
    sumthinelse: 3 defenders, 5 attackers killed = roughly 1.7 dead attackers per dead defender. Just listing what happened in that game.

    the swordsmen: it doesn't much matter in this range (below 1%) so I chose the defenders as an army.


    This shows what i once started to test, but never finished (and picked up now): a combat test where I'd write down the probabilites of wins and losses (not caring for HP) of all fights. I got long strings of <20% results, then long strings of >65% - showing that sometimes it goes pretty much as expected (especially when you plan properly) but often the luck is extremely strong. Like when I get a 3,7,15,2,18 % win prob string and win all!
     
  14. TheNiceOne

    TheNiceOne Emperor

    Joined:
    Feb 6, 2002
    Messages:
    1,372
    Location:
    Norway
    Now this is an idea I like. This will keep the combat random (as it should be), it will keep the result in one battle totally independant from results in another battle (which is important IMO), but it will make consentration of force more important. One unit should become tired if sustaining many attacks.

    Now, such a change would skew the combat results in favour of the attacker, but this could easily be balanced by increasing all terrain defense bonuses by 10-15% or so.
     
  15. Pongui

    Pongui Deity

    Joined:
    Apr 30, 2002
    Messages:
    4,342
    A RNG nudge might be OK if it was applied inversely to the other civ, and not directly returnable. Say civ A gets a streak of strangely good luck against B. B then gets a RNG credit, which has a slight chance of being spent every time B attacks a civ other than A, say C. Maybe that credit is enough to turn B's ordinary good luck qualify as strangely good - then C would get a credit to use against A, D, or E. The nudge would have to be low enough not to spread credits rampantly.
     
  16. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    Just an exploit waiting to happen.

    Can you imagine the carnage the top playes could have with this?

    I bet Firaxis thought they were being clever when they played with the odds for getting settlers and free techs from goody huts for expansionist civs. Now it is just one big exploit, except it can't be called that as it is very intentional behaviour.

    Tweaking the odds under certain circumstances is dodgy. Very dodgy.
     
  17. sumthinelse

    sumthinelse civ investigator

    Joined:
    Mar 20, 2002
    Messages:
    1,333
    Location:
    Austin Texas USA
    About transferring the RNG boost to combat against another civ:

    I agree.

    About giving a RNG boost only in a local situation:

    For example: I am attacking with a stack of 20 vet modern armor tanks and 1 elite modern armor against fortified mech infantry. I wait until I have a string of bad luck and then attack with the elite.

    Here is an example from what we call "football" in America: The offense has 4 chances to advance the ball 10 yards, and if they succeed they get 4 more chances. What if they decided to change the rules so that: if the offense loses some yards on one play they get more yards on the next play? This would "smooth" the statistics but I think the game would actually become boring because it would cheapen the value of scoring by making it easier.

    :confused: Are you sure about this? 95% of the posters on this forum have posted confidently that expansionist is the weakest civ trait (I don't think it's that simple -- I think they are very good on a huge panageia). What are you talking about? Do you in fact know the odds for settler and tech on each difficulty level? If you do I would like to see those numbers.
     
  18. Four Four Seven

    Four Four Seven Spearman

    Joined:
    Feb 20, 2002
    Messages:
    83
    Location:
    Massachusetts, USA
    But, in a way, this already happens!

    Think of it this way - I send a swordsman against your 4hp spearman. One of three things will happen to your spearman:
    1) I kill your spearman.
    2) I lose the battle, but cause damage
    3) I lose the battle, and cause no damage.

    Whenever #2 occurs, your defensive rating essentially already does go down! Not for an individual round, but for the next battle as a whole.

    When #3 occurs (a rout, so to speak), I don't think it makes any sense to have a defensive rating go down. You demolished my unit with no casualties! Why should your unit be worse at defending when the next army comes along. If anything, they should be BETTER with more experience (and, this is reflected nicely with promotions to veteran or elite).

    I just don't think your solution makes sense, even as way to make the game more "realistic" . I don't think you can make the argument "but all my units are attacking simultaneously," if you consider the length of a turn is from 1 to 20 years. If you want your units to attack simultaneously, they need to be in an army. And, in that case, your chance of victory is MUCH higher!

    This is a fun discussion!
     
  19. willebra

    willebra Chieftain

    Joined:
    Dec 4, 2002
    Messages:
    10
    Location:
    Finland
    I think the odds for three regular swordmen winning when attacking a fortified regular spearman in a city on grassland is higher than that.

    You get approximately 4/5 or 80% if you assume that the spearman, buff, heals to full hitpoints after each attack (0,60*0,60*0,60, always starting each fight with three hitpoints, even if the previous one was won 2-0 or 1-0), but in the game the spearman won't do that (the turn must pass). The spearman 'remembers' the results of earlier combat rounds by losing hitpoints.

    The correct odds should be approx 93% for the swordmen to win (either 9-0 or 1-0 or anything in between) and 7 % for the spearman (most probable being winning with one hitpoint remaining, some 4%).

    By increasing the hitpoints, the more probable result will become even more probable. However, you must look at the total result (the probablity for the three swordmen together winning). It is more probable for one spearman to win one swordsman in these conditions than the other way around. However, it is more probable that the three swordmen attacking all at the same turn will win (at least one of them) than that the spearman will win.

    If you increase the hitpoints of all involved by the same proportional amount, the result which is more probable will become even more probable, thus you 'smooth' things out.

    Increasing hitpoints will make (i) the one spearman - one swordman combat better for the spearman but (ii) the one spearman - three swordmen combat better for the swordmen.
     
  20. willebra

    willebra Chieftain

    Joined:
    Dec 4, 2002
    Messages:
    10
    Location:
    Finland
    fourfourseven:
    I agree, the hitpoints do already the remembering. You can alter the amount of remembering by increasing/decreasing hitpoints of all units.

    Armies: isn't it so that fighting in armies doesn't actually increase the chances of victory? I tought the armies only change the order in which the lost hitpoints are substracted from the units within the army. So you have better chances of not losing units, if you win the battle as a whole. However the total chance of winning or losing with three units stays the same (if you win by 3-0 or more, you won't lose any units, which is nice...and wouldn't happen without the army).
     

Share This Page