Skip to the content

Tenka天下

Play seeded world conquest for two to six, with dice battles, cards, computer players and saved games.

Tenka means the world under heaven in Japanese. About the name

Contents

Reference · Rules, maps and records

TenkaGametype

A game, as its moves make it. Only the table — seed, players, rounds, placing — and moves are ever kept (encodeTenka); everything else is read again from them, dice and all, since every die is drawn from the game's own seeded random (rng). A kept game can never hold a world its moves do not make.

Import it

import type { TenkaGame } from "@johnmorrisdotca/tenka";

Definition

type TenkaGame = {
    map?: TenkaMapKey;
    seed: number;
    players: readonly string[];
    rounds: number;
    placing: TenkaPlacing;
    moves: readonly TenkaMove[];
    rng: number;
    first: TenkaSeat;
    round: number;
    toPlay: TenkaSeat;
    phase: TenkaPhase;
    owners: readonly TenkaOwner[];
    armies: readonly number[];
    hands: readonly (readonly TenkaCard[])[];
    deck: readonly TenkaCard[];
    discards: readonly TenkaCard[];
    trades: number;
    reserve: number;
    setUpLeft: readonly number[];
    conquered: boolean;
    occupying: {
        from: number;
        to: number;
        least: number;
    } | null;
    shifting: {
        from: number;
        to: number;
    } | null;
    lastRoll: TenkaRoll | null;
    lastTrade: TenkaTrade | null;
    lastDraw: {
        seat: TenkaSeat;
        card: TenkaCard;
    } | null;
    out: readonly boolean[];
    lastOut: {
        seat: TenkaSeat;
        by: TenkaSeat;
    } | null;
    winners: readonly TenkaSeat[];
};

Members

NameTypeDescription
map (optional)TenkaMapKey | undefined

The map it is played on; left out for the world, so a game saved before there was a choice reads as it did.

seednumber

The seed every shuffle, deal and die of this game is drawn from.

playersreadonly string[]

The names given at the table, in seat order: "" for one left blank.

roundsnumber

How many rounds before the count: TENKA_WORLD_ROUNDS for the whole world.

placingTenkaPlacing
movesreadonly TenkaMove[]

Every move made, in order: the game's whole record.

rngnumber

The random's state after everything drawn so far.

firstnumber

The seat that plays first each round.

roundnumber

The round being played, from 1.

toPlaynumber
phaseTenkaPhase
ownersreadonly number[]

Per territory, who holds it.

armiesreadonly number[]

Per territory, how many armies stand there.

handsreadonly (readonly number[])[]

Per seat, the cards in hand.

deckreadonly number[]

The cards still to draw, top first.

discardsreadonly number[]

The cards traded in, shuffled back when the deck runs out.

tradesnumber

How many sets have been traded in this game, by anybody: what the next set is worth.

reservenumber

Armies waiting to be placed this turn.

setUpLeftreadonly number[]

Per seat, starting armies still to place by hand.

conqueredboolean

Whether the player to move has taken a territory this turn: a card at its end.

occupying{ from: number; to: number; least: number; } | null

The territory just taken, and the least that must move in.

shifting{ from: number; to: number; } | null

The two territories of the fortifying move chosen, waiting for how many.

lastRollTenkaRoll | null

The last roll of this turn, for the table to see.

lastTradeTenkaTrade | null
lastDraw{ seat: TenkaSeat; card: TenkaCard; } | null

The card drawn at the end of the last turn, and by whom.

outreadonly boolean[]

Per seat, whether they are out: no territory left.

lastOut{ seat: TenkaSeat; by: TenkaSeat; } | null

The last player knocked out, and by whom.

winnersreadonly number[]

On a finished game, every seat that won. Empty while playing.

Examples

import { startTenka } from "@johnmorrisdotca/tenka";
import type { TenkaGame } from "@johnmorrisdotca/tenka";

const game = startTenka(10,["Seat 1","Seat 2"],42)!;
const value: TenkaGame = game;
console.log(value);
{
  seed: 42,
  players: [ 'Seat 1', 'Seat 2' ],
  rounds: 10,
  placing: 'auto',
  moves: [],
  rng: 2192484137,
  first: 1,
  round: 1,
  toPlay: 1,
  phase: 'reinforce',
  owners: [
     1,  1,  1, 0, 1,  0, -1, -1, -1, -1,
     1, -1, -1, 1, 1,  0,  1,  0, -1,  0,
     0, -1, -1, 1, 0, -1,  1,  1,  0,  0,
     0,  1,  1, 0, 0,  0, -1,  1, -1,  0,
    -1, -1
  ],
  armies: [
    4, 2, 4, 1, 3, 1, 1, 4, 3, 2,
    4, 4, 2, 3, 2, 4, 1, 3, 4, 7,
    4, 2, 1, 4, 3, 6, 3, 2, 3, 4,
    3, 2, 5, 1, 1, 2, 1, 1, 4, 3,
    3, 3
  ],
  hands: [ [], [] ],
  deck: [
    39, 24,  6, 15, 43, 14, 17, 27, 33,  5,
    41, 19, 36, 38, 25, 32,  4, 16, 21,  1,
    18, 42, 11,  8,  0, 30,  3, 26, 12, 28,
    40, 29, 22, 34, 23,  2, 37, 10,  7, 20,
    35, 31, 13,  9
  ],
  discards: [],
  trades: 0,
  reserve: 4,
  setUpLeft: [ 0, 0 ],
  conquered: false,
  occupying: null,
  shifting: null,
  lastRoll: null,
  lastTrade: null,
  lastDraw: null,
  out: [ false, false ],
  lastOut: null,
  winners: []
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tenka 2.2.0.