@slot-engine/core 0.0.1 → 0.0.2

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +0 -7
  3. package/dist/index.d.ts +0 -7
  4. package/dist/index.js +9 -7
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +9 -7
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +5 -1
  9. package/.turbo/turbo-build.log +0 -33
  10. package/.turbo/turbo-typecheck.log +0 -4
  11. package/CHANGELOG.md +0 -7
  12. package/index.ts +0 -205
  13. package/lib/zstd.exe +0 -0
  14. package/optimizer-rust/Cargo.toml +0 -19
  15. package/optimizer-rust/src/exes.rs +0 -154
  16. package/optimizer-rust/src/main.rs +0 -1659
  17. package/src/Board.ts +0 -527
  18. package/src/Book.ts +0 -83
  19. package/src/GameConfig.ts +0 -148
  20. package/src/GameMode.ts +0 -86
  21. package/src/GameState.ts +0 -272
  22. package/src/GameSymbol.ts +0 -61
  23. package/src/ReelGenerator.ts +0 -589
  24. package/src/ResultSet.ts +0 -207
  25. package/src/Simulation.ts +0 -625
  26. package/src/SlotGame.ts +0 -117
  27. package/src/Wallet.ts +0 -203
  28. package/src/WinType.ts +0 -102
  29. package/src/analysis/index.ts +0 -198
  30. package/src/analysis/utils.ts +0 -128
  31. package/src/optimizer/OptimizationConditions.ts +0 -99
  32. package/src/optimizer/OptimizationParameters.ts +0 -46
  33. package/src/optimizer/OptimizationScaling.ts +0 -18
  34. package/src/optimizer/index.ts +0 -142
  35. package/src/utils/math-config.ts +0 -109
  36. package/src/utils/setup-file.ts +0 -36
  37. package/src/utils/zstd.ts +0 -28
  38. package/src/winTypes/ClusterWinType.ts +0 -3
  39. package/src/winTypes/LinesWinType.ts +0 -208
  40. package/src/winTypes/ManywaysWinType.ts +0 -3
  41. package/tsconfig.json +0 -19
  42. package/utils.ts +0 -270
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@slot-engine/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/slot-engine/slot-engine"
7
7
  },
8
+ "homepage": "https://slot-engine.dev/docs/core",
9
+ "files": [
10
+ "dist"
11
+ ],
8
12
  "main": "dist/index.js",
9
13
  "module": "dist/index.js",
10
14
  "types": "dist/index.d.ts",
@@ -1,33 +0,0 @@
1
-
2
- > @slot-engine/core@0.0.1 prebuild /home/runner/work/slot-engine/slot-engine/packages/core
3
- > pnpm typecheck && pnpm copy-files
4
-
5
-
6
- > @slot-engine/core@0.0.1 typecheck /home/runner/work/slot-engine/slot-engine/packages/core
7
- > tsc --noEmit
8
-
9
-
10
- > @slot-engine/core@0.0.1 copy-files /home/runner/work/slot-engine/slot-engine/packages/core
11
- > tsx ../../scripts/copy-core-files.ts
12
-
13
- ✅ Files copied successfully.
14
-
15
- > @slot-engine/core@0.0.1 build /home/runner/work/slot-engine/slot-engine/packages/core
16
- > tsup ./index.ts --dts --format cjs,esm --sourcemap
17
-
18
- CLI Building entry: index.ts
19
- CLI Using tsconfig: tsconfig.json
20
- CLI tsup v8.5.0
21
- CLI Target: es2022
22
- CJS Build start
23
- ESM Build start
24
- CJS dist/index.js 93.83 KB
25
- CJS dist/index.js.map 193.64 KB
26
- CJS ⚡️ Build success in 127ms
27
- ESM dist/index.mjs 90.37 KB
28
- ESM dist/index.mjs.map 193.21 KB
29
- ESM ⚡️ Build success in 129ms
30
- DTS Build start
31
- DTS ⚡️ Build success in 2038ms
32
- DTS dist/index.d.ts 42.85 KB
33
- DTS dist/index.d.mts 42.85 KB
@@ -1,4 +0,0 @@
1
-
2
- > @slot-engine/core@0.0.1 typecheck /home/runner/work/slot-engine/slot-engine/packages/core
3
- > tsc --noEmit
4
-
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # @slot-engine/core
2
-
3
- ## 0.0.1
4
-
5
- ### Patch Changes
6
-
7
- - Initial npm release for testing purposes. ([#2](https://github.com/slot-engine/slot-engine/pull/2)) - Thanks @nordowl
package/index.ts DELETED
@@ -1,205 +0,0 @@
1
- import { GameConfig } from "./src/GameConfig"
2
- import { type SimulationContext } from "./src/Simulation"
3
- import { GameMode, GameModeName } from "./src/GameMode"
4
- import { GameSymbol } from "./src/GameSymbol"
5
- import { ReelGenerator, Reels } from "./src/ReelGenerator"
6
- import { ResultSet, EvaluationContext } from "./src/ResultSet"
7
- import { StandaloneBoard } from "./src/Board"
8
- import { WinType } from "./src/WinType"
9
- import { LinesWinType } from "./src/winTypes/LinesWinType"
10
- import { ClusterWinType } from "./src/winTypes/ClusterWinType"
11
- import { ManywaysWinType } from "./src/winTypes/ManywaysWinType"
12
- import { OptimizationConditions } from "./src/optimizer/OptimizationConditions"
13
- import { OptimizationScaling } from "./src/optimizer/OptimizationScaling"
14
- import { OptimizationParameters } from "./src/optimizer/OptimizationParameters"
15
- import { SlotGame } from "./src/SlotGame"
16
- export { weightedRandom } from "./utils"
17
-
18
- export {
19
- StandaloneBoard,
20
- GameConfig,
21
- GameMode,
22
- GameSymbol,
23
- WinType,
24
- LinesWinType,
25
- ClusterWinType,
26
- ManywaysWinType,
27
- OptimizationConditions,
28
- OptimizationScaling,
29
- OptimizationParameters,
30
- ReelGenerator,
31
- ResultSet,
32
- type Reels,
33
- }
34
-
35
- /**
36
- * @internal
37
- */
38
- export interface CommonGameOptions<
39
- TGameModes extends AnyGameModes = AnyGameModes,
40
- TSymbols extends AnySymbols = AnySymbols,
41
- TUserState extends AnyUserData = AnyUserData,
42
- > {
43
- /**
44
- * The unique identifier of the game, used for configuration and identification.
45
- */
46
- id: string
47
- /**
48
- * The name of the game, used for display purposes.
49
- */
50
- name: string
51
- /**
52
- * An arbitrary number to identify the provider of this game.
53
- */
54
- providerNumber: number
55
- /**
56
- * A GameMode is the core structure of a slot, defining the board,\
57
- * bet cost, win type, and other properties.
58
- *
59
- * One-off mechanisms can also be injected into the core game logic from here.
60
- */
61
- gameModes: Record<GameModeName, GameMode>
62
-
63
- /**
64
- * A list of all symbols that will appear on the reels.
65
- */
66
- symbols: GameSymbol[]
67
- /**
68
- * A mapping from spin type to scatter counts to the number of free spins awarded.
69
- *
70
- * @example
71
- * ```ts
72
- * scatterToFreespins: {
73
- * [GameConfig.CONSTANTS.BASE_GAME]: {
74
- * 3: 10,
75
- * 4: 12,
76
- * 5: 15,
77
- * },
78
- * [GameConfig.CONSTANTS.FREE_SPINS]: {
79
- * 3: 6,
80
- * 4: 8,
81
- * 5: 10,
82
- * },
83
- * },
84
- * ```
85
- */
86
- scatterToFreespins: Record<string, Record<number, number>>
87
- /**
88
- * If set, this will pad the board with symbols on the top and bottom of the reels.\
89
- * Useful for teasing symbols right above or below the active board.
90
- *
91
- * Default: 1
92
- */
93
- padSymbols?: number
94
- /**
95
- * The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
96
- */
97
- maxWinX: number
98
- /**
99
- * Hooks are used to inject custom logic at specific points in the game flow.\
100
- * Some required hooks must be implemented for certain features to work.
101
- */
102
- hooks: GameHooks<TGameModes, TSymbols, TUserState>
103
- /**
104
- * Custom additional state that can be used in game flow logic.
105
- */
106
- userState?: TUserState
107
- }
108
-
109
- /**
110
- * @internal
111
- */
112
- export type AnyUserData = Record<string, any>
113
-
114
- /**
115
- * @internal
116
- */
117
- export type AnyGameModes = Record<string, GameMode>
118
-
119
- /**
120
- * @internal
121
- */
122
- export type AnySymbols = GameSymbol[]
123
-
124
- /**
125
- * @internal
126
- */
127
- export interface GameHooks<
128
- TGameModes extends AnyGameModes = AnyGameModes,
129
- TSymbols extends AnySymbols = AnySymbols,
130
- TUserState extends AnyUserData = AnyUserData,
131
- > {
132
- /**
133
- * This hook is called after the simulation state is prepared for a spin,\
134
- * and the core is ready to handle the game flow.
135
- *
136
- * **The developer is responsible for implementing the entire game flow here, including:**
137
- * - Drawing the board
138
- * - Evaluating wins
139
- * - Tumbling mechanics
140
- * - Updating wallet
141
- * - Handling free spins
142
- * - Recording events
143
- * - ... and everything in between.
144
- *
145
- * You can access the config and state from the context.
146
- *
147
- * The game flow is not built into the core, because it can vary greatly between different games.\
148
- * This hook provides the flexibility to implement any game flow you need.
149
- */
150
- onHandleGameFlow: (ctx: SimulationContext<TGameModes, TSymbols, TUserState>) => void
151
- /**
152
- * This hook is called whenever a simulation is accepted, i.e. when the criteria of the current ResultSet is met.
153
- */
154
- onSimulationAccepted?: (
155
- ctx: SimulationContext<TGameModes, TSymbols, TUserState>,
156
- ) => void
157
- }
158
-
159
- export type InferUserState<T> = T extends SlotGame<infer U> ? U : never
160
-
161
- export type HookContext<T> =
162
- T extends SlotGame<infer G, infer S, infer U> ? SimulationContext<G, S, U> : never
163
-
164
- export { type EvaluationContext }
165
-
166
- export type InferGameType<
167
- TGameModes extends AnyGameModes,
168
- TSymbols extends AnySymbols,
169
- TUserState extends AnyUserData,
170
- > = SlotGame<TGameModes, TSymbols, TUserState>
171
-
172
- export interface CreateSlotGameOpts<
173
- TGameModes extends AnyGameModes = AnyGameModes,
174
- TSymbols extends AnySymbols = AnySymbols,
175
- TUserState extends AnyUserData = AnyUserData,
176
- > {
177
- id: CommonGameOptions["id"]
178
- name: CommonGameOptions["name"]
179
- providerNumber: CommonGameOptions["providerNumber"]
180
- gameModes: TGameModes
181
- symbols: TSymbols
182
- scatterToFreespins: CommonGameOptions["scatterToFreespins"]
183
- padSymbols?: CommonGameOptions["padSymbols"]
184
- maxWinX: CommonGameOptions["maxWinX"]
185
- userState?: TUserState
186
- hooks: CommonGameOptions<TGameModes, TSymbols, TUserState>["hooks"]
187
- }
188
-
189
- export function createSlotGame<TGame>(
190
- opts: TGame extends InferGameType<infer G, infer S, infer U>
191
- ? CreateSlotGameOpts<G, S, U>
192
- : never,
193
- ) {
194
- return new SlotGame(opts) as TGame
195
- }
196
-
197
- export const defineUserState = <TUserState extends AnyUserData>(data: TUserState) => data
198
-
199
- export const defineSymbols = <TSymbol extends GameSymbol>(symbols: TSymbol[]) => symbols
200
-
201
- export const defineGameModes = <TGameModes extends AnyGameModes>(gameModes: TGameModes) =>
202
- gameModes
203
-
204
- export const defineReelSets = <TSymbols extends AnySymbols>(reelSets: ReelGenerator[]) =>
205
- reelSets
package/lib/zstd.exe DELETED
Binary file
@@ -1,19 +0,0 @@
1
- [package]
2
- name = "PigFarmRust"
3
- version = "0.1.0"
4
- edition = "2021"
5
-
6
- # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
-
8
- [dependencies]
9
- serde = { version = "1.0", features = ["derive"] }
10
- serde_json = "1.0"
11
- csv = "1.1"
12
- rust_decimal = "1.11.0"
13
- rayon = "1.5"
14
- rand = "0.8.4"
15
- ndarray = "0.15.3"
16
- rand_distr = "0.4.2"
17
- rand_pcg = "0.2"
18
-
19
-
@@ -1,154 +0,0 @@
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
- }