@shifty:
What kind of “program” are you writing? What equation/algorithm are you using?
It’s written in BlitzMax. The source below should (hopefully :)) not be too hard to understand - if you have questions, feel free to ask:
' Compares 2nd ed. A&A tech dev cost/rate with Anniv. ed. A&A ' 20 turns to test; record turn number that a total of 2 breakthroughs were achieved. Test 1 & 2 rolls/turn. ' If two breakthroughs aren't achieved, "turn 0" is recorded (ignored for graphing & turn average) ' (When going for two breakthroughs, two aren't achieved in about 2% for both 2nd and Anniv.) Strict Local breakthroughs, totalCost, turn, totalTurns Local answer[21], prefix$, graph$ Local breakthroughLimit = 2 For Local rolls = 1 To 2 ' actual rolls for 2nd Ed, Researchers for Anniv. Print;Print; Print rolls + " Tech Roll(s)/Researcher(s) per Turn:" Print; Print "2nd Edition" totalCost = 0 totalTurns = 0 For Local c = 0 To 20 answer[c] = 0 Next For Local test = 1 To 100000 ' a hundred thousand tests for accuracy breakthroughs = 0 turn = 0 While breakthroughs < breakthroughLimit And turn <= 20 turn :+ 1 totalCost :+ rolls * 5 ' each roll costs 5 IPCs For Local c = 1 To rolls If Rand(6) = 6 Then breakthroughs :+ 1 Next Wend totalTurns :+ turn If turn > 20 Then answer[0] :+ 1 Else answer[turn] :+ 1 EndIf Next ' display results For Local c = 1 To 20 graph = "" ' divide results by 1000 so each asterisk represents one percent For Local cc = 1 To Int(answer[c]/1000.0 + .5) graph :+"*" Next If c < 10 Then prefix = " " Else prefix ="" ' extra space for single digits Print prefix + c + " " + graph Next Print "Avg turn = " + totalTurns / 100000.0 Print "Avg cost = " + totalCost / 100000.0 Print; Print "Anniversary Edition" totalCost = 0 totalTurns = 0 For Local c = 0 To 20 answer[c] = 0 Next Local researchers ' researchers accumulate from turn to turn For Local test = 1 To 100000 researchers = 0 breakthroughs = 0 turn = 0 While breakthroughs < breakthroughLimit And turn <= 20 turn :+ 1 totalCost :+ rolls * 5 ' each researcher costs 5 IPCs researchers :+ 1 * rolls ' accumulate 1 researcher per "roll" Local success For Local c = 1 To researchers If Rand(6) = 6 Then success = True ' only one regardless of # of sixes rolled Next If success Then researchers = 0 ' eliminate accumulated researchers when successful breakthroughs :+ 1 EndIf Wend totalTurns :+ turn If turn > 20 Then answer[0] :+ 1 Else answer[turn] :+ 1 EndIf Next ' display results For Local c = 1 To 20 graph = "" ' divide results by 1000 so each asterisk represents one percent For Local cc = 1 To Int(answer[c]/1000.0 + .5) graph :+"*" Next If c < 10 Then prefix = " " Else prefix ="" ' extra space for single digits Print prefix + c + " " + graph Next Print "Avg turn = " + totalTurns / 100000.0 Print "Avg cost = " + totalCost / 100000.0 NextI release it into the public domain (modify it as desired/convert it to the language of your choice). breakthroughLimit is initially set for 2, which generated the first set of graphs in this thread (I hand-rounded the accuracy to a single decimal place when copy/pasting results in the thread). Setting it to 1 (i.e. stopping after getting one breakthrough) produced the second set above. I also made another, slightly tweaked version to generate the “only buy Researchers on turn 1” version for wodan46.