amazing odds

My head hurts.

That's why I just skip over the posted algorithms. If the poker thing is confusing, then it's much more easily understood. I translate RNG's into decks, battles into hands, combatants into cards, etc. Much easier to follow, and you still get incredibly bad/good odds situations, although you'll never get worse than approximately 3% in Texas Hold'em. Makes going all in a little less insane. :shifty:
 
If you have odds of 99/100, and run a hundred billion tests, at some point you'll lose 100 times in a row. This is true whether you have a terrible RNG or a superb RNG. Hence the quality of the random number generator is fairly academic IMO. It's not worth implementing a really meaty RNG system for a meaningless PC game. If Civ was an online poker game, then yep. But a leisurely TBS? Why bother?

The chances of losing a 99% battle 100 times in a row is 1 out of 10^200. A hundred billion is only 10^11, or 10^14 in some parts of the world. Doesn't make it that likely in that many tests.
 
If you have odds of 99/100, and run a hundred billion tests, at some point you'll lose 100 times in a row. This is true whether you have a terrible RNG or a superb RNG. Hence the quality of the random number generator is fairly academic IMO. It's not worth implementing a really meaty RNG system for a meaningless PC game. If Civ was an online poker game, then yep. But a leisurely TBS? Why bother?
except that it's wrong (welnic said why) from a mathematical point of view, it only happens if the tables include this streak.

Are the tables meant to show the one out of 10^200 situations?
It would mean that there are enough numbers in the table to show ALL the 10^200 possible situations.
If it's not so, it's not correct mathematically.

I have the feeling that
- the tables are not meant to show those really rare situations
- the long streaks (good or bad) happen more often than they should.

At some points, I attack with 10% odds being really confident that I will win. It's not random enough IMHO.
 
Sometimes the random generator just frustrates everybody I guess. I just lost a 99,6% fight yesterday. That made me scream as it was one of my best units. I also get the feeling that AI catapults/trebuchets retreat more often then mine. But it is just the feeling because the bad feelings tend to stick more in your mind.

I am always amazed at how many times their catapults get to withdraw compared to mine. For the longest time I was trying to figure out which combination of promotions woulf give me the best chancwe for withdrawl but then i just said it was probably just the computer ceating because their promotions seem really random.
 
Isn't it the case that the probability of winning a combat round is calculated from the original strengths of the combatants, not reworked for each round according to damage ? So if the odds are given as 90% then the chance of winning 5 successive rounds is indeed 0.9 ^ 5 or 0.59049.
But alas, the RNG is streaky. Yesterday I was on the point of winning: the last enemy city had only an unpromoted Longbowman and 40% defence, which I attacked with a Warlord Infantry with Combat 2 and City Raider 3 (upgraded from a Maceman), making strengths of 39 vs 9.9 and odds of >99.9% (the Combat Log showed 100%): the LB struck first, then my infantry, then came a string of 9 hits by the LB which killed my Warlord. Even at 0.1% the chance of 9 successive hits is 0.01 ^ 9 or 0. (seventeen zeros) 1. Somehow I wasn't too surprised, as all my Warlord units either lose battles even at high odds or get severely damaged and take ages to heal before they can fight again.
I...hate...the RNG......,the RNG...hates...me !
 
The question is a conditional probability problem. The probability of an event A given an event B occurs is P(A|B) = P(int(A,B))/P(B) where "int(,)" denotes intersection (of sets).

The event B is "winning at least 4", or X>=4 where X is the number of wins. The probability of event B, denoted P(B) is given by

P(B) = 0.9^5 + 5 * 0.9^4 * 0.1^1 = 0.91854 (X is a binomial random variable).

P(int(A,B)) = P(A AND B occur) = P(X>=4 and X=5) = P(X=5) = 0.9^5 = 0.59049

So P(A|B) = 0.59049 / 0.91854 = ~0.643

I don't disagree with that formula, but how are you calculating your event P(B)?

As stated P(B) represents 4 wins at 90% odds, which have a total probability of 0.9^4=0.6561.

The event P(int(A,B)) is clear, it means five wins out of five at 90% odds. So 0.9^5=0.59049.

P(A|B) = 0.59049/0.6561 = 0.9 or 90%,

This stands to reason, since original wording of question states that 4 wins are guaranteed, hence the fact that they are at 90% odds is irrelevent, the fact that they are won is already given. So only bit of information that is valid imo is that the last fight is at 90% odds.
 
i don't know if my game is ******** but i am repeditly losing when i have over 90% odds, in fact i lose more often than i win even with those odds every time. This is incredibly frusterating, in fact its more like cheating on the part of the computer. :mad:

I know it seems like a waste of resources when you lose but attacking at low odds can actually be a good strategy :eek: ... when you win of course ;)

See what I wrote some time ago in this thread Getting Great Generals up to 4.5 times faster than normal? discussing how to increase the number of GGs generated.

Winning battles at low odds gets more exp (and therefore more GGs) from the enemy troops you kill at the expense of losing more hammers.
 
I don't disagree with that formula, but how are you calculating your event P(B)?

As stated P(B) represents 4 wins at 90% odds, which have a total probability of 0.9^4=0.6561.

The event P(int(A,B)) is clear, it means five wins out of five at 90% odds. So 0.9^5=0.59049.

P(A|B) = 0.59049/0.6561 = 0.9 or 90%,

This stands to reason, since original wording of question states that 4 wins are guaranteed, hence the fact that they are at 90% odds is irrelevent, the fact that they are won is already given. So only bit of information that is valid imo is that the last fight is at 90% odds.

You're misunderstanding the question. P(B) is precisely what ParadigmShifter showed in this calculation: (the red part I changed)

ParadigmShifter said:
If there are 5 fights, and you win at least 4 of them, there are the following possibilities:

WWWWL, prob 0.9^4 * 0.1
WWWWW, prob 0.9^5
WWWLW, prob 0.9^4 * 0.1
WWLWW, prob 0.9^4 * 0.1
WLWWW, prob 0.9^4 * 0.1
LWWWW, prob 0.9^4 * 0.1

0.9^5 = 0.59049
0.9^4 * 0.1 = 0.06561. There are 5 of these

So prob(win at least 4 out of 5) = 0.59049 + 5 * 0.06561 = 0.91854 = 91.854%.

I said at least 4 wins out of 5 battles in the original question. This means you need to include the 6 cases that ParadigmShifter listed. This is just a binomial random variable. I'm not a maths teacher so I won't try to teach it, but here's a wiki that might get you started. I don't mean to offend, but this is something we covered in high school.

EDIT And by the way, if you don't disagree with the formula, you can't really disagree with the answer. The answer I gave is correct. Read the example I gave in the post where I gave the solution.
PieceOfMind said:
The answer (0.643) you could think of as follows:

Suppose someone made the experiment and lined up 5 attackers beside 5 defenders so that the combat odds were 90% in the attacker's favour. Suppose that person performs the experiment and records the 5 results (as win or loss). The order is actually irrelevant. Suppose I'm shown any 4 of these results. Further suppose all of these 4 results were successes (wins). Then if I were asked to guess the 5th result, I'd guess that it too would be a success and 64.3% of the time I would be correct.
 
Wow, high school must have changed since I was there.

The problem in my mind is that I come back to coin flipping...if you flipped a coin 4 times with heads, then what's the chance of a heads on the last flip? Uhhhh, 50%.

So if I have five battles, where 4 are given as being won, how can that affect the last battle at 90% odds? Or are you assuming we don't know the odds for each battle and thus are calculating them based on the evidence we see from the results of the first four alone...this is why people are misunderstanding your question, I think.

p.s. I don't know what you do for a living, but rest assured that in non-tech fields, your math skills will deteriorate very quickly - I was very good at math (and statistics), but find myself swimming against it now - mainly because you lose it without enough practice. So maybe drop down the condescension a notch, eh?
 
I do believe that I remember from University, it was a long time ago, that there is a difference between chance and probability. If you toss a coin one time the chance and probability for heads are the same, i.e 0,5. If you toss the coin again and the result from the first was heads the CHANCE for an additional head is 0,5 but the PROBABILITY is just 0,5*0,5 = 0,25.

Snow
 
You're misunderstanding the question. P(B) is precisely what ParadigmShifter showed in this calculation: (the red part I changed)

This is a correct calculation for 4 or more wins out of 5, but then you go ahead and stick it into the equation that assumes that event A is not subset of the set of event B, which is false because WWWWW scenario is already included in the event B.
 
There is a lot of controversy about Bayesian probability. This is the reason why.

I originally said 90% and am sticking by that IF you see all the battles as you go along. In the blind trials case, where you are told that 4+ out of 5 are winners, the other calculation is correct.
 
Fair ? the RNG is fair ?? Oh, ha ha.
I may possibly have had a Warlord unit win without taking vast damage, but although they do mostly win at >99.9% odds the poor things generally survive with 10 or less hit points and (being in enemy territory) take lots of turns to heal. As I've said elsewhere, I lost one Warlord to 9 successive hits by a Longbowman, their strengths being 39 to 9.9 which gives the LB 0.254 chance of winning a combat round and about 4 in a million of winning 9 in a row. I think that's the worst losing streak I've had, but it's far from the only one.
And not once, not one single time, have I had a "suicide" siege weapon (those whose attack is intended primarily for collateral damage) either win or withdraw, though the AI's have had much better "luck". I did have a Cavalry withdraw, once, the odds in its favour being 70% or so: it was, of course, horribly damaged and easily picked off by the AI in its turn.
I think the RNG should be renamed. How about YLS (You lose, sucker !) or NCH (No chance, human !) ? Or even BAP (biased against player ) ?
 
Wow, how did I miss this thread for so long. For those wondering, Piece of Mind is correct in his analysis and formulas. In many cases it is nice to write out what these letters stand for so people can more easily follow.

A = the event that you win all five battles
B = the event that you win at least four battles (this includes as a subset, event A)

From basic probability theory P(A|B)=P(A intersect B)/P(B).

In this case since A is a subset of B that simplifies to just P(A)/P(B). His calculation for what values P(A) and P(B) numerically hold is correct as is his final conclusion.

As to any controversy about Bayesian vs. frequentist. I am not an expert on this controversy, but I doubt any frequentist would claim that Bayes' theorem(we are using a basic form in the above formula) is not valid. This is not a controversial problem at all in any way.
 
Spoiler :
The question is a conditional probability problem. The probability of an event A given an event B occurs is P(A|B) = P(int(A,B))/P(B) where "int(,)" denotes intersection (of sets).

The event B is "winning at least 4", or X>=4 where X is the number of wins. The probability of event B, denoted P(B) is given by

P(B) = 0.9^5 + 5 * 0.9^4 * 0.1^1 = 0.91854 (X is a binomial random variable).

P(int(A,B)) = P(A AND B occur) = P(X>=4 and X=5) = P(X=5) = 0.9^5 = 0.59049

So P(A|B) = 0.59049 / 0.91854 = ~0.643


this is like calculating the odds of picking 5 red marbles, in 5 tries, from a bag that only contains one other non-red marble. right?

i understand the math. but why is it like that? what is the reason for the formula being that way?
 
this is like calculating the odds of picking 5 red marbles, in 5 tries, from a bag that only contains one other non-red marble. right?

i understand the math. but why is it like that? what is the reason for the formula being that way?

http://en.wikipedia.org/wiki/Bayes'_theorem

Wikipedia (the first place to go when looking for information on anything nowadays... just not the place where you stop looking) has a pretty good page on Bayes Theorem. I'm actually quite glad that this discussion happened since all I had for probability was high school probability and a very good ability to translate difficult questions into compound statement using AND, OR and NOT and the laws of logic .
(e.g. NOT[A AND B] == NOT[A] OR NOT. )

Bayes Theorem lets me take a lot of problems that I could previously solve and rework them in a much easier way. Now I don't have to do as much of the tedious translation and counting of possible cases, I can do the calculations more directly for oddball questions.

Also, you guys like poker? I used to play collectible card games and one of my hobbies there was helping people calculate the probability of getting whatever super-combo they were looking for in a set number of turns.

It's just like probabilities in poker, except you get to choose how many cards are in your deck (minimum of 30, 40 or 60 depending on what game you are playing), how many of each card is in your deck (maximum of 3 or 4 depending on the game) and many of the cards have an effect on the game state (like causing you to draw more cards per turn, allowing you to discard your hand to trade it in for a new hand with one fewer card, changing the maximum number of cards you can hold in your hand, etc).

I have to say, my wanderings through Wikipedia a few nights ago would have saved me a fair amount of number crunching over the last decade if I had known about them.


...and the kids in my class still ask me "When are we ever going to use this?" If you don't care about how things work in the world around you then you won't ever use the things I teach. If you want to be a complete human being with some understanding of the function of the universe, though, then you'll learn your algebra and maybe a little calculus and you'll pay attention when the teacher is explaining how (and why) a lever works and why things fall to the ground at different speeds.
 
haruntaiwan said:
Wow, high school must have changed since I was there.

The problem in my mind is that I come back to coin flipping...if you flipped a coin 4 times with heads, then what's the chance of a heads on the last flip? Uhhhh, 50%.

So if I have five battles, where 4 are given as being won, how can that affect the last battle at 90% odds? Or are you assuming we don't know the odds for each battle and thus are calculating them based on the evidence we see from the results of the first four alone...this is why people are misunderstanding your question, I think.

Let me be clear. This is how I could re-word the original question:

  • Let's say there are exactly 5 battles.
  • For each battle there are exactly two possible outcomes: win or loss (W or L)
  • The outcome W has probability 0.9. Hence L has probability 0.1.
  • You do not know the results of the battles. ie. blind as ParadigmShifter mentions.
  • For some reason or other, you are shown exactly 4 of the battle results.
  • We also assume all of these 4 battles had the outcome W. Note this does not mean the first 4 necessarily!
  • Then the question is what is the probability that all 5 results are W. Equivalently, the question is what is the probability that the remaining result (that you haven't yet seen) is a W.

harauntaiwan said:
p.s. I don't know what you do for a living, but rest assured that in non-tech fields, your math skills will deteriorate very quickly - I was very good at math (and statistics), but find myself swimming against it now - mainly because you lose it without enough practice. So maybe drop down the condescension a notch, eh?

haruntaiwan, I did say I have no intention to offend. I apologise if you are offended by what I say, but I try to be as frank as possible. Otherwise I'd ramble on for pages and pages, carefully wording things just so no one takes it personally. I'm not sure Napalm would have wanted me to sugar coat everything. And I said in an earlier post I'm a maths student - At the moment that's my living.

The statement for example about doing binomials in high school. I was under the impression it's probably one of the simplest cases to analyse in probability. Any basic course on probability would cover it. I don't want to have a go at anyone who hasn't studied it before - that would be unfair.

Please be understanding that mathematicians do need to be pedantic about their maths. Would you challenge a physicist over the correctness of the special theory of relativity? Would you challenge a chemist over the validity of the formula for water - H20? Perhaps you would like to challenge them, but in either case, both scientists have the right to defend their understandings as being correct - I would expect them to.

And to any physicists, yes I know you can't say relativity is "correct" but you know what I mean ;)

sno666 said:
I do believe that I remember from University, it was a long time ago, that there is a difference between chance and probability. If you toss a coin one time the chance and probability for heads are the same, i.e 0,5. If you toss the coin again and the result from the first was heads the CHANCE for an additional head is 0,5 but the PROBABILITY is just 0,5*0,5 = 0,25.

I wasn't aware of any real distinction between chance and probability, except that probability is defined more precisely I think. I assumed chance and probability (and odds too) were sort of synonymous. I don't think I agree with the way you say they're different though. I would say the chance and probability of 2 heads in a row is 0.25. Look up the gambler's fallacy. It applies here. If you toss one coin and it's heads, then the probability of getting a head on the next toss is still 0.5. I know you know this, but I'm not sure what you're trying to get at in your post.

Napalm102 said:
This is a correct calculation for 4 or more wins out of 5, but then you go ahead and stick it into the equation that assumes that event A is not subset of the set of event B, which is false because WWWWW scenario is already included in the event B.

Vale covered this. (thanks!) A is a subset of B. A = {(wwwww)} is a subset of {(wwwww),(wwwwl),(wwwlw),(wwlww),(wlwww),(lwwww)} = B

zooropa86 said:
this is like calculating the odds of picking 5 red marbles, in 5 tries, from a bag that only contains one other non-red marble. right?

Not quite. It's like picking 5 red marbles out of a bag which contains 9 red marbles and 1 blue marble, with replacements. You also need to assume a result is discarded if you do not pick at least 4 red marbles.

zooropa86 said:
i understand the math. but why is it like that? what is the reason for the formula being that way?

When we calculate a probability, we find the probability of getting a favourable outcome, and divide by the sum of the probabilities of all possible outcomes. For example, the probability of getting 2 heads in a row from 2 coin tosses is (0.25)/(0.25+0.25+0.25+0.25) = 0.25. There are four possible outcomes (HH, HT, TT, TH), each with probability 0.25. Explicitly this is P({HH}) / ( P({HH})+P({HT})+P({TH})+P({TT}) )
The confusion comes about because more often than not we are taking the probability of all possible outcomes to be 1, and we may mistakenly assume this. (technically it is true that the probability of all possible outcomes is 1, but for calculation’s sake it's not convenient) If I said, what is the probability of getting 2 heads in a row from 2 coin tosses, given that the first toss is a head, you'd calculate: (0.25)/(0.25 + 0.25)=0.5. Note now the two possible outcomes are HT and HH ie. we don't include TT and TH. If I said, what is the probability of getting 2 heads in a row given exactly one of the tosses returns a tail, you'd calculate (0.25)/(0.25+0.25)=0.5. Here the possible outcomes are HT and TH, each with probability 0.25. Now this is actually incorrect as you'd probably already realised. The reason this is incorrect is that getting HH is not possible from the outcomes HT and TH. Hence we need to take the intersection on the top, of the set {HT,TH} and {HH}. This intersection is of course empty, and so it's probability is 0. So in fact the correct calculation here would be 0/(0.25+0.25). This is a long winded way of saying it is impossible to get two heads from two coin tosses if one of them is a tail. The result is obvious, but the explicit calculation to get it is not.

An alternative way to understand the method is by means of normalization. We always expect the sum of the probabilities of all possible events to be 1. So if we discard some possible outcomes, then we must "renormalize" the probabilities of the remaining possible outcomes, by means of scaling, so that the sum becomes 1 again. This is the way I like to think of it.

Hopefully this coin tossing scenario has helped a bit. Anyway, I better stop ranting about this stuff because it has departed from the OP discussion a lot (not that there's a lot to go on from the OP).

So Vale, being the resident mathematician, do you happen to know how Civ4 calculates battle probabilities. I haven't even tried to begin to conjure up how the calculator would work, but your background on Bayesian versus frequentist etc. sounds like it might be handy :)

EDIT Oh, and I forgot to mention that conditional probability is something mathematician's have defined. It's defined the way it is so that it correlates with our intuitions, as is usually the case with mathematical definitions. This makes it a little bit harder to explain why it's true, because it's kind of true by definition. This is called arguing from the definition. It's like saying 1 + 1 = 2 because it is defined that way - not because of some absolute truth associated with it - though even mathematicians will tend to argue over this one, usually with philosophers :p. :lol: just noticed 1+1=2 is in Vale's avatar!

...also, minor correction (in red)
 
I'm assuming you are asking about how the number displayed when you hover over your target while in goto mode before combat is calculated. The actual combat resolution has been covered very well in one of the strategy articles and I will assume a basic knowledge of how that works in an explanation of how I would calculate those numbers if I were writing an algorithm for such.

I am not a computer scientist and wouldn't know how to even see the code to begin to decipher how firaxis actually does it so this is just a rough idea.

No first strikes case:

First, you need to determine several basic variables: attacker and defenders modified strength and their hit points. Using the formulas in the aforementioned article we can compute the probability of an attacker win on any given round (p), the related damage dA, the probability of a defender win on any given round (1-p) and the related damagedD. With the knowledge of the hit points, it is then possible to compute A, the number of hits the attacker needs to get before dying to kill the defender and D, the number of hits the attacker needs to get before dying to kill the attacker (This is just hitpoints divided by damage per hit and then rounded up).

So combat can only last at most A+D-1 rounds since after that many rounds, exactly one person is guaranteed to have killed their opponent. We don't care about overkill for the purposes of this calculation and this is just a binomial distribution with n=A+D-1 and p=p.
The probability that the attacker will win is P(x>=A) and this can be calculated easily by the computer since the minimum damage being 12 guarantees that n cannot possibly be bigger than 17. Lets just call the function that calculates the above probability for given values of p, A and D,
winrate(p, A, D) and I will refer to that function later. Also for purposes of later calculations, I will define winrate(p, A, D) = 1 whenever A<=0.

First strike case:

To be honest I'm not 100&#37; sure how the net number of first strikes is calculated if both attacker and defender have a non-integral number first strikes. The fair thing in my mind is that the fractions (consider 6-7 first strikes as 6.5) should cancel out as if they were integral, but it is possible that the game does something else. In any case thats not too relevant to the upcoming calculations since at the beginning we will assume that the net number of first strikes is an integral (no coin flips about number of first strikes) number of first strikes for the attacker (for all intents and purposes, once the game does the modified strength calculations, attacker and defender are the same so it is ok to assume the attacker is the one with the first strikes (if the defender has it, do the calculations and subtract the result from 1).

So assuming the attacker has f first strikes and keeping the meaning of p, A and D from before, things become much more complicated. The way I think might be reasonable to do it is to consider the binomial distribution Y with n=f and p=p and calculate the probabilities P(Y=0), P(Y=1),...,P(Y=f). Then the chance for an attackers win will be given by:

firststrikewinrate(p, f, A, D) = SUM {i=1,...f} [P(Y=i) winrate(p, A-i, D)] (this is why I defined winrate earlier for values of A less than 1).

Finally, if the number of first strikes is to be randomly determined, the game can calculate the probabilities for each particular number of bonus first strikes (assuming that the article I mentioned is right, this will again be a binomial distribution with p=.5 this time and n = the range between the minimum number of first strikes and the maximum number) and then do the sum of those probabilities multiplied by firststrikewinrate with the appropriate f plugged in for each call.

To reiterate, I don't know if this is actually how the game calculates things, but I am pretty certain that these would give the correct values assuming a true RNG.

After going through this, I'm somewhat surprised that people think the game may be having trouble calculating the probabilities for cases with first strikes. It isn't that much more complicated than the base case and I think most undergraduate students who have taken a computer science class could implement an algorithm based on the above that would calculate things accurately.
 
haruntaiwan, I did say I have no intention to offend. I apologise if you are offended by what I say, but I try to be as frank as possible. Otherwise I'd ramble on for pages and pages, carefully wording things just so no one takes it personally. I'm not sure Napalm would have wanted me to sugar coat everything. And I said in an earlier post I'm a maths student - At the moment that's my living.

Hey it's all good. It's not about being offended it is about understanding the results that you get. I'm trying to think of something that can explain what does the ~60&#37; result represents in practice. Needless to say I still have big issues with the way the problem is worded (4 or more wins out of possible 5). It's like you come into a room when someone is playing Civ and find out that 4 battles were just won at 90% odds and there is one more battle left at the same odds and for some reason the equation tells me I only have 60% chance to win?

edit: or rather based on the wording of the question this should be in the past tense. Someone who just had 5 battles at 90% odds tells me that 4 were won, and asks me to guess the outcome of the fifth. If I say Win then I only have 60% of getting it right? This just doesn't sit well with me.
 
Back
Top Bottom