Advertisement
mzxrules

Dampe Code

Jan 8th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Dampe
  4. {
  5.     class Program
  6.     {
  7.         static long wins = 0;
  8.         const decimal pG = 0.4m;
  9.         const decimal pB = 0.3m;
  10.         const decimal pR = 0.2m;
  11.         const decimal pP = 0.1m;
  12.         static decimal[] results = new decimal[16];
  13.         static decimal[] droprule = new decimal[16];
  14.         static long dropruleTotal = 0;
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             PlayDampe(0, 1, 0, 0, 0);
  19.             decimal sum = 0;
  20.             decimal dropruleSum = 0;
  21.  
  22.             Console.WriteLine("Dig : Cumulative : Individual : Rule Cumulative : Rule Individual");
  23.             for (int i = 1; i < 16; i++)
  24.             {
  25.                 sum += results[i];
  26.                 dropruleSum += droprule[i];
  27.                 Console.WriteLine($"{i:D2}: {sum:F16} : {results[i]:F16} : {dropruleSum:F16} : {droprule[i]:F16}");
  28.             }
  29.  
  30.             Console.WriteLine($"I won {wins} times. Guaranteed Drop hit {dropruleTotal} times");
  31.             Console.WriteLine($"Garanteed Rule {dropruleSum}");
  32.             Console.ReadLine();
  33.         }
  34.  
  35.         private static void PlayDampe(int depth, decimal odds, int green, int blue, int red)
  36.         {
  37.             //start with no digs
  38.             if (green > 8)
  39.             {
  40.                 wins++;
  41.                 results[depth] += odds;
  42.                 droprule[depth] += odds;
  43.                 dropruleTotal++;
  44.                 return;
  45.             }
  46.  
  47.             //let's dig
  48.             depth++;
  49.             //if red
  50.             if (red < 2)
  51.                 PlayDampe(depth, odds * pR, green, blue, red + 1);
  52.             else
  53.                 PlayDampe(depth, odds * pR, green + 1, blue, red);
  54.  
  55.             //if blue
  56.             if (blue < 4)
  57.                 PlayDampe(depth, odds * pB, green, blue + 1, red);
  58.             else
  59.                 PlayDampe(depth, odds * pB, green + 1, blue, red);
  60.  
  61.             //if green
  62.             PlayDampe(depth, odds * pG, green + 1, blue, red);
  63.  
  64.             //if grand prize
  65.             if (depth > 0)
  66.             {
  67.                 wins++;
  68.                 results[depth] += odds * pP;
  69.                 return;
  70.             }
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement