@slot-engine/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +33 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +7 -0
- package/README.md +8 -0
- package/dist/index.d.mts +1306 -0
- package/dist/index.d.ts +1306 -0
- package/dist/index.js +2929 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2874 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/zstd.exe +0 -0
- package/dist/optimizer-rust/Cargo.toml +19 -0
- package/dist/optimizer-rust/src/exes.rs +154 -0
- package/dist/optimizer-rust/src/main.rs +1659 -0
- package/index.ts +205 -0
- package/lib/zstd.exe +0 -0
- package/optimizer-rust/Cargo.toml +19 -0
- package/optimizer-rust/src/exes.rs +154 -0
- package/optimizer-rust/src/main.rs +1659 -0
- package/package.json +33 -0
- package/src/Board.ts +527 -0
- package/src/Book.ts +83 -0
- package/src/GameConfig.ts +148 -0
- package/src/GameMode.ts +86 -0
- package/src/GameState.ts +272 -0
- package/src/GameSymbol.ts +61 -0
- package/src/ReelGenerator.ts +589 -0
- package/src/ResultSet.ts +207 -0
- package/src/Simulation.ts +625 -0
- package/src/SlotGame.ts +117 -0
- package/src/Wallet.ts +203 -0
- package/src/WinType.ts +102 -0
- package/src/analysis/index.ts +198 -0
- package/src/analysis/utils.ts +128 -0
- package/src/optimizer/OptimizationConditions.ts +99 -0
- package/src/optimizer/OptimizationParameters.ts +46 -0
- package/src/optimizer/OptimizationScaling.ts +18 -0
- package/src/optimizer/index.ts +142 -0
- package/src/utils/math-config.ts +109 -0
- package/src/utils/setup-file.ts +36 -0
- package/src/utils/zstd.ts +28 -0
- package/src/winTypes/ClusterWinType.ts +3 -0
- package/src/winTypes/LinesWinType.ts +208 -0
- package/src/winTypes/ManywaysWinType.ts +3 -0
- package/tsconfig.json +19 -0
- package/utils.ts +270 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
use csv::ReaderBuilder;
|
|
2
|
+
use serde::{Deserialize, Serialize};
|
|
3
|
+
use serde_json;
|
|
4
|
+
use std::error::Error;
|
|
5
|
+
use std::path::{Path};
|
|
6
|
+
use std::{collections::HashMap, fs::File};
|
|
7
|
+
|
|
8
|
+
////////////////////////////////////
|
|
9
|
+
/// JSON STRUCTS
|
|
10
|
+
////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
// Search Key STRUCTS
|
|
13
|
+
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
14
|
+
pub struct SearchKey {
|
|
15
|
+
pub name: String,
|
|
16
|
+
pub value: String,
|
|
17
|
+
}
|
|
18
|
+
// FORCE RESULT STRUCTS
|
|
19
|
+
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
20
|
+
pub struct SearchResult {
|
|
21
|
+
// Each key maps to a vector of serde_json::Value to accommodate different types.
|
|
22
|
+
pub search: Vec<SearchKey>,
|
|
23
|
+
pub timesTriggered: u32,
|
|
24
|
+
pub bookIds: Vec<u32>,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// FORCE RESULT STRUCTS
|
|
28
|
+
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
29
|
+
pub struct IdentityCondition {
|
|
30
|
+
pub search: Vec<SearchKey>,
|
|
31
|
+
pub opposite: bool,
|
|
32
|
+
pub win_range_start: f64,
|
|
33
|
+
pub win_range_end: f64,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// CONFIG FILE STRUCTS
|
|
37
|
+
|
|
38
|
+
#[derive(Debug, Deserialize, Serialize)]
|
|
39
|
+
pub struct BetMode {
|
|
40
|
+
pub bet_mode: String,
|
|
41
|
+
pub cost: f64,
|
|
42
|
+
pub rtp: f64,
|
|
43
|
+
pub max_win: f64,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
47
|
+
pub struct FenceJson {
|
|
48
|
+
pub name: String,
|
|
49
|
+
pub hr: Option<String>, // Option, as it can be a number or a string "x"
|
|
50
|
+
pub rtp: Option<String>,
|
|
51
|
+
pub avg_win: Option<String>,
|
|
52
|
+
pub identity_condition: IdentityCondition,
|
|
53
|
+
pub min_mean_to_median: Option<String>,
|
|
54
|
+
pub max_mean_to_median: Option<String>,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[derive(Debug, Deserialize, Serialize)]
|
|
58
|
+
pub struct FencesInfo {
|
|
59
|
+
pub bet_mode: String,
|
|
60
|
+
pub fences: Vec<FenceJson>,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#[derive(Debug, Deserialize, Serialize)]
|
|
64
|
+
pub struct DressJson {
|
|
65
|
+
pub fence: String,
|
|
66
|
+
pub scale_factor: String,
|
|
67
|
+
pub identity_condition_force: Option<String>, // Dynamic value (can be a string or an array)
|
|
68
|
+
pub identity_condition_win_range: Option<[f64; 2]>, // Optional field (can be a range of numbers or null)
|
|
69
|
+
pub prob: Option<f64>, // Optional field (can be a number or null)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#[derive(Debug, Deserialize, Serialize)]
|
|
73
|
+
pub struct DressesInfo {
|
|
74
|
+
pub bet_mode: String,
|
|
75
|
+
pub dresses: Vec<DressJson>,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[derive(Debug, Deserialize, Serialize)]
|
|
79
|
+
pub struct ConfigData {
|
|
80
|
+
pub game_id: String,
|
|
81
|
+
pub bet_modes: Vec<BetMode>,
|
|
82
|
+
pub fences: Vec<FencesInfo>,
|
|
83
|
+
pub dresses: Vec<DressesInfo>,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// LOOK UP TABLE STRUCT
|
|
87
|
+
#[derive(Debug, Deserialize)]
|
|
88
|
+
pub(crate) struct LookUpTableEntry {
|
|
89
|
+
pub id: u32,
|
|
90
|
+
pub weight: u64,
|
|
91
|
+
pub win: f64,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//Integer payout values
|
|
95
|
+
#[derive(Debug, Deserialize)]
|
|
96
|
+
pub(crate) struct LookUpTableInput {
|
|
97
|
+
pub id: u32,
|
|
98
|
+
pub weight: u64,
|
|
99
|
+
pub win: u64,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
////////////////////////////////////
|
|
103
|
+
/// FUNCTIONS TO LOAD CONFIG FILES
|
|
104
|
+
////////////////////////////////////
|
|
105
|
+
|
|
106
|
+
pub(crate) fn load_force_options(
|
|
107
|
+
game_name: &str,
|
|
108
|
+
bet_type: &str,
|
|
109
|
+
user_game_build_path: String,
|
|
110
|
+
) -> Vec<SearchResult> {
|
|
111
|
+
let file_path = Path::new(&user_game_build_path)
|
|
112
|
+
.join(format!("force_record_{}.json", bet_type));
|
|
113
|
+
let json_file_path = Path::new(&file_path);
|
|
114
|
+
let file = File::open(json_file_path).expect("Unable to open force file");
|
|
115
|
+
println!("json force path: {}", json_file_path.display());
|
|
116
|
+
let search_results: Vec<SearchResult> =
|
|
117
|
+
serde_json::from_reader(file).expect("error while reading or parsing");
|
|
118
|
+
return search_results;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
pub(crate) fn load_config_data(game_name: &str, user_game_build_path: String) -> ConfigData {
|
|
122
|
+
let file_path = Path::new(&user_game_build_path)
|
|
123
|
+
.join("math_config.json");
|
|
124
|
+
let json_file_path = Path::new(&file_path);
|
|
125
|
+
let file = File::open(json_file_path).expect("Unable to open force file");
|
|
126
|
+
let config_data: ConfigData =
|
|
127
|
+
serde_json::from_reader(file).expect("error while reading or parsing");
|
|
128
|
+
return config_data;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
pub(crate) fn read_look_up_table(
|
|
132
|
+
game_name: &str,
|
|
133
|
+
bet_type: &str,
|
|
134
|
+
user_game_build_path: String,
|
|
135
|
+
) -> Result<HashMap<u32, LookUpTableEntry>, Box<dyn Error>> {
|
|
136
|
+
let file_path = Path::new(&user_game_build_path)
|
|
137
|
+
.join(format!("lookUpTable_{}.csv", bet_type));
|
|
138
|
+
let csv_file_path = Path::new(&file_path);
|
|
139
|
+
let file = File::open(csv_file_path)?;
|
|
140
|
+
let mut rdr = ReaderBuilder::new().has_headers(false).from_reader(file);
|
|
141
|
+
|
|
142
|
+
let mut lookup_table: HashMap<u32, LookUpTableEntry> = HashMap::new();
|
|
143
|
+
|
|
144
|
+
for result in rdr.deserialize() {
|
|
145
|
+
let record: LookUpTableInput = result?;
|
|
146
|
+
let record_float = LookUpTableEntry{
|
|
147
|
+
id: record.id,
|
|
148
|
+
weight: record.weight,
|
|
149
|
+
win: record.win as f64 / 100.0};
|
|
150
|
+
lookup_table.insert(record.id, record_float);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
Ok(lookup_table)
|
|
154
|
+
}
|