Skip to main content

CLI Reference

LSJI includes a command-line interface for training and playing without writing code.

Installation

# Global install
npm install -g lsji

# Or use npx
npx lsji --help

Commands

lsji train

Train the agent.

lsji train [options]

Options:

OptionDescriptionDefault
--episodes <n>Number of training episodes200
--pattern <0-3>Training pattern0
--batch-size <n>Database batch size200
--opponent <type>Opponent strategyrandom
--storage <type>Storage backendsqlite
--db-path <path>Database file path./lsji.db
--alpha <n>Learning rate0.1
--gamma <n>Discount factor0.9
--epsilon <n>Exploration rate0.1
--jsonOutput as JSONfalse

Training Patterns:

  • 0 — Random actions
  • 1 — Always Rock
  • 2 — Counter previous action
  • 3 — Sequential (0,1,2,0,1,2...)

Opponent Strategies:

  • random — Random actions
  • always_rock — Always plays Rock
  • counter — Counters agent's previous action
  • sequential — Cycles through actions

Examples:

# Default training
lsji train --episodes 500

# Train against always-rock opponent
lsji train --episodes 100 --pattern 1 --opponent always_rock

# Train with custom hyperparameters
lsji train --episodes 1000 --alpha 0.05 --gamma 0.95 --epsilon 0.2

# Use memory storage (ephemeral)
lsji train --episodes 100 --storage memory

lsji play

Play a single game against the agent.

lsji play --hand <0|1|2> [options]

Options:

OptionDescription
--hand <0|1|2>Your hand: 0=Rock, 1=Scissors, 2=Paper
--opponent <type>Opponent strategy
--storage <type>Storage backend
--db-path <path>Database file path
--jsonOutput as JSON

Examples:

lsji play --hand 0 # Play Rock
lsji play --hand 1 # Play Scissors
lsji play --hand 2 --json # Play Paper, JSON output

lsji status

Show system status and statistics.

lsji status [options]

Options:

OptionDescription
--storage <type>Storage backend
--db-path <path>Database file path
--jsonOutput as JSON

Example:

lsji status --json

Output:

{
"status": "running",
"todayTotal": 42,
"limit": 90000,
"performance": [
{ "mode": "train", "total": 1000, "win_rate": 65.5 },
{ "mode": "test", "total": 50, "win_rate": 72.0 }
],
"aiBrain": [
{ "state": "0", "action": 0, "q_value": 0.45 },
{ "state": "0", "action": 1, "q_value": 0.12 }
]
}

lsji start

Enable training and play.

lsji start [options]

lsji stop

Disable training and play (system paused).

lsji stop [options]

lsji help

Show help message.

lsji help
lsji --help
lsji -h

Environment Variables

VariableDescriptionDefault
LSJI_STORAGEDefault storage backendsqlite
LSJI_DB_PATHDefault database path./lsji.db

Examples

Full Training Session

# Start fresh
rm -f lsji.db

# Train against random opponent
lsji train --episodes 500 --opponent random

# Train against counter opponent
lsji train --episodes 500 --opponent counter

# Check progress
lsji status --json

# Play a few games
lsji play --hand 0
lsji play --hand 1
lsji play --hand 2

Using Memory Storage (CI/Testing)

lsji train --episodes 100 --storage memory
lsji play --hand 0 --storage memory
lsji status --storage memory

Custom Hyperparameters

lsji train \
--episodes 2000 \
--alpha 0.05 \
--gamma 0.95 \
--epsilon 0.2 \
--opponent random \
--storage sqlite \
--db-path ./custom.db