Skip to content

Getting Started with hizi engine generator

Installation

TypeScript

The generator is published to the public npm registry — install it like any other npm package:

bash
npm install @hizi.io/engine-generator
bash
pnpm add @hizi.io/engine-generator
bash
yarn add @hizi.io/engine-generator

Python

Requires Python 3.10+.

bash
pip install "git+ssh://[email protected]:7022/hizi/hizi-engine.git#subdirectory=generator-py"
bash
pip install "git+https://code.hoelle.games/hizi/hizi-engine.git#subdirectory=generator-py"
bash
cd generator-py
pip install .

Virtual environment (Python)

It's recommended to use a virtual environment:

bash
python -m venv .venv
source .venv/bin/activate       # bash/zsh
# source .venv/bin/activate.fish  # fish
# .venv\Scripts\activate          # Windows

Quick Start

1. Import the Generator

typescript
import { HiziEngineGenerator } from '@hizi.io/engine-generator';
python
from hizi_engine_generator import HiziEngineGenerator, AddResultOptions

2. Create an Instance

typescript
const generator = new HiziEngineGenerator();
python
gen = HiziEngineGenerator()

3. Start Output

Before recording results, open an output directory to stream to:

typescript
await generator.start('./output/');
// Will create ./output/entries.jsonl and ./output/scenarios.jsonl
python
gen.start('./output/')
# Creates ./output/entries.jsonl and ./output/scenarios.jsonl

4. Run Your Simulation and Record Results

For each outcome your game engine produces, call addResult() / add_result():

typescript
// Your game engine produces an outcome
const win = 50;
const scenario = {
  result: {
    reelIndexes: [12, 45, 78],
    visibleSymbols: [
      [2, 3, 1],
      [2, 2, 2],
      [4, 0, 5],
    ],
  },
};

generator.addResult(scenario, {
  win,
  metaTags: ['medium-win'],
});
python
# Your game engine produces an outcome
win = 50
scenario = {
    'result': {
        'reelIndexes': [12, 45, 78],
        'visibleSymbols': [
            [2, 3, 1],
            [2, 2, 2],
            [4, 0, 5],
        ],
    },
}

gen.add_result(scenario, AddResultOptions(feature='basegame', win=win, meta_tags=['medium-win']))

Repeat this for every spin in your simulation - typically hundreds of thousands or millions of spins.

5. Finalize Output

typescript
await generator.end();
python
gen.end()

That's it. The output files are ready to be loaded by the hizi engine.