P-LensOpen the app

Pachislot

Japanese pachislot, explained

Pachislot (パチスロ) is the slot machine of Japan's pachinko parlors: three reels, a lever and three stop buttons, played with tokens. This page explains the machine for readers who have never played one, the setting levels the parlor chooses and players try to read, and how P-Lens reads them from the data counter.

The machine

Three reels and three buttons

A pachislot machine has three reels behind a window, each a strip of symbols. A game goes like this: the player puts in tokens, called medals (メダル), three a game on most machines; pulls a lever, which sets the reels spinning; and presses three stop buttons, one under each reel, to stop them one by one.

Whether a game wins, and what, is drawn by the machine the moment the lever is pulled. The stop buttons decide whether a win the draw gave is lined up: each reel can slide a few symbols after its button is pressed, enough to line up a win when the press was close, or to keep one from lining up that the draw did not give. Pressing at the right moment (目押し) matters for some wins and not for others.

Small wins (小役) come often and pay a few medals: a replay (リプレイ) gives the next game free, and fruit such as grapes (ブドウ) and cherries (チェリー) pay a few medals each. On their own they pay back less than the medals put in.

Bonuses

BIG, REG, AT and ART

The medals come mostly from bonuses. A machine of the older kind has two:

  • BIG (big bonus): a stretch of games that pays a large number of medals, a few hundred.
  • REG (regular bonus): a shorter one that pays fewer, often less than half as many.

Many of the machines on parlor floors now are AT machines instead. AT (assist time) is a stretch of games during which the machine shows the player which order to press the stop buttons in. Some small wins can only be lined up with the right order; told it, the player lines them up every time, and the medals grow game after game. ART (assist replay time) is AT combined with a raised chance of a replay, so fewer medals are spent per game while it lasts. AT machines usually reach their AT through stages of their own, chance zones (CZ) and the like, and many have a ceiling (天井): a number of games after which an AT is given.

Settings

Setting levels 1 to 6

Unlike a pachinko machine, a pachislot machine has a switch that changes how it pays: its setting (設定, set-tay), from 1 to 6. The parlor chooses each cabinet's setting, inside the cabinet, and does not show it. A higher setting makes some bonuses or small wins more likely, and raises the machine's payout rate (機械割, ki-kai-wa-ri), the medals paid out per medal put in over the long run.

Setting 1 typically pays out a little less than 100% and setting 6 more. The test machine in P-Lens' fixtures, for example, pays out 98.03% at setting 1 and 113.5% at setting 6 (expected.json). Spec sheets publish each setting's chances of the bonuses and some small wins, so a player who counts what a cabinet does can compare it with the setting it would be most like.

That is why players estimate settings. The setting decides most of what playing a cabinet is worth, and it is the one thing the cabinet does not say. What it does say is on the data counter.

The data counter

Above each machine sits a data counter (データカウンター, day-ta kau-n-tah), a display the parlor installs. It shows the games played on that cabinet so far that day, how many BIGs and REGs it has given, the games between them, and often the same for the previous days. On an AT machine, it shows the history of ATs and the games before each. Anyone walking past can read it, before sitting down or after.

Rental and exchange

Renting medals, and the exchange rate

Medals are rented at the machine. The price is capped by regulation at 20 yen a medal, plus consumption tax, and a 20-yen corner typically rents 46 medals for 1,000 yen, the figure P-Lens assumes when it is told nothing else. Parlors also have lower-rate corners, most often 5 yen a medal. Many newer machines (smart pachislot, スマスロ) keep the count of medals electronically instead of dropping physical ones into a tray; the play and the counting are the same.

The medals left at the end are exchanged for prizes at the parlor's counter, at the price they were rented at. The discount comes at the prize exchange shop, which buys the special prizes for cash. The exchange rate is stated as the medals it takes to get 100 yen there: 5 is equal exchange, and 5.6 is what P-Lens assumes for a 20-yen corner when told nothing else. Medals, like pachinko balls, can be left on deposit with the parlor. The parlor and its counter are covered on their own page, Japan's pachinko parlors.

In P-Lens

Reading the setting by Bayesian inference

P-Lens is a bookkeeping app for a player's own pachinko and pachislot results. For a pachislot play, it works out from the data counter's figures how likely each setting is, by Bayesian inference: what was thought likely before looking (the prior), times how likely the counter's figures are under each setting (the likelihood), gives how likely each setting is after looking (the posterior).

The likelihood

For a machine of bonuses, each game is taken to come up BIG, REG, a small win the player counted, or nothing counted, with each setting's published chances. The games nobody counted share what is left of the probability. From crates/pachislot-engine/src/posterior.rs:

/// The regular games' part of a stretch's log-likelihood: every count but
/// a watch's cues.
fn regular_log_likelihood(table: &SettingLevelTable, segment: &Segment) -> f64 {
    let chance = |id: &EntityId| -> f64 {
        table
            .events
            .iter()
            .filter(|event| event.answers_to(id))
            .map(|event| event.chance.value())
            .sum()
    };
    let (counted, covered, log) = segment
        .counts
        .iter()
        .filter(|(id, _)| !is_cue(table, id))
        .fold((0_u64, 0.0, 0.0), |(counted, covered, log), (id, count)| {
            let probability = chance(id);
            (
                counted + u64::from(*count),
                covered + probability,
                log + times(u64::from(*count), probability.ln()),
            )
        });
    let rest = u64::from(segment.games).saturating_sub(counted);
    log + times(rest, (-covered).ln_1p())
}

The product is taken in logarithms: the probability of 8,000 particular games is far too small a number for a float to hold. Each setting's log-likelihood is added to its log-prior, and the results are scaled back to shares summing to one. Figures impossible under every setting the prior allows are an error, ContradictoryEvidence, rather than the least impossible setting (the same file):

/// Each setting's prior weighed by what was seen under its table, as a
/// share of all of them.
fn weighed(
    spec: &NormalizedSpec,
    prior: Option<&Distribution>,
    seen: impl Fn(&SettingLevelTable) -> f64,
) -> Result<Posterior, InferenceError> {
    let logs: Vec<f64> = log_prior(spec, prior)?
        .into_iter()
        .zip(&spec.tables)
        .map(|(log_prior, table)| log_prior + seen(table))
        .map(|log| if log.is_nan() { f64::NEG_INFINITY } else { log })
        .collect();
    let total = log_sum_exp(&logs);
    if !total.is_finite() {
        return Err(InferenceError::ContradictoryEvidence);
    }
    Ok(Posterior {
        setting_levels: spec
            .setting_levels()
            .zip(logs)
            .map(|(setting_level, log)| (setting_level, (log - total).exp()))
            .collect(),
    })
}

An AT machine's history is read the same way, its ATs and the games before each walked through the machine's ceilings and modes, setting by setting.

Spec sheets also list screens a machine shows only under some settings: a trophy at the end of an AT that appears only at setting 4 or higher, say. Players call these 確定演出 (kakutei enshutsu, confirming effects). A formula may name each one with the settings it can be seen under. On the live screen the player marks it seen rather than counting it, since once is all it tells, and every setting it never appears under is given no likelihood at all: a trophy that says setting 4 or higher leaves settings 1 to 3 at 0%. Hints that are only likelier under high settings are counted instead, as the share of some event they appeared on, such as a dress on the round screen within an AT, and weighed against each setting's chance of it.

The prior

Nobody but the parlor knows how many cabinets it set high that day. P-Lens offers ten spreads of settings to start from, from a day the parlor collects to cabinets said to be part of an all-high row, and a player can choose a spread from the shared catalog instead. From core/pachislot/prior.ts:

/**
 * Each stock spread's shares of setting levels 1 to 6, in basis points,
 * harshest first. They are made here, not taken from anywhere: what people
 * who ran parlors and people who played for a living have said in public
 * agrees on the shape — an ordinary day is mostly 1 with some 2, seldom
 * above 4, its levels averaging 1.2 to 1.6; a day a parlor gives back
 * averages near 2 and brings 5 and 6 in; a day it collects is nearly all
 * 1 — and each spread here is one point within that shape. No level is
 * given nothing: a spread that rules a level out could never be argued out
 * of it by what the cabinet then does. `featured` is not a parlor's day
 * but a cabinet's standing on one: one of those the day's high levels were
 * said to be put in.
 */
const STOCK_SHARES: Readonly<Record<StockSpreadKey, readonly number[]>> = {
  collecting: [8200, 1300, 350, 100, 30, 20],
  "ordinary-harsh": [7000, 2000, 600, 300, 60, 40],
  ordinary: [6000, 2500, 900, 500, 60, 40],
  "ordinary-kind": [4500, 3000, 1300, 900, 200, 100],
  "event-weak": [5500, 2200, 800, 800, 350, 350],
  event: [4800, 2000, 700, 1100, 650, 750],
  "event-strong": [4000, 2000, 900, 1300, 800, 1000],
  "new-machine": [3500, 2400, 1700, 1200, 700, 500],
  "grand-opening": [4000, 2500, 1200, 1200, 500, 600],
  featured: [1000, 1000, 1000, 2500, 2000, 2500],
}

Where nobody chooses one, a play starts from ordinary, shown in the app as 通常営業(標準) (prior.ts). The prior matters as much as the counter does, and the app says under the odds which spread they were worked out under: 設定配分「…」のもとでの見込みです, "the odds under the spread …" (SettingLevelOdds.tsx).

A worked example

The test machine above has only two settings, 1 and 6, with BIG at 1 in 250 and 1 in 200 and REG at 1 in 400 and 1 in 250. Say its data counter shows 4,000 games, 20 BIGs and 14 REGs. The engine, called directly at v0.10.63, under two priors:

Prior (1 : 6)Setting 1Setting 6Payout
Even25.9%74.1%109.49%
90 : 1075.9%24.1%101.76%

The same 4,000 games read as probably setting 6 when the two were alike beforehand, and as probably setting 1 when one cabinet in ten was thought to be set high. The payout rate in the last column is each setting's weighed by the posterior. The figures were chosen for the example; the fixture has two settings rather than six, so the app's stock spreads, which share among six, are not used here.

On screen, the posterior is read in three figures players use. From core/pachislot/setting-level-reading.ts:

/**
 * What a posterior over settings says, in the words players use: how likely a
 * high setting is, the setting the odds average to, and the single most
 * likely one. The engine gives the distribution; these only read it.
 */
export interface SettingLevelReading {
  /** 高設定期待度: the chance the setting is at least `threshold`. */
  readonly highShare: number
  readonly threshold: number
  /** 期待設定: the settings averaged by their chance, `3.22` and the like. */
  readonly averageSettingLevel: number
  /** 最有力: the most likely setting; where several are as likely as each other, the middle one of them, the lower where two are in the middle. */
  readonly mostLikely: number | undefined
}

Theoretical value

What the settings make a play worth

Theoretical value (仕事量, shi-go-to-ryoh, as players call it) is, in P-Lens: for the plays actually done, the cumulative theoretical gain or loss that occurred under their calculation conditions. For a pachislot play, the calculation condition is the machine's figures for each setting, the posterior over its settings, and the parlor's rental and exchange. Each setting's figures, its payout rate and the medals a game gains or loses on average, are weighed by how likely that setting is. From crates/pachislot-engine/src/theoretical.rs:

/// A figure of each setting level weighed by how likely it is. A weight for
/// a setting the analysis does not have counts for nothing.
fn weighted(
    analysis: &Analysis,
    weights: &[(SettingLevel, f64)],
    read: fn(&SettingLevelFigures) -> f64,
) -> f64 {
    weights
        .iter()
        .filter_map(|(setting_level, weight)| {
            analysis
                .setting_levels
                .iter()
                .find(|figures| figures.setting_level == *setting_level)
                .map(|figures| weight * read(figures))
        })
        .sum()
}

The medals over the games played are then priced at the exchange rate, less the extra that renting with cash cost above a medal's exchange value, on the share of medals rented. From theoretical.rs:


/// Medals over regular games, in yen on the player's terms.
///
/// The rental spread is charged on the share of the medals played that was
/// rented, and the replay fee on the share drawn from savings:
/// `games × bet × spread per medal`. Played from medals in hand, a medal
/// costs nothing beyond its value.
fn yen_of(medals: f64, games: f64, bet: u32, play: PlayConditions) -> f64 {
    medals * play.medal_value() - games * f64::from(bet) * play.spread_per_medal()

The value is written to the play's entry in the book as a virtual posting, (統計:期待値), beside the cash and medals, never among them; a value inferred for a play recorded afterwards goes to 統計:期待値:推定. The article Beyond money: hledger as an aggregation engine goes through the posting and its account. The pachinko page shows an entry.

The app also has a calculator, 期待値算出, that works out the expected value of a play not yet made, at each setting, from games and terms the player types in (ValueSheet.tsx). Both figures are labelled 期待値 (ki-tai-chi) in the app. The one kept in the book belongs to plays that took place.

Machine data

A machine as components

A machine's figures for each setting are worked out on the device from its specification. As with pachinko, a specification is a set of entities, here the bonuses and small wins, each made of the components it has. From crates/pachislot-domain/src/spec.rs:

/// A machine as an ECS world, in the words pachislot uses: its entities —
/// the bonuses and small wins a regular game can come up with — each made of
/// whichever components it has, and the resources the whole machine shares.
///
/// A feature is a component: an entity is a bonus because it has `bonus`, a
/// replay because it has `replay`, a part of a bonus because it has `part_of`.
/// A machine the model grows to cover gains a component, not a new shape.
/// The engine queries the components and derives one table of outcomes per
/// setting.
#[derive(Clone, Debug, PartialEq)]
pub struct Spec {
    /// Every entity, in the order it was made: the order its outcomes take.
    pub entities: Vec<EntityId>,
    pub components: Components,
    pub resources: Resources,
}

The test machine of the example, its entities and components (made-up/spec.json); its last line says it has settings 1 and 6 and a bet of three medals a game:

{
  "v": 1,
  "entities": ["big", "reg", "reg-solo", "reg-cherry", "grape", "cherry", "replay"],
  "components": {
    "label": {
      "big": "BIG",
      "reg": "REG",
      "reg-solo": "単独REG",
      "reg-cherry": "チェリー重複REG",
      "grape": "ブドウ",
      "cherry": "チェリー",
      "replay": "リプレイ"
    },
    "chance": {
      "big": [
        { "settingLevel": 1, "value": { "type": "ratio", "numerator": 1, "denominatorHundredths": 25000 } },
        { "settingLevel": 6, "value": { "type": "ratio", "numerator": 1, "denominatorHundredths": 20000 } }
      ],
      "reg-solo": [
        { "settingLevel": 1, "value": { "type": "percent", "basisPoints": 20 } },
        { "settingLevel": 6, "value": { "type": "percent", "basisPoints": 30 } }
      ],
      "reg-cherry": [
        { "settingLevel": 1, "value": { "type": "percent", "basisPoints": 5 } },
        { "settingLevel": 6, "value": { "type": "percent", "basisPoints": 10 } }
      ],
      "grape": [
        { "settingLevel": 1, "value": { "type": "percent", "basisPoints": 1600 } },
        { "settingLevel": 6, "value": { "type": "percent", "basisPoints": 1700 } }
      ],
      "cherry": [
        { "settingLevel": 1, "value": { "type": "percent", "basisPoints": 250 } },
        { "settingLevel": 6, "value": { "type": "percent", "basisPoints": 250 } }
      ],
      "replay": [
        { "settingLevel": 1, "value": { "type": "percent", "basisPoints": 1370 } },
        { "settingLevel": 6, "value": { "type": "percent", "basisPoints": 1370 } }
      ]
    },
    "payout": { "big": 240, "reg": 96, "grape": 8, "cherry": 2 },
    "bonus": ["big", "reg"],
    "replay": ["replay"],
    "partOf": { "reg-solo": "reg", "reg-cherry": "reg" }
  },
  "resources": { "settingLevels": [1, 6], "bet": 3 }
}

Its REG is two entities, a REG alone and one with a cherry, each partOf the REG the counter shows. A data counter counts REGs, not how they came, so the likelihood above reads the two as one.

Further

Further reading