Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Dampe
- {
- class Program
- {
- static long wins = 0;
- const decimal pG = 0.4m;
- const decimal pB = 0.3m;
- const decimal pR = 0.2m;
- const decimal pP = 0.1m;
- static decimal[] results = new decimal[16];
- static decimal[] droprule = new decimal[16];
- static long dropruleTotal = 0;
- static void Main(string[] args)
- {
- PlayDampe(0, 1, 0, 0, 0);
- decimal sum = 0;
- decimal dropruleSum = 0;
- Console.WriteLine("Dig : Cumulative : Individual : Rule Cumulative : Rule Individual");
- for (int i = 1; i < 16; i++)
- {
- sum += results[i];
- dropruleSum += droprule[i];
- Console.WriteLine($"{i:D2}: {sum:F16} : {results[i]:F16} : {dropruleSum:F16} : {droprule[i]:F16}");
- }
- Console.WriteLine($"I won {wins} times. Guaranteed Drop hit {dropruleTotal} times");
- Console.WriteLine($"Garanteed Rule {dropruleSum}");
- Console.ReadLine();
- }
- private static void PlayDampe(int depth, decimal odds, int green, int blue, int red)
- {
- //start with no digs
- if (green > 8)
- {
- wins++;
- results[depth] += odds;
- droprule[depth] += odds;
- dropruleTotal++;
- return;
- }
- //let's dig
- depth++;
- //if red
- if (red < 2)
- PlayDampe(depth, odds * pR, green, blue, red + 1);
- else
- PlayDampe(depth, odds * pR, green + 1, blue, red);
- //if blue
- if (blue < 4)
- PlayDampe(depth, odds * pB, green, blue + 1, red);
- else
- PlayDampe(depth, odds * pB, green + 1, blue, red);
- //if green
- PlayDampe(depth, odds * pG, green + 1, blue, red);
- //if grand prize
- if (depth > 0)
- {
- wins++;
- results[depth] += odds * pP;
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement