UNFINISHED Implemented procedural dice generation. Way too hard
This commit is contained in:
parent
ea1ca7a0cd
commit
03f0f7859e
43 changed files with 13909 additions and 57 deletions
13
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/.gitignore
generated
vendored
Normal file
13
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/.idea.DiceProbabilities.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
8
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/indexLayout.xml
generated
Normal file
8
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/indexLayout.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/vcs.xml
generated
Normal file
6
DiceProbabilities/.idea/.idea.DiceProbabilities/.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
4
DiceProbabilities/DiceProbabilitesPrinter/Program.cs
Normal file
4
DiceProbabilities/DiceProbabilitesPrinter/Program.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
using DiceProbabilities;
|
||||
|
||||
Console.WriteLine(DiceRollProbability.RollFourPickTwoPickTwoAgainOdds());
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"DiceProbabilitesPrinter/1.0.0": {
|
||||
"dependencies": {
|
||||
"DiceProbabilities": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"DiceProbabilitesPrinter.dll": {}
|
||||
}
|
||||
},
|
||||
"DiceProbabilities/1.0.0": {
|
||||
"runtime": {
|
||||
"DiceProbabilities.dll": {
|
||||
"assemblyVersion": "1.0.0",
|
||||
"fileVersion": "1.0.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"DiceProbabilitesPrinter/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"DiceProbabilities/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net9.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
129
DiceProbabilities/DiceProbabilities/RollFourSumTwo.cs
Normal file
129
DiceProbabilities/DiceProbabilities/RollFourSumTwo.cs
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DiceProbabilities
|
||||
{
|
||||
public static class RollFourSumTwo
|
||||
{
|
||||
public static readonly Dictionary<string, float> ResultOddsmapping = new Dictionary<string, float>()
|
||||
{
|
||||
{"=", .6296f },
|
||||
{"2", .1319f},
|
||||
{"3", .2330f},
|
||||
{"4", 3557f},
|
||||
{"5", .4475f},
|
||||
{"6", .5610f},
|
||||
{"7", .6435f},
|
||||
{"8", .5610f},
|
||||
{"9", .4475f},
|
||||
{"10", .3557f},
|
||||
{"11", .2340f},
|
||||
{"12", .1319f}
|
||||
|
||||
};
|
||||
|
||||
public static float GetProbalityOfAtleastOneUnlocking(List<string> options)
|
||||
{
|
||||
float probabilityNoDiceWillSumToLocks = 1;
|
||||
foreach (var option in options)
|
||||
{
|
||||
if (ResultOddsmapping.TryGetValue(option, out var value))
|
||||
{
|
||||
probabilityNoDiceWillSumToLocks *= (1 - value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"{option} is not a valid result for the sum of two dice.");
|
||||
}
|
||||
}
|
||||
|
||||
return 1 - probabilityNoDiceWillSumToLocks;
|
||||
}
|
||||
|
||||
public static string RollFourPickTwoPickTwoAgainOdds()
|
||||
{
|
||||
// Total number of rolls (6^4 = 1296 possible outcomes)
|
||||
int possibleDiceCombosCount = 0;
|
||||
|
||||
// Counter for the possible sums
|
||||
Dictionary<(string, string), int> selectionsCounts = new Dictionary<(string, string), int>();
|
||||
double diceEqualCount = 0;
|
||||
|
||||
// Generate all possible rolls of 4 dice
|
||||
for (int d1 = 1; d1 <= 6; d1++)
|
||||
{
|
||||
for (int d2 = 1; d2 <= 6; d2++)
|
||||
{
|
||||
for (int d3 = 1; d3 <= 6; d3++)
|
||||
{
|
||||
for (int d4 = 1; d4 <= 6; d4++)
|
||||
{
|
||||
// Get all possible pairs of dice
|
||||
var possibleDiceSlections = new List<((int, int), (int, int))>
|
||||
{
|
||||
((d1, d2), (d3, d4)), ((d1, d3), (d2, d4)), ((d1, d4), (d2, d3)),
|
||||
((d2, d3), (d1, d4)), ((d2, d4), (d1, d3)),
|
||||
((d3, d4), (d1, d2))
|
||||
};
|
||||
|
||||
foreach (((int, int), (int, int)) selections in possibleDiceSlections)
|
||||
{
|
||||
possibleDiceCombosCount++;
|
||||
var firstSelection = selections.Item1;
|
||||
var secondSelection = selections.Item2;
|
||||
string firstSelectionResult;
|
||||
string secondSelectionResult;
|
||||
if (firstSelection.Item1 == firstSelection.Item2)
|
||||
{
|
||||
firstSelectionResult = "=";
|
||||
if (secondSelection.Item1 == secondSelection.Item2)
|
||||
{
|
||||
secondSelectionResult = "=";
|
||||
IncrementSelectionsCounts(selectionsCounts, (firstSelectionResult, secondSelectionResult));
|
||||
}
|
||||
|
||||
secondSelectionResult = (secondSelection.Item1 + secondSelection.Item2).ToString();
|
||||
IncrementSelectionsCounts(selectionsCounts, (firstSelectionResult, secondSelectionResult));
|
||||
}
|
||||
|
||||
firstSelectionResult = (firstSelection.Item1 + firstSelection.Item2).ToString();
|
||||
if (secondSelection.Item1 == secondSelection.Item2)
|
||||
{
|
||||
secondSelectionResult = "=";
|
||||
IncrementSelectionsCounts(selectionsCounts, (firstSelectionResult, secondSelectionResult));
|
||||
}
|
||||
|
||||
secondSelectionResult = (secondSelection.Item1 + secondSelection.Item2).ToString();
|
||||
IncrementSelectionsCounts(selectionsCounts, (firstSelectionResult, secondSelectionResult));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Sum\tProbability (%)" + Environment.NewLine);
|
||||
|
||||
// sb.Append($"=\t{diceEqualCount / possibleDiceCombosCount * 100:F2}%{Environment.NewLine}");
|
||||
foreach (var selections in selectionsCounts.Keys)
|
||||
{
|
||||
double probability = (double)selectionsCounts[selections] / possibleDiceCombosCount * 100;
|
||||
sb.Append($"{selections}\t{probability:F2}%{Environment.NewLine}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void IncrementSelectionsCounts(Dictionary<(string, string), int> dict, (string, string) key)
|
||||
{
|
||||
if (!dict.ContainsKey(key))
|
||||
{
|
||||
dict[key] = 0;
|
||||
}
|
||||
|
||||
dict[key]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETStandard,Version=v2.0/",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETStandard,Version=v2.0": {},
|
||||
".NETStandard,Version=v2.0/": {
|
||||
"DiceProbabilities/1.0.0": {
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "2.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"DiceProbabilities.dll": {}
|
||||
}
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/1.1.0": {},
|
||||
"NETStandard.Library/2.0.3": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"DiceProbabilities/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/1.1.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
|
||||
"path": "microsoft.netcore.platforms/1.1.0",
|
||||
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
|
||||
},
|
||||
"NETStandard.Library/2.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
|
||||
"path": "netstandard.library/2.0.3",
|
||||
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
13
DiceProbabilities/Roll4Add2.txt
Normal file
13
DiceProbabilities/Roll4Add2.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Sum Probability (%)
|
||||
= 62.96%
|
||||
2 13.19%
|
||||
3 23.30%
|
||||
4 35.57%
|
||||
5 44.75%
|
||||
6 56.10%
|
||||
7 64.35%
|
||||
8 56.10%
|
||||
9 44.75%
|
||||
10 35.57%
|
||||
11 23.40%
|
||||
12 13.19%
|
||||
145
DiceProbabilities/Roll4Add2AddOther2.txt
Normal file
145
DiceProbabilities/Roll4Add2AddOther2.txt
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
Sum Probability (%)
|
||||
(=, =) 2.78%
|
||||
(=, 2) 0.46%
|
||||
(2, =) 0.46%
|
||||
(2, 2) 0.08%
|
||||
(=, 3) 0.93%
|
||||
(2, 3) 0.15%
|
||||
(3, =) 0.93%
|
||||
(3, 2) 0.15%
|
||||
(=, 4) 1.39%
|
||||
(2, 4) 0.23%
|
||||
(4, =) 1.39%
|
||||
(4, 2) 0.23%
|
||||
(=, 5) 1.85%
|
||||
(2, 5) 0.31%
|
||||
(5, =) 1.85%
|
||||
(5, 2) 0.31%
|
||||
(=, 6) 2.31%
|
||||
(2, 6) 0.39%
|
||||
(6, =) 2.31%
|
||||
(6, 2) 0.39%
|
||||
(=, 7) 2.78%
|
||||
(2, 7) 0.46%
|
||||
(7, =) 2.78%
|
||||
(7, 2) 0.46%
|
||||
(3, 3) 0.31%
|
||||
(3, 4) 0.46%
|
||||
(4, 3) 0.46%
|
||||
(3, 5) 0.62%
|
||||
(5, 3) 0.62%
|
||||
(3, 6) 0.77%
|
||||
(6, 3) 0.77%
|
||||
(=, 8) 2.31%
|
||||
(2, 8) 0.39%
|
||||
(3, 7) 0.93%
|
||||
(7, 3) 0.93%
|
||||
(8, =) 2.31%
|
||||
(8, 2) 0.39%
|
||||
(4, 4) 0.69%
|
||||
(4, 5) 0.93%
|
||||
(5, 4) 0.93%
|
||||
(4, 6) 1.16%
|
||||
(6, 4) 1.16%
|
||||
(=, 9) 1.85%
|
||||
(2, 9) 0.31%
|
||||
(4, 7) 1.39%
|
||||
(7, 4) 1.39%
|
||||
(9, =) 1.85%
|
||||
(9, 2) 0.31%
|
||||
(5, 5) 1.23%
|
||||
(5, 6) 1.54%
|
||||
(6, 5) 1.54%
|
||||
(=, 10) 1.39%
|
||||
(2, 10) 0.23%
|
||||
(5, 7) 1.85%
|
||||
(7, 5) 1.85%
|
||||
(10, =) 1.39%
|
||||
(10, 2) 0.23%
|
||||
(6, 6) 1.93%
|
||||
(=, 11) 0.93%
|
||||
(2, 11) 0.15%
|
||||
(6, 7) 2.31%
|
||||
(7, 6) 2.31%
|
||||
(11, =) 0.93%
|
||||
(11, 2) 0.15%
|
||||
(=, 12) 0.46%
|
||||
(2, 12) 0.08%
|
||||
(7, 7) 2.78%
|
||||
(12, =) 0.46%
|
||||
(12, 2) 0.08%
|
||||
(3, 8) 0.77%
|
||||
(8, 3) 0.77%
|
||||
(3, 9) 0.62%
|
||||
(4, 8) 1.16%
|
||||
(8, 4) 1.16%
|
||||
(9, 3) 0.62%
|
||||
(3, 10) 0.46%
|
||||
(5, 8) 1.54%
|
||||
(8, 5) 1.54%
|
||||
(10, 3) 0.46%
|
||||
(3, 11) 0.31%
|
||||
(6, 8) 1.93%
|
||||
(8, 6) 1.93%
|
||||
(11, 3) 0.31%
|
||||
(3, 12) 0.15%
|
||||
(7, 8) 2.31%
|
||||
(8, 7) 2.31%
|
||||
(12, 3) 0.15%
|
||||
(4, 9) 0.93%
|
||||
(9, 4) 0.93%
|
||||
(4, 10) 0.69%
|
||||
(5, 9) 1.23%
|
||||
(9, 5) 1.23%
|
||||
(10, 4) 0.69%
|
||||
(4, 11) 0.46%
|
||||
(6, 9) 1.54%
|
||||
(9, 6) 1.54%
|
||||
(11, 4) 0.46%
|
||||
(4, 12) 0.23%
|
||||
(7, 9) 1.85%
|
||||
(9, 7) 1.85%
|
||||
(12, 4) 0.23%
|
||||
(5, 10) 0.93%
|
||||
(10, 5) 0.93%
|
||||
(5, 11) 0.62%
|
||||
(6, 10) 1.16%
|
||||
(10, 6) 1.16%
|
||||
(11, 5) 0.62%
|
||||
(5, 12) 0.31%
|
||||
(7, 10) 1.39%
|
||||
(10, 7) 1.39%
|
||||
(12, 5) 0.31%
|
||||
(6, 11) 0.77%
|
||||
(11, 6) 0.77%
|
||||
(6, 12) 0.39%
|
||||
(7, 11) 0.93%
|
||||
(11, 7) 0.93%
|
||||
(12, 6) 0.39%
|
||||
(7, 12) 0.46%
|
||||
(12, 7) 0.46%
|
||||
(8, 8) 1.93%
|
||||
(8, 9) 1.54%
|
||||
(9, 8) 1.54%
|
||||
(8, 10) 1.16%
|
||||
(10, 8) 1.16%
|
||||
(8, 11) 0.77%
|
||||
(11, 8) 0.77%
|
||||
(8, 12) 0.39%
|
||||
(12, 8) 0.39%
|
||||
(9, 9) 1.23%
|
||||
(9, 10) 0.93%
|
||||
(10, 9) 0.93%
|
||||
(9, 11) 0.62%
|
||||
(11, 9) 0.62%
|
||||
(9, 12) 0.31%
|
||||
(12, 9) 0.31%
|
||||
(10, 10) 0.69%
|
||||
(10, 11) 0.46%
|
||||
(11, 10) 0.46%
|
||||
(10, 12) 0.23%
|
||||
(12, 10) 0.23%
|
||||
(11, 11) 0.31%
|
||||
(11, 12) 0.15%
|
||||
(12, 11) 0.15%
|
||||
(12, 12) 0.08%
|
||||
Loading…
Add table
Add a link
Reference in a new issue