diff --git a/BingoSlotDifferentialEvolutionOptimization.csproj b/BingoSlotDifferentialEvolutionOptimization.csproj
deleted file mode 100644
index b5ba39e..0000000
--- a/BingoSlotDifferentialEvolutionOptimization.csproj
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- Debug
- x86
- 10.0.0
- 2.0
- {CF73F52C-87A0-412A-A0DE-A3255711DA17}
- Exe
- BingoSlotDifferentialEvolutionOptimization
- BingoSlotDifferentialEvolutionOptimization
-
-
- true
- full
- false
- bin\Debug
- DEBUG;
- prompt
- 4
- true
- x86
-
-
- full
- true
- bin\Release
- prompt
- 4
- true
- x86
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/BingoSlotDifferentialEvolutionOptimization.sln b/BingoSlotDifferentialEvolutionOptimization.sln
deleted file mode 100644
index b84785d..0000000
--- a/BingoSlotDifferentialEvolutionOptimization.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BingoSlotDifferentialEvolutionOptimization", "BingoSlotDifferentialEvolutionOptimization.csproj", "{CF73F52C-87A0-412A-A0DE-A3255711DA17}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x86 = Debug|x86
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CF73F52C-87A0-412A-A0DE-A3255711DA17}.Debug|x86.ActiveCfg = Debug|x86
- {CF73F52C-87A0-412A-A0DE-A3255711DA17}.Debug|x86.Build.0 = Debug|x86
- {CF73F52C-87A0-412A-A0DE-A3255711DA17}.Release|x86.ActiveCfg = Release|x86
- {CF73F52C-87A0-412A-A0DE-A3255711DA17}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = BingoSlotDifferentialEvolutionOptimization.csproj
- EndGlobalSection
-EndGlobal
diff --git a/BingoSlotDifferentialEvolutionOptimization.userprefs b/BingoSlotDifferentialEvolutionOptimization.userprefs
deleted file mode 100644
index d42f3a9..0000000
--- a/BingoSlotDifferentialEvolutionOptimization.userprefs
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscreteDifferentialEvolution.cs b/DiscreteDifferentialEvolution.cs
deleted file mode 100644
index f76ede8..0000000
--- a/DiscreteDifferentialEvolution.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Globalization;
-
-namespace BingoSlotDifferentialEvolutionOptimization
-{
- class DiscreteDifferentialEvolution
- {
- public const long NUMBER_OF_RECOMBINATIONS = 100;
-
- public const int POPULATION_SIZE = 17;
-
- public const int NUMBER_OF_REELS = 5;
-
- public const int REEL_LENGTH = 63;
-
- private double targetRtp;
-
- private int symbolsDiversity;
-
- private double[] fitness = new double[ POPULATION_SIZE ];
-
- private int[][][] population = new int[POPULATION_SIZE][][];
-
- private int[][] offspring = null;
-
- private int targetIndex = -1;
-
- private int baseIndex = -1;
-
- private int aIndex = -1;
-
- private int bIndex = -1;
-
- private int bestIndex = -1;
-
- public void select ()
- {
- do {
- targetIndex = Util.prng.Next (population.Length);
- baseIndex = Util.prng.Next (population.Length);
- aIndex = Util.prng.Next (population.Length);
- bIndex = Util.prng.Next (population.Length);
- } while(targetIndex == baseIndex || targetIndex == aIndex || targetIndex == bIndex || baseIndex == aIndex || baseIndex == bIndex || aIndex == bIndex);
- }
-
- public void differs ()
- {
- int min = int.MaxValue;
- int max = int.MinValue;
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- offspring [i] [j] = population [aIndex] [i] [j] - population [bIndex] [i] [j];
- if (min > offspring [i] [j]) {
- min = offspring [i] [j];
- }
- if (max < offspring [i] [j]) {
- max = offspring [i] [j];
- }
- }
- }
-
- /*
- * Normalize.
- */
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- offspring [i] [j] -= min;
- if (min < max) {
- offspring [i] [j] = 3 * offspring [i] [j] / (max - min + 1) - 1;
- }
- }
- }
- }
-
- public void mutate ()
- {
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- offspring [i] [j] += population [baseIndex] [i] [j];
- }
- }
-
- /*
- * Validate reels.
- */
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- if (Symbols.isValid (offspring [i] [j]) == false) {
- offspring [i] [j] = Symbols.randomValid ();
- }
- }
- }
- }
-
- public void crossover ()
- {
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- if (Util.prng.NextDouble () < 0.5) {
- offspring [i] [j] = population [targetIndex] [i] [j];
- }
- }
- }
- }
-
- public void survive ()
- {
- SlotMachineSimulation simulation = new SlotMachineSimulation ();
- simulation.load (offspring);
- simulation.simulate ();
- double cost = simulation.costFunction (targetRtp, symbolsDiversity);
- if (cost < fitness [targetIndex]) {
- fitness [targetIndex] = cost;
- for (int i = 0; i < offspring.Length; i++) {
- for (int j = 0; j < offspring [i].Length; j++) {
- population [targetIndex] [i] [j] = offspring [i] [j];
- }
- }
- if (fitness [bestIndex] > fitness [targetIndex]) {
- bestIndex = targetIndex;
- }
- }
- }
-
- public void optimize ()
- {
- for (int r = 0; r < NUMBER_OF_RECOMBINATIONS; r++) {
- Stopwatch watch = Stopwatch.StartNew ();
- select ();
- differs ();
- mutate ();
- crossover ();
- survive ();
- watch.Stop ();
-
- if (Util.VERBOSE == true) {
- CultureInfo ci = new CultureInfo ("en-us");
- Console.WriteLine (this);
- Console.WriteLine ("{0}:{1}:{2}", ((int)watch.Elapsed.TotalHours).ToString ("D2", ci), ((int)watch.Elapsed.TotalMinutes % 60).ToString ("D2", ci), ((int)watch.Elapsed.TotalSeconds % 60).ToString ("D2", ci));
- }
- }
- }
-
- public DiscreteDifferentialEvolution (int[][] reels, double targetRtp, int symbolsDiversity)
- {
- if (reels.Length != NUMBER_OF_REELS) {
- Console.WriteLine ("Number of reals is incorrect!");
- return;
- }
-
- for (int i = 0; i < reels.Length; i++) {
- if (reels [i].Length != REEL_LENGTH) {
- Console.WriteLine ("Reel length is incorrect!");
- return;
- }
- }
-
- for (int p = 0; p < POPULATION_SIZE; p++) {
- population [p] = new int[NUMBER_OF_REELS] [];
- for (int i = 0; i < NUMBER_OF_REELS; i++) {
- population [p] [i] = new int[REEL_LENGTH];
- }
- }
-
- offspring = new int[NUMBER_OF_REELS] [];
- for (int i = 0; i < NUMBER_OF_REELS; i++) {
- offspring [i] = new int[REEL_LENGTH];
- }
-
- this.targetRtp = targetRtp;
- this.symbolsDiversity = symbolsDiversity;
-
- for (int p = 0; p < population.Length; p++) {
- for (int i = 0; i < reels.Length; i++) {
- for (int j = 0; j < reels [i].Length; j++) {
- population [p] [i] [j] = reels [i] [j];
- }
- }
- }
-
- /*
- * Move around, but keep the first unchanged.
- */
- for (int p = 1; p < population.Length; p++) {
- for (int i = 0; i < reels.Length; i++) {
- for (int j = 0; j < reels [i].Length; j++) {
- int q = Util.prng.Next (reels [i].Length);
- int swap = population [p] [i] [q];
- population [p] [i] [q] = population [p] [i] [j];
- population [p] [i] [j] = swap;
- }
- }
- }
-
- /*
- * Evaluate population fintess.
- */
- bestIndex = 0;
- for (int p = 0; p < population.Length; p++) {
- SlotMachineSimulation simulation = new SlotMachineSimulation ();
- simulation.load (population [p]);
- simulation.simulate ();
- fitness [p] = simulation.costFunction (targetRtp, symbolsDiversity);
- if (fitness [bestIndex] > fitness [p]) {
- bestIndex = p;
- }
- }
- }
-
- public override string ToString ()
- {
- string result = "";
-
- for (int p = 0; p < population.Length; p++) {
- if (p != bestIndex) {
- continue;
- }
-
- result += fitness [p];
- result += "\r\n";
- for (int i = 0; i < population [p].Length; i++) {
- result += "new int[] {";
- for (int j = 0; j < population [p] [i].Length; j++) {
- result += population [p] [i] [j];
- result += ",";
- //result += "\t";
- }
- result += "},";
- result += "\r\n";
- }
- }
-
- return result;
- }
- }
-}
diff --git a/Paytable.cs b/Paytable.cs
deleted file mode 100644
index 9c9085b..0000000
--- a/Paytable.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace BingoSlotDifferentialEvolutionOptimization
-{
- class Paytable
- {
- /**
- * Slot game paytable.
- */
- public static int[][] values = {
- new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- new int[]{ 0, 0, 0, 250, 100, 75, 50, 25, 15, 9, 6, 3, 1, 0, 0, 0, 0 },
- new int[]{ 0, 0, 0, 500, 250, 100, 75, 50, 25, 15, 10, 7, 3, 0, 0, 0, 0 },
- new int[]{ 0, 0, 0, 750, 500, 250, 150, 100, 75, 50, 30, 20, 10, 0, 0, 0, 0 },
- };
- }
-}
-
diff --git a/Program.cs b/Program.cs
index dc2ee6b..6108087 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,39 +1,63 @@
-
-using System;
+using System;
namespace BingoSlotDifferentialEvolutionOptimization
{
class MainClass
{
+ private static long NUMBER_OF_EXPERIMENTS = 1;
+
+ private static long NUMBER_OF_SIMUALTIONS = 1000000;
+
public static void Main (string[] args)
{
- int[][] reels = {
- new int[] { 7, 8, 7, 4, 3, 10, 3, 11, 10, 11, 4, 3, 11, 3, 6, 4, 8, 7, 4, 3, 12, 11, 8, 4, 8, 12, 11, 4, 4, 6, 7, 5, 7, 3, 3, 5, 6, 9, 5, 6, 9, 4, 12, 6, 7, 5, 12, 11, 10, 7, 8, 4, 4, 5, 10, 10, 5, 5, 6, 7, 9, 7, 9, },
- new int[] { 9, 5, 11, 10, 11, 12, 5, 8, 4, 4, 12, 8, 7, 6, 11, 4, 4, 6, 6, 12, 7, 6, 10, 8, 11, 9, 5, 11, 6, 12, 6, 3, 9, 11, 7, 3, 4, 6, 3, 7, 4, 5, 7, 12, 10, 6, 9, 4, 8, 3, 10, 4, 4, 7, 8, 7, 5, 12, 11, 3, 8, 5, 12, },
- new int[] { 10, 9, 3, 11, 6, 10, 6, 5, 3, 5, 11, 4, 9, 6, 10, 7, 4, 9, 12, 7, 12, 12, 9, 11, 11, 8, 9, 6, 7, 11, 7, 5, 11, 11, 3, 5, 4, 11, 6, 9, 6, 11, 5, 7, 3, 11, 10, 11, 8, 9, 10, 9, 4, 7, 5, 4, 3, 6, 8, 11, 7, 3, 5, },
- new int[] { 8, 4, 3, 7, 7, 11, 7, 5, 4, 11, 3, 11, 11, 5, 5, 9, 9, 10, 7, 6, 10, 12, 4, 10, 12, 10, 5, 7, 10, 8, 9, 12, 9, 7, 5, 3, 6, 7, 3, 8, 9, 6, 8, 11, 11, 4, 10, 11, 12, 12, 10, 6, 6, 12, 8, 12, 10, 5, 8, 7, 5, 4, 3, },
- new int[] { 5, 6, 5, 6, 11, 12, 4, 3, 7, 8, 3, 11, 5, 5, 8, 8, 9, 3, 7, 7, 11, 7, 10, 11, 11, 3, 11, 8, 7, 5, 7, 11, 4, 9, 6, 11, 11, 6, 9, 11, 5, 11, 7, 6, 8, 11, 12, 11, 8, 7, 5, 7, 3, 12, 12, 6, 8, 10, 5, 11, 5, 9, 4, },
+ int[][] reels = { new int[] {
+ 3, 3, 3,
+ 4, 9, 7, 5, 9, 11, 9, 4, 4, 8, 6, 5, 11, 11, 4, 11, 6, 5, 11, 4, 5,
+ 9, 5, 11, 4, 11, 8, 7, 4, 10, 6, 4, 6, 9, 5, 7, 7, 12, 11, 11, 6,
+ 6, 9, 11, 7, 12, 9, 12, 12, 4, 4, 12, 11, 7, 6, 11, 7, 9, 4, 5,
+ },
+ new int[] {
+ 3, 3, 3,
+ 9, 4, 12, 5, 9, 9, 10, 7, 7, 5, 4, 11, 9, 11, 4, 5,
+ 11, 6, 11, 11, 7, 11, 11, 11, 5, 11, 7, 9, 4, 6, 10, 6, 11, 12,
+ 6, 11, 12, 4, 5, 7, 11, 4, 7, 11, 4, 4, 12, 9, 5, 6, 5, 4,
+ 4, 4, 8, 7, 11, 7, 9, 6,
+ }, new int[] {
+ 3, 3, 3,
+ 12, 7, 11, 5, 11,
+ 4, 6, 5, 5, 4, 9, 10, 5, 5, 9, 9, 7, 6, 9, 4, 5, 11, 7,
+ 9, 6, 6, 11, 9, 5, 4, 8, 4, 6, 11, 9, 12, 7, 5, 9, 5, 11,
+ 5, 12, 7, 7, 5, 8, 9, 11, 6, 11, 8, 5, 12, 9, 9, 4, 5, 6,
+ 11,
+ }, new int[] {
+ 3, 3, 3,
+ 11, 11, 11, 9, 6, 8, 11, 7, 9, 5, 4, 11, 11,
+ 12, 4, 7, 7, 7, 9, 5, 11, 5, 9, 12, 11, 12, 9, 8, 10, 9,
+ 11, 4, 4, 7, 9, 7, 4, 4, 7, 7, 4, 9, 11, 12, 5, 6, 4, 11,
+ 11, 6, 4, 4, 4, 9, 11, 8, 6, 9, 4, 12,
+ }, new int[] {
+ 3, 3, 3,
+ 11, 9, 11, 8, 6, 4, 5, 12, 11, 11, 4, 11, 5, 8, 5, 6, 4, 7, 7,
+ 9, 11, 11, 4, 9, 6, 9, 5, 9, 7, 5, 8, 7, 6, 9, 5, 10, 11,
+ 12, 12, 7, 12, 6, 11, 4, 11, 6, 4, 4, 7, 6, 11, 7, 6, 10,
+ 12, 6, 4, 10, 9, 4,
+ },
+
};
- DiscreteDifferentialEvolution dde = new DiscreteDifferentialEvolution (reels, 0.9, 3);
- dde.optimize ();
- Console.WriteLine (dde);
-
-// for (int r = 0; r < SlotMachineSimulation.NUMBER_OF_EXPERIMENTS; r++) {
-// SlotMachineSimulation simulation = new SlotMachineSimulation ();
-// simulation.load (reels);
-//
-// for (long e = 0; e < SlotMachineSimulation.NUMBER_OF_SIMUALTIONS; e++) {
-// simulation.runBaseGame ();
-// }
-//
-// Console.WriteLine (simulation);
-//
-// Console.WriteLine ("RTP difference from target: " + simulation.rtpDifference (0.9));
-// Console.WriteLine ("Prize deviation MSE: " + simulation.prizeDeviation ());
-// Console.WriteLine ("Symbols diversity: " + simulation.symbolsDiversity (3));
-// Console.WriteLine ("Cost function: " + simulation.costFunction (0.9, 3));
-// }
+ for (int r = 0; r < NUMBER_OF_EXPERIMENTS; r++) {
+ Simulation simulation = new Simulation ();
+ simulation.loadReels (reels);
+
+ for (long e = 0; e < NUMBER_OF_SIMUALTIONS; e++) {
+ simulation.runBaseGame ();
+ }
+
+ Console.WriteLine (simulation);
+
+ Console.WriteLine (simulation.rtp ());
+ Console.WriteLine (simulation.deviation ());
+ }
}
}
}
diff --git a/SlotMachineSimulation.cs b/Simulation.cs
similarity index 85%
rename from SlotMachineSimulation.cs
rename to Simulation.cs
index 8b368d5..dddf1bf 100644
--- a/SlotMachineSimulation.cs
+++ b/Simulation.cs
@@ -2,24 +2,21 @@
namespace BingoSlotDifferentialEvolutionOptimization
{
- class SlotMachineSimulation
+ class Simulation
{
+
/*
* Used in bingo cards generation for better suffling.
*/
- private const int NUMBER_OF_SHAKES = 30;
-
- private const int BINGO_CARDS_TALONS = 6;
+ private static int NUMBER_OF_SHAKES = 30;
- private const int BINGO_CARDS_WIDTH = 9;
+ private static int BINGO_CARDS_TALONS = 6;
- private const int BINGO_CARDS_LENGTH = 18;
+ private static int BINGO_CARDS_WIDTH = 9;
- private const int BINGO_BONUS_DISTRIBUTION_LENGTH = 63;
+ private static int BINGO_CARDS_LENGTH = 18;
- public const long NUMBER_OF_EXPERIMENTS = 10;
-
- public const long NUMBER_OF_SIMUALTIONS = 1000000;
+ private static int BINGO_BONUS_DISTRIBUTION_LENGTH = 63;
/**
* Bingo line bonus distribution.
@@ -112,6 +109,18 @@ class SlotMachineSimulation
*/
private int[] numbersInRow = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ /**
+ * Slot game paytable.
+ */
+ private int[][] paytable = {
+ new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ new int[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ new int[]{ 0, 0, 0, 75, 50, 20, 15, 9, 7, 5, 3, 2, 1, 0, 0, 0, 0 },
+ new int[]{ 0, 0, 0, 150, 100, 75, 50, 35, 20, 15, 9, 7, 3, 0, 0, 0, 0 },
+ new int[]{ 0, 0, 0, 300, 250, 200, 150, 100, 75, 50, 30, 20, 10, 0, 0, 0, 0 },
+ };
+
/**
* Lines combinations.
*/
@@ -127,54 +136,357 @@ class SlotMachineSimulation
new int[]{ 1, 2, 1, 0, 1 },
};
+ /**
+ * List of symbols names.
+ */
+ private String[] symbols = {
+ "SYM00",
+ "SYM01",
+ "SYM02",
+ "SYM03",
+ "SYM04",
+ "SYM05",
+ "SYM06",
+ "SYM07",
+ "SYM08",
+ "SYM09",
+ "SYM10",
+ "SYM11",
+ "SYM12",
+ "SYM16",
+ "SYM17",
+ "SYM18",
+ "SYM19",
+ };
+
/**
* Lines combinations.
*/
private int[][] reels = {
new int[] {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
},
};
@@ -237,7 +549,7 @@ class SlotMachineSimulation
/**
* Symbols win hit rate in base game.
*/
- private long[][] baseSymbolMoney = {
+ private static long[][] baseSymbolMoney = {
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -249,7 +561,7 @@ class SlotMachineSimulation
/**
* Symbols hit rate in base game.
*/
- private long[][] baseGameSymbolsHitRate = {
+ private static long[][] baseGameSymbolsHitRate = {
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new long[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -489,7 +801,7 @@ private int lineWin (int[] line)
line [i] = -1;
}
- int win = Paytable.values [number] [symbol];
+ int win = paytable [number] [symbol];
if (win > 0) {
baseSymbolMoney [number] [symbol] += win;
@@ -703,7 +1015,7 @@ private int bingoWin ()
*
* @date 27 Feb 2015
*/
- public SlotMachineSimulation ()
+ public Simulation ()
{
totalBet = lines.Length;
}
@@ -718,7 +1030,7 @@ public long getLostMoney ()
return lostMoney;
}
- public void load (int[][]reels)
+ public void loadReels (int[][]reels)
{
for (int i = 0; i < reels.Length; i++) {
for (int j = 0; j < reels [i].Length; j++) {
@@ -823,12 +1135,12 @@ public void runBaseGame ()
totalNumberOfGames++;
}
- public double rtpDifference (double target)
+ public double rtp ()
{
- return Math.Abs (target - (double)wonMoney / (double)lostMoney);
+ return (double)wonMoney / (double)lostMoney;
}
- public double prizeDeviation ()
+ public double deviation ()
{
int k = 0;
double average = 0;
@@ -861,41 +1173,6 @@ public double prizeDeviation ()
return result;
}
- public double symbolsDiversity (int length)
- {
- int count = 0;
- int matches = 0;
-
- for (int i = 0; i < reels.Length; i++) {
- for (int j = 0; j < reels [i].Length; j++) {
- for (int k = 0; k < length - 1; k++) {
- for (int l = k + 1; l < length; l++) {
- if ((reels [i] [(j + k) % reels [i].Length]) == (reels [i] [(j + l) % reels [i].Length])) {
- matches++;
- }
- count++;
- }
- }
- }
- }
-
- return (double)matches / (double)count;
- }
-
- public double costFunction (double target, int length)
- {
- return symbolsDiversity (length) * 100 + rtpDifference (target) * 10 + prizeDeviation () * 1;
- }
-
- public void simulate ()
- {
- for (int r = 0; r < NUMBER_OF_EXPERIMENTS; r++) {
- for (long e = 0; e < NUMBER_OF_SIMUALTIONS; e++) {
- runBaseGame ();
- }
- }
- }
-
/**
* Print all simulation input data structures.
*
@@ -911,14 +1188,14 @@ public String printDataStructures ()
result += "Paytable:";
result += "\r\n";
- for (int i = 0; i < Paytable.values.Length; i++) {
+ for (int i = 0; i < paytable.Length; i++) {
result += "\t" + i + " of";
}
result += "\r\n";
- for (int j = 0; j < Paytable.values [0].Length; j++) {
+ for (int j = 0; j < paytable [0].Length; j++) {
result += "SYM" + j + "\t";
- for (int i = 0; i < Paytable.values.Length; i++) {
- result += Paytable.values [i] [j] + "\t";
+ for (int i = 0; i < paytable.Length; i++) {
+ result += paytable [i] [j] + "\t";
}
result += "\r\n";
}
diff --git a/Symbols.cs b/Symbols.cs
deleted file mode 100644
index a5cd532..0000000
--- a/Symbols.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-
-namespace BingoSlotDifferentialEvolutionOptimization
-{
- class Symbols
- {
- /**
- * List of symbols names.
- */
- public static String[] names = {
- "",
- "",
- "",
- "SYM03",
- "SYM04",
- "SYM05",
- "SYM06",
- "SYM07",
- "SYM08",
- "SYM09",
- "SYM10",
- "SYM11",
- "SYM12",
- "",
- "",
- "",
- "",
- };
-
- public static bool isValid(int symbol) {
- if (symbol < 0 || symbol >= names.Length) {
- return false;
- }
-
- if(names[symbol].Equals("") == true) {
- return false;
- }
-
- return true;
- }
-
- public static int randomValid() {
- int symbol = -1;
-
- do {
- symbol = Util.prng.Next(names.Length);
- }while(names[symbol].Equals("") == true);
-
- return symbol;
- }
- }
-}
diff --git a/Util.cs b/Util.cs
index 3ffb279..8edebdf 100644
--- a/Util.cs
+++ b/Util.cs
@@ -5,13 +5,8 @@ namespace BingoSlotDifferentialEvolutionOptimization
class Util
{
/**
- * Report in steps.
- */
- public const bool VERBOSE = true;
-
- /**
- * Pseudo-random number generator.
- */
+ * Pseudo-random number generator.
+ */
public static Random prng = new Random ();
}
}