### Install Slot Engine Panel with Bun Source: https://slot-engine.dev/docs/panel This command installs the Slot Engine Panel package using the Bun package manager. Ensure Bun is installed on your system before running this command. It installs the package and sets up necessary configurations. ```bash bun install @slot-engine/panel ``` -------------------------------- ### Example Implementation of Slot Engine Integration Source: https://slot-engine.dev/docs/core/game-implementation This section provides a practical example of how to integrate and use the slot engine. It includes a callout box with a link to a complete game flow example, demonstrating a real-world application of the engine's functionalities. This serves as a quick-start guide for developers. ```html

Example Implementation

Check out a complete game flow example here.

``` -------------------------------- ### Start Slot Engine Panel Source: https://slot-engine.dev/docs/panel This command starts the Slot Engine Panel application. It assumes a 'MyGame' is defined in your configuration. This is a basic startup command for the panel. ```bash panel start() ``` -------------------------------- ### Install @slot-engine/panel using npm, pnpm, yarn, or bun Source: https://context7_llms Installs the `@slot-engine/panel` package for Slot Engine. This package is required for setting up the Panel. Ensure your project is set up with Node.js and a compatible version of `@slot-engine/core` (>= 0.2.0). ```npm npm i @slot-engine/panel ``` ```pnpm pnpm i @slot-engine/panel ``` ```yarn yarn add @slot-engine/panel ``` ```bun bun install @slot-engine/panel ``` -------------------------------- ### Slot Engine Book Example Source: https://slot-engine.dev/docs/core/game-context/data-service This example demonstrates the structure of a 'book' generated by a Slot Engine simulation. It includes simulation metadata and an array of 'events' that dictate frontend visualizations. ```json { "simulationId": "sim_12345", "payoutValues": { "totalWin": 150, "lines": [ { "symbol": "A", "multiplier": 10, "bet": 1 }, { "symbol": "K", "multiplier": 5, "bet": 1 } ] }, "events": [ { "index": 0, "type": "REVEAL_SYMBOLS", "data": { "symbols": ["A", "K", "Q", "J", "10"] } }, { "index": 1, "type": "DISPLAY_WIN_LINE", "data": { "line": 1, "symbol": "A", "multiplier": 10 } }, { "index": 2, "type": "DISPLAY_WIN_AMOUNT", "data": { "amount": 150 } }, { "index": 3, "type": "TRIGGER_FREE_SPINS", "data": { "spins": 10 } } ] } ``` -------------------------------- ### Install @slot-engine/core Package Source: https://context7_llms Installs the @slot-engine/core package using npm, pnpm, yarn, or bun. Ensure you have Node.js version >= 23.8.0 or >= 22.15.0 for Zstandard compression features. ```bash npm i @slot-engine/core ``` ```bash pnpm i @slot-engine/core ``` ```bash yarn add @slot-engine/core ``` ```bash bun install @slot-engine/core ``` -------------------------------- ### Create Slot Game Basic Setup (JavaScript) Source: https://slot-engine.dev/docs/core/config Demonstrates the basic setup for creating a slot game using `createSlotGame` from the `@slot-engine/core` library. It includes essential game details like ID, name, max win, and scatter to free spins mapping. ```javascript import { createSlotGame, SPIN_TYPE } from "@slot-engine/core" export const game = createSlotGame({ id: "my-game", name: "My Game", maxWinX: 5000, padSymbols: 1, scatterToFreespins: { [SPIN_TYPE.BASE_GAME]: { 3: 10, 4: 12, 5: 15, }, [SPIN_TYPE.FREE_SPINS]: { 3: 6, 4: 8, 5: 10, }, }, symbols: {}, gameModes: {}, userState: {}, hooks: { onHandleGameFlow(ctx) {}, }, }) ``` -------------------------------- ### Slot Game Configuration Example Source: https://slot-engine.dev/docs/core/config This snippet illustrates a typical configuration structure for a slot game. It includes sections for symbols, game modes, and user state, which are essential for defining the game's behavior and appearance. The example shows how to add these configurations. ```javascript self.__next_f.push([ 1, "90:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/symbols\",\"children\":\"symbols\"}]\n91:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/game-modes\",\"children\":\"game modes\"}]\n92:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/custom-state\",\"children\":\"state\"}]\n93:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/game-implementation\",\"children\":\"implementation\"}]\n94:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/game-tasks/simulation\",\"children\":\"simulate\"}]\n95:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/game-tasks/optimization\",\"children\":\"optimize\"}]\n96:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/game-modes\",\"children\":\"Game Configuration: Game Modes\"}]\n97:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/symbols\",\"children\":\"Game Configuration: Symbols\"}]\n98:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/custom-state\",\"children\":\"Game Configuration: User State\"}]\n99:[\"$\",\"$L2c\",null,{\"href\":\"/docs/core/config/hooks\",\"children\":\"Game Configuration: Hooks\"}]\n" ]); ``` -------------------------------- ### Slot Engine Usage Example Source: https://slot-engine.dev/docs/core/game-context/board-service Demonstrates how to use the slot engine to draw a board with specified reel stops. This example is a conceptual representation of the engine's functionality. ```javascript const reels = [ // Reel definitions here ]; // Example usage of the slot engine to draw a board // slotEngine.drawBoard({ reels }); ``` -------------------------------- ### Configure Slot Engine Panel Source: https://context7_llms Sets up the Slot Engine Panel by importing `createPanel` and your game, then initializing and starting the panel. This configuration file should be in a separate file, and requires your game to be correctly imported. ```typescript import { createPanel } from "@slot-engine/panel" import { game as MyGame } from "../../path-to/my-game" const panel = createPanel({ games: [MyGame], }) panel.start() ``` -------------------------------- ### CSV Lookup Table Example Source: https://context7_llms Example of a CSV lookup table used for defining book IDs, weights, and payout multipliers. Weights determine the probability of an outcome being selected. ```csv ID, weight, payout 1,1,780 2,1,1000 3,1,0 ... ``` -------------------------------- ### Manual Game Logic Invocation in Stake's Example Games Source: https://slot-engine.dev/docs/core/slot-engine-vs-stake-math-sdk Stake's example games require developers to manually invoke methods like reset_seed(), reset_book(), or check_repeat(). The purpose of these methods is not immediately clear and requires deep dives into the underlying implementation to understand their role in game simulation. ```javascript reset_seed(); reset_book(); check_repeat(); ``` -------------------------------- ### Example Lookup Table Entry (CSV) Source: https://slot-engine.dev/docs/core/game-tasks/simulation An example entry from a lookup table CSV file, displaying the book ID, its weight, and the payout multiplier. This table is used to map simulation outcomes to their probabilities. ```csv ID,weight,payout 1,1,780 2,1,1000 3,1,0 ``` -------------------------------- ### Example Book File Structure (JSONL) Source: https://context7_llms Illustrates the structure of a book file generated by Slot Engine simulations. Each line represents a single book (simulation) and contains details like payout multiplier and events. These files are compressed using Zstandard. ```jsonl {"id":1,"payoutMultiplier":780,"events":[{"index":1,"type":"test","data":{"test":123}}]} {"id":2,"payoutMultiplier":1000,"events":[{"index":1,"type":"test","data":{"test":123}}]} {"id":3,"payoutMultiplier":0,"events":[{"index":1,"type":"test","data":{"test":123}}]} ``` -------------------------------- ### Install Rust for Slot Game Optimization Source: https://slot-engine.dev/docs/core/game-tasks/optimization This step involves installing the Rust programming language, which is required because the optimization program is written in Rust. Ensure Rust is installed before proceeding with optimization. ```text Install Rust if you haven't already. This is necessary because the optimization program is written in Rust. ``` -------------------------------- ### Combine and Get Reel Stops for Multiple Symbols Source: https://context7_llms Demonstrates how to get reel stops for multiple symbols (e.g., scatter and super scatter) and then combine them into a single array for further processing. ```typescript const reels = ctx.services.board.getRandomReelset() const scatter = config.symbols.get("S")! const superScatter = config.symbols.get("SS")! const reelStops = ctx.services.board.combineReelStops( ctx.services.board.getReelStopsForSymbol(reels, scatter), ctx.services.board.getReelStopsForSymbol(reels, superScatter), ) ``` -------------------------------- ### Reel Set Configuration Example Source: https://slot-engine.dev/docs/core/config/reel-sets This snippet shows an example of how to define a reel set for the slot engine. It includes properties like 'id', 'symbolWeights', and 'spaceBetweenSameSymbols'. The 'spaceBetweenSameSymbols' can be configured as a single number or an object with specific symbol weights. ```json { "id": "example", "symbolWeights": {}, "spaceBetweenSameSymbols": {}, "spaceBetweenSameSymbols": { "S": 5, "W": 3 } } ``` -------------------------------- ### Using TSX Library for Slot Engine Source: https://slot-engine.dev/docs/panel This section mentions the TSX library, which is used in conjunction with Slot Engine. It provides a link to the TSX library's website for more information. ```html tsx library ``` -------------------------------- ### Draw Board with Forced Scatter Symbols Source: https://context7_llms Provides a complete example of how to generate a reel set, find scatter symbol positions, randomly select a subset of these positions, and then draw the board with these forced scatter symbols. ```typescript const reels = ctx.services.board.getRandomReelset() const scatter = config.symbols.get("S")! const reelStops = ctx.services.board.getReelStopsForSymbol(reels, scatter) const scatterReelStops = ctx.services.board.getRandomReelStops(reels, reelStops, 3) ctx.services.board.drawBoardWithForcedStops({ reels, forcedStops: scatterReelStops, }) ``` -------------------------------- ### Context Object Example Source: https://slot-engine.dev/docs/core/game-implementation This snippet demonstrates how to access and utilize the context object within your game flow. The context object provides essential information and utilities for managing game state and logic. ```typescript ctx: Context ``` -------------------------------- ### Slot Engine Optimization Scaling Code Example Source: https://slot-engine.dev/docs/core/game-tasks/optimization Demonstrates the 'scaling' keyword in the context of optimization, showing its usage with the 'new OptimizationScaling' constructor. This snippet highlights the syntax and structure for implementing scaling. ```javascript scaling: new OptimizationScaling ``` -------------------------------- ### Slot Engine Configuration Example Source: https://slot-engine.dev/docs/core/game-tasks/optimization This snippet demonstrates a typical configuration object for a slot engine. It includes parameters such as 'criteria', 'scaleFactor', 'winRange', and 'probability', which define the behavior and outcomes of the slot game. ```json { "criteria": "freespins", "scaleFactor": 1.2, "winRange": [50, 150], "probability": 1 } ``` -------------------------------- ### Reel CSV File Naming Convention Source: https://slot-engine.dev/docs/panel This describes the required naming convention for reel CSV files when using the reel set designer. Files must be prefixed with 'reels_' to be recognized. ```text Your reels CSV files must be prefixed with reels_. ``` -------------------------------- ### Run Slot Engine Panel with tsx Source: https://context7_llms Starts the Slot Engine Panel using the `tsx` library for convenient execution of TypeScript files. Running in watch mode (`tsx watch`) is recommended as it automatically recognizes changes without requiring a manual restart. ```bash cd ./path-to/your-panel pnpm tsx watch ./index.ts ``` -------------------------------- ### Access Game Context and Board Services (TypeScript) Source: https://context7_llms Demonstrates how to access the game context and utilize board services to retrieve reel configurations and draw the board. It also shows how to safely access symbol configurations. ```typescript type Context = GameContext export function onHandleGameFlow(ctx: Context) { const reels = ctx.services.board.getRandomReelset() ctx.services.board.drawBoardWithRandomStops(reels) // type safe! ❧ const scatter = ctx.config.symbols.get("S")! const [count] = ctx.services.board.countSymbolsOnBoard(scatter) } ``` -------------------------------- ### Configure Game Root Directory for Slot Engine Source: https://slot-engine.dev/docs/panel To ensure Panel can resolve file paths correctly, your game must specify the 'rootDir' configuration option as '__dirname'. This is crucial for proper integration and file management within the Slot Engine environment. ```typescript export const game = createSlotGame({ rootDir: __dirname, // required if connecting this game to @slot-engine/panel // ... }); ``` -------------------------------- ### Code Example: Generated Reel Set Source: https://slot-engine.dev/docs/core/config/reel-sets A JavaScript code snippet demonstrating the structure of a generated reel set, including its ID, symbol weights, and stacking preferences. This example uses syntax highlighting. ```javascript new GeneratedReelSet({ id: "example", symbolWeights: {}, preferStackedSymbols: 50 }) ``` -------------------------------- ### Configure and Run Game Simulations Source: https://context7_llms Configures simulation parameters such as the number of runs and concurrency, then initiates the simulation tasks. This process generates JSONL and CSV output files for analysis. ```typescript game.configureSimulation({ simRunsAmount: { base: 100000, bonus: 100000, }, concurrency: 16, }) game.runTasks({ doSimulation: true, }) ``` -------------------------------- ### Create Slot Game Configuration Source: https://slot-engine.dev/docs/core/config Demonstrates how to import necessary functions and constants from the slot-engine core library and initialize a new slot game with a configuration object. This includes defining basic game properties like ID and name. ```javascript import { createSlotGame, SPIN_TYPE } from "@slot-engine/core" export const game = createSlotGame({ id: "my-game", name: "My Awesome Game", // ... other configuration properties }) ``` -------------------------------- ### Create and Configure a Panel Source: https://slot-engine.dev/docs/panel/config Demonstrates how to create a panel by calling the `createPanel` function and passing a configuration object. The configuration includes an array of games to be associated with the panel. ```typescript const panel = createPanel({ games: [MyGame], }) ``` -------------------------------- ### Slot Engine Configuration Example (JSON) Source: https://slot-engine.dev/docs/core/config/reel-sets An example of slot engine configuration, likely in JSON format, demonstrating the structure for symbol weights, spacing, and scatter symbol rules. This configuration directly impacts game mechanics and payout structures. ```json { "symbolWeights": {}, "spaceBetweenSymbols": {}, "S": { "SS": "3", "W": "1" } // ^ Scatter is at least 3 away from super scatter and 1 away from wild } ``` -------------------------------- ### Simulate Game with configureSimulation() Source: https://slot-engine.dev/docs/core/game-tasks/simulation This snippet demonstrates how to initiate a game simulation by calling the `configureSimulation()` function. It's a crucial step after configuring game parameters to verify their behavior. ```javascript game.configureSimulation(); ``` -------------------------------- ### Configure Symbol Stacking in Generated Reel Set (TypeScript) Source: https://context7_llms This code example demonstrates how to configure symbol stacking behavior using `preferStackedSymbols` and `symbolStacks` options in `GeneratedReelSet`. `preferStackedSymbols` sets a general likelihood for symbols to be stacked, while `symbolStacks` allows for detailed control over stacking for specific symbols, including chance, minimum, and maximum stack sizes. ```typescript new GeneratedReelSet({ id: "example", symbolWeights: {}, preferStackedSymbols: 50, }) new GeneratedReelSet({ id: "example", symbolWeights: {}, symbolStacks: { W: { chance: { "1": 20, "2": 20, "3": 20, "4": 20 }, // 20% chance to be stacked on reels 2-5 min: 2, // At least 2 wilds in a stack max: 4, // At most 4 wilds in a stack }, }, }) ``` -------------------------------- ### Get Random Reelset Source: https://context7_llms Selects a random reel set configuration based on the predefined weights for the current game result. ```typescript ctx.services.board.getRandomReelset() => Reels ``` -------------------------------- ### Record Data with Slot Engine Context Source: https://slot-engine.dev/docs/core/config/hooks Demonstrates how to record additional data within the Slot Engine's context using the `ctx.services.data.record()` method. This is a safe way to extend data without altering core payouts or results. ```javascript ctx.services.data.record() ``` -------------------------------- ### Get All Game Symbols as Array Source: https://slot-engine.dev/docs/core/game-context/game-service Returns all available game symbols as an array. This is useful for iterating through symbols or checking for their existence within the game. ```javascript ctx.services.game.getSymbolArray() ``` -------------------------------- ### Get Reel Stops for Symbol Source: https://context7_llms Retrieves all positions of a specific symbol across all reels. Useful for identifying potential scatter or bonus symbol locations. ```typescript ctx.services.board.getReelStopsForSymbol(reels, symbol) => number[][] ``` -------------------------------- ### Wallet Service - Get Current Tumble Win Source: https://slot-engine.dev/docs/core/game-context/wallet-service Retrieves the current total tumble win amount. ```APIDOC ## GET ctx.services.wallet.getCurrentTumbleWin() ### Description Gets the current total tumble win. ### Method GET ### Endpoint ctx.services.wallet.getCurrentTumbleWin() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **winAmount** (number) - The current total tumble win. #### Response Example ```json { "winAmount": 100.50 } ``` ``` -------------------------------- ### Add Book Event for Win Lines and Balance Update (TypeScript) Source: https://context7_llms Demonstrates how to add events to the game's book using `ctx.services.data.addBookEvent()`. This includes showing win lines with specific coordinates and updating the player's balance. These events are crucial for frontend visualization of game progress. ```typescript ctx.services.data.addBookEvent({ type: "show-winlines", data: { lines: [0, 3] wins: [ [ { reel: 0, row: 0 }, { reel: 1, row: 0 }, { reel: 2, row: 0 }, ], [ { reel: 0, row: 2 }, { reel: 1, row: 2 }, { reel: 2, row: 2 }, ] ] } }) ctx.services.data.addBookEvent({ type: "add-update-balance", data: { value: 200, } }) ``` -------------------------------- ### Get Current Game Mode Source: https://slot-engine.dev/docs/core/game-context/game-service Retrieves the current active game mode. This function is useful for understanding the current state of the game and applying mode-specific logic. ```javascript ctx.services.game.getCurrentGameMode() ``` -------------------------------- ### Get Reel Stops For Symbol Source: https://slot-engine.dev/docs/core/game-context/board-service Retrieves the reel stops for a specific symbol, considering the provided reels and scatter configurations. ```APIDOC ## GET /getreelstopsforsymbol ### Description Retrieves the reel stops for a given symbol, taking into account the reels and scatter configurations. ### Method GET ### Endpoint /getreelstopsforsymbol ### Parameters #### Query Parameters - **reels** (array) - Required - The reels configuration. - **scatter** (object) - Required - Scatter symbol configuration. ### Request Example ```json { "reels": [ // ... reel configurations ... ], "scatter": { // ... scatter configuration ... } } ``` ### Response #### Success Response (200) - **reelStops** (array) - The determined reel stops for the specified symbol. #### Response Example ```json { "reelStops": [ // ... stops for the symbol ... ] } ``` ``` -------------------------------- ### Adjust npm Scripts for Slot Engine Run Argument Source: https://context7_llms Demonstrates how to adjust npm scripts or commands to include the '--slot-engine-run' argument, required for tasks like simulation and optimization in newer versions of Slot Engine. ```bash pnpm tsx ./index.ts ``` ```bash pnpm tsx ./index.ts --slot-engine-run ``` -------------------------------- ### Get Random Reel Stops for Scatters Source: https://context7_llms Illustrates how to obtain reel stops for a scatter symbol and then use `getRandomReelStops` to select a specific number of these scatter positions for placement. ```typescript const reels = ctx.services.board.getRandomReelset() const scatter = config.symbols.get("S")! const reelStops = ctx.services.board.getReelStopsForSymbol(reels, scatter) const scatterReelStops = ctx.services.board.getRandomReelStops(reels, reelStops, 3) ``` -------------------------------- ### Create Slot Game Configuration with Game Flow Hook (JavaScript) Source: https://slot-engine.dev/docs/core/game-implementation Demonstrates how to initialize a slot game using the `createSlotGame` function. It highlights the structure for defining game configurations, including the crucial `hooks` object where the `onHandleGameFlow` function is specified to manage the entire game's logic. ```javascript export const game = createSlotGame({ /* the rest of your configuration */ hooks: { onHandleGameFlow } }); ``` -------------------------------- ### Define Symbols with Properties (JavaScript) Source: https://slot-engine.dev/docs/core/config/symbols Configures game symbols using `defineSymbols` and `GameSymbol`. This example defines scatter and wild symbols with their respective properties. ```javascript import { defineSymbols, GameSymbol } from "@slot-engine/core" export const symbols = defineSymbols({ S: new GameSymbol({ id: "S", properties: { isScatter: true, }, }), W: new GameSymbol({ id: "W", properties: { isWild: true, }, }), H1: new GameSymbol({ id: "H1", pays: { 3: 10, 4: 75, 5: 250, }, }), }) ``` -------------------------------- ### Initial State Configuration Source: https://slot-engine.dev/docs/core/config/custom-state Specifies how to set the initial values for each state property in a new simulation. These values are fundamental for starting any simulation with the desired configuration. ```javascript const initialState = { // Define initial values for state properties here }; ``` -------------------------------- ### Call runTasks() Function Source: https://slot-engine.dev/docs/core/game-tasks/optimization A simple example showing the final call to the `runTasks()` function on the game object. This is the primary method for initiating game task execution. ```javascript runTasks() ``` -------------------------------- ### Enable Uncompressed Book Files Creation Source: https://slot-engine.dev/docs/core/game-tasks/simulation A boolean flag to determine whether uncompressed book files should be created. Setting this to true may result in significant disk space usage, depending on the game's data. ```json { "makeUncompressedBooks": true } ``` -------------------------------- ### Get a Random Item from an Array (TypeScript) Source: https://context7_llms Demonstrates how to use the `randomItem` method from the RNG service to select a random element from an array. This is useful for various game mechanics requiring random choices. ```typescript ctx.services.rng.randomItem(array) ``` -------------------------------- ### Configure Slot Game Criteria and Quotas (JSON-like) Source: https://slot-engine.dev/docs/core/config/result-sets This configuration example demonstrates how to set specific criteria and quotas for game events within a slot engine. It includes a 'criteria' field, which can be a string or a more complex object, and a 'quota' field to define the probability or frequency of an event. ```json { "criteria": "0", "quota": 0.01 } ``` -------------------------------- ### Set Symbols Per Reel API Source: https://slot-engine.dev/docs/core/game-context/board-service This endpoint allows you to set the number of symbols that appear on each reel. This configuration is temporary and will be reset at the start of the next simulation. ```APIDOC ## POST /setSymbolsPerReel ### Description Sets a new temporary value for `symbolsPerReel`. The value will be persisted until changed by the user or until the simulation is reset or the next simulation starts. ### Method POST ### Endpoint /setSymbolsPerReel ### Parameters #### Request Body - **symbolsPerReel** (number[]) - Required - An array of numbers, where each number represents the count of symbols for a specific reel. ### Request Example ```json { "symbolsPerReel": [3, 4, 3, 4, 3] } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the symbols per reel have been set. #### Response Example ```json { "message": "Symbols per reel set successfully" } ``` ``` -------------------------------- ### Define Slot Game Configuration with Types Source: https://context7_llms Sets up the complete configuration for a slot game, including defining game modes, symbols, and user state using dedicated utility functions. It then infers the `GameType` using these definitions and passes it to `createSlotGame`. This approach ensures type safety and proper integration of all game components. ```typescript import { createSlotGame, SPIN_TYPE, InferGameType, defineGameModes, defineSymbols, defineUserState, } from "@slot-engine/core" export const gameModes = defineGameModes({}) export type GameModesType = typeof gameModes export const symbols = defineSymbols({}) export type SymbolsType = typeof symbols export const userState = defineUserState({}) export type UserStateType = typeof userState export type GameType = InferGameType export const game = createSlotGame({ /* the rest of your configuration */ symbols, gameModes, userState, }) ``` -------------------------------- ### Board Service: Set Reels Amount Source: https://slot-engine.dev/docs/core/game-context/board-service Temporarily sets the total number of reels on the board. This value is persisted until changed by the user or until the simulation resets or starts. ```javascript ctx.services.board.setReelsAmount(reelsAmount) ``` -------------------------------- ### Get Random Reel Stops Source: https://context7_llms Selects a random stop position for a specified number of reels from a given set of reel stops. Primarily used for strategically placing symbols like scatters on the board. ```typescript ctx.services.board.getRandomReelStops(reels, reelStops, amount) => Record ``` -------------------------------- ### Get Result Set By Criteria Function Source: https://slot-engine.dev/docs/core/game-context/game-service Fetches a result set based on the provided mode and criteria. This function is essential for querying game data. It accepts `mode` and `criteria` as input and returns a `ResultSet`. ```javascript ctx.services.game.getResultSetByCriteria() ``` -------------------------------- ### Slot Engine Dos and Don'ts Guidelines Source: https://slot-engine.dev/docs/core/game-implementation This section outlines best practices for using the slot engine, categorized into 'Dos' and 'Don'ts'. It aims to guide developers on how to effectively integrate and utilize the engine's features while avoiding common pitfalls. The 'Dos' section emphasizes correct usage, while the 'Don'ts' section highlights potential issues to avoid. ```markdown ## Dos and Don'ts ### ✅ Do * Follow the recommended patterns for game state management. * Utilize the provided type definitions for clarity and safety. * Refer to the example implementation for practical guidance. ### ❌ Don't * Avoid direct manipulation of the game state outside of defined functions. * Do not bypass the `onHandleGameFlow` function for critical game logic. * Ensure all custom symbols and modes adhere to the expected structure. ``` -------------------------------- ### Board Service: Set Symbols Per Reel Source: https://slot-engine.dev/docs/core/game-context/board-service Temporarily sets the number of symbols per reel. This value is persisted until changed by the user or until the simulation resets or starts. ```javascript ctx.services.board.setSymbolsPerReel(symbolsPerReel) ``` -------------------------------- ### Create Slot Game Configuration - Slot Engine Source: https://context7_llms Initializes a slot game configuration, defining the game flow within the onHandleGameFlow hook. ```typescript export const game = createSlotGame({ /* the rest of your configuration */ hooks: { onHandleGameFlow(ctx) { // implement your game here }, }, }) ``` -------------------------------- ### Get Anticipation State Source: https://slot-engine.dev/docs/core/game-context/board-service The `getAnticipation()` function returns an array of booleans representing the anticipation state for each reel. This state can be used to visually indicate potential free spins. ```typescript ctx.services.board.getAnticipation() ``` -------------------------------- ### Create Slot Game Instance Source: https://context7_llms Initializes a new slot game using `createSlotGame` with basic configuration details. This function requires a configuration object that includes game ID, name, maximum win multiplier, padding for symbols, scatter-to-freespins mapping, symbol definitions, game modes, user state, and hooks. ```typescript import { createSlotGame, SPIN_TYPE } from "@slot-engine/core" export const game = createSlotGame({ id: "my-game", name: "My Game", maxWinX: 5000, padSymbols: 1, scatterToFreespins: { [SPIN_TYPE.BASE_GAME]: { 3: 10, 4: 12, 5: 15, }, [SPIN_TYPE.FREE_SPINS]: { 3: 6, 4: 8, 5: 10, }, }, symbols: {}, gameModes: {}, userState: {}, hooks: { onHandleGameFlow(ctx) {} }, }) ``` -------------------------------- ### Get Reel Set by ID - Slot Engine API Source: https://slot-engine.dev/docs/core/game-context/game-service Retrieves a specific reel set from the slot engine based on its unique identifier and the game mode. This function is crucial for dynamically loading game configurations. ```javascript ctx.services.game.getReelsetById(gameMode, id) ``` -------------------------------- ### Create Slot Game and Configure Simulation (JavaScript) Source: https://slot-engine.dev/docs/core/game-tasks/simulation This snippet shows how to initialize a slot game using `createSlotGame` and then configure its simulation parameters. It includes settings for simulation runs, base and bonus amounts, and concurrency. This is useful for testing and balancing game mechanics. ```javascript const game = createSlotGame({ // ... other game configurations }); game.configureSimulation({ simRunsAmount: { base: 100_000, bonus: 100_000, }, concurrency: 16 }); ``` -------------------------------- ### Get Random Item from Array Source: https://slot-engine.dev/docs/core/game-context/rng-service The `randomItem()` method retrieves a random element from a given array. It takes an array as input and returns a single element of the same type as the array elements. This function is part of the `ctx.services.rng` module. ```javascript ctx.services.rng.randomItem() ```