@djensen:
I would like to see a true odds calculator. The problem is that my math is rusty and I’m not sure how to handle complex probability calculations such as would be required for Axis & Allies.
Anybody good with probability computations? I just need help with the math.
I have already figured out that a true odds calculator should use memoization otherwise large complex battle computations will take as long as a dice simulator. (Memoization is basically caching results of previous calls to a function for future use, it’s perfect for these math related operations).
Honestly, I dunno wat a “memoization” is.
I will say tho that large complex battle computations take a lot LONGER than a dice simulator.
Me am Dice Simulator. Me say “You hit twice.”
Me am Large Complex Battle Computer. Me say “You hit 20%. You miss 30%. Ur enemy hits 15%. 35% of time scenario repeats.”
Here’s wat u do (simple)
First you get Microsoft Excel and someone that knows how to plug in formulas and stuff and use concatenation etc. Then you put the first 100 or so lines of Pascal’s triangle into a big array of arrays. (So the first array element of the array of arrays will be “1”, the next will be “1, 1”, the next will be “1, 2, 1”)
You need to do this because it cuts down on calculation time a lot.
Then you write the bit that gets the user input.
Then you split the user input into types. Like, let’s say that the user input is “3 infantry 1 tank attacking 2 infantry”. You split that into “3 attacking infantry”, “1 attacking tank”, and “2 defending infantry”.
Then you use Pascal’s triangle to generate a list of possible outcomes for each of those types. Like let’s say you attack with 3 infantry. You have a (1/6) ^ 3 to hit 3 times, a 2 * ((1/6)^2*(5/6)) to hit 2 times, a 2 * ((1/6)*(5/6)^2) to hit 1 time, and a (5/6) ^ 3 to hit 0 times. You can see the Pascal’s triangle element; “1, 2, 2, 1” here. (You can use combination mathematics, but just making a fat Pascal’s triangle array is a lot more efficient on calculation time).
Okay, so once you have a list of possible outcomes for each of those types, you multiply the attackers list together (and give the appropriate output), and then you multiply the defenders list together (and give the appropriate output).
Now, there’s a certain probability that nobody will get a hit. If you want to rerun the battle if nobody gets a hit on the first round, or report the result, whatever. But realize that you can’t ask the program to “resolve” an unresolvable battle. If you don’t write in something to account for the probability that nobody gets a hit, you could stick your program into an infinite loop.
Easiest way to do it is to make each probability outcome fraction (use fractions, not percentages for in-program calculation) have a common denominator. Then you whack out the probability of all missing, and add up the remaining numerators to get a single denominator.
I’d do it myself, but I need nekid Jen pix for inspiration . . .
Got it. That is a handy shortcut.