本文へ移動

Tenka天下

2〜6人で、シードから始まる世界征服ゲームを遊べます。さいころでの戦い、カード、コンピューターの相手、ゲームの保存に対応します。

「天下」は、天の下に広がる世界を表す言葉です。 名前について(英語)

目次

リファレンス

ルール・地図・棋譜

import { … } from "@johnmorrisdotca/tenka";

最小化と gzip 圧縮をしたサイズは 14.9 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Tenka 天下: the classic world-conquest game on a map of the modern world, for two to six players, as plain functions over plain data.

A game is a value. startTenka deals one from a seed, playTenka makes a move and returns the next game (or null for a move the rules refuse), and every shuffle, deal and die is drawn from the game's own seeded random, so a game replays exactly from its seed and its moves (encodeTenka, decodeTenka). Nothing here touches the DOM, a clock or Math.random.

The map's outlines, which only a board drawing the world needs, are their own entry, @johnmorrisdotca/tenka/shapes, and so is the table that draws and plays a game in plain DOM, @johnmorrisdotca/tenka/ui.

エクスポート

名前種類概要
areNeighbours関数Whether two territories are neighbours, by land or by sea.
armiesHeld関数How many armies an owner has on the map.
attacksOpen関数Every attack open now: from each territory of theirs with armies to spare, on each neighbour somebody else holds, with each number of dice — and the same attack again and again until it is decided.
battleLosses関数WHO LOSES WHAT: the highest die of each side compared, then the next highest, as many pairs as the side with fewer dice threw.
beginTurn関数A turn starting for seat: its armies worked out, nothing yet taken, nothing rolled.
boardOf関数The map an argument names, and the world for anything that is not one: these functions are handed to an array's map and filter (deck.map(cardKind)), which pass an index where the map would go.
cardKind関数What a card shows: land, sea or air for a territory's card, in turn round the map; wild for a wild card.
cardTerritory関数The territory a card shows, or null for a wild card.
choiceNow関数A choice made on an earlier map, read against this one: only what still stands, and a number of armies the move can take.
cleanTenkaName関数A name as the table typed it, tidied: spaces run together, trimmed, cut to TENKA_NAME_MOST.
connectedOwn関数Every territory of the same owner reachable from this one through that owner's own territories, in order; never the territory itself.
continentNameIn関数A continent's name in a table of strings, by its key ("northAmerica", "asia"…).
continentsHeld関数The continents a seat holds every territory of.
counted関数THE COUNT, when the last round is over: whoever holds the most territories wins; level on territories, whoever has more armies on the map; level on both, they share the win.
decodeTenka関数A kept game read back, or null for nothing kept, or for text that is not a game these rules can play out again: a browser's storage is somebody's to edit, and a half-understood game is worse than none.
defendDice関数The dice a defender holding armies throws: as many as allowed, since more never hurts the defence.
encodeTenka関数A game as text to keep: its table and its moves.
endOfTurn関数THE END OF A TURN: a card for a player who took a territory in it, then the next player still in.
finished関数The game ended, with these seats winning.
isSet関数Whether three cards make a set: three of one kind, one of each kind, or any two with a wild card (a wild card stands for whatever the set needs).
isTenkaSeed関数Whether a number is a seed a game can be dealt from: a whole number from 0 to TENKA_SEED_MOST.
isTenkaTable関数Whether a game this long for this many players is one Tenka is offered for.
isTerritory関数Whether a number is a territory of the map.
isWild関数Whether a card is one of the two wild cards.
marksFor関数What the map lights up for a choice.
mostAttackDice関数The most dice an attacker may throw from a territory holding armies: one army always stays behind.
mustTrade関数Whether the player to move must trade cards before anything else: five or more in hand while reinforcing.
nextRandom関数The next number from the random at state, in [0, 1), and the state after it.
nextSeatIn関数The next player still in after seat, round the table; the neutral army never takes a turn.
NO_CHOICE定数Nothing chosen: where a turn, and a table, start.
playTenka関数The game after the player to move makes move, or null when they may not: a move for another phase, a territory not theirs, a neighbour that is not one, dice they have not the armies for, a set that is not a set.
randomBelow関数A whole number from 0 to below - 1, and the state after it.
readTenkaMove関数A kept move read back, or null for anything that is not one.
reinforcementFor関数THE ARMIES A TURN BRINGS: one for every three territories held, never fewer than three, and each continent held whole adds its bonus.
replayTenka関数A game made again from its table and its moves, or null if any move could not have been made when it was.
sensibleTenkaMove関数The computer player's move: one the rules accept, chosen as a person might.
setsIn関数Every set a hand holds, each as its three cards smallest first, in order.
shuffled関数A list in a random order (Fisher and Yates), and the state after it; the list given is left alone.
startTenka関数A NEW GAME, all of it drawn from seed: who goes first; the territories shuffled and dealt round the table one at a time from that player, each with one army on it (at a table of two, dealt three ways, the neutral army taking every third); the cards shuffled; and each player's starting armies (TENKA_STARTING_ARMIES) less the ones already on their territories — scattered at random when placing is auto, or left to be placed by hand, one at a time round the table.
tapTerritory関数What tapping territory does now: a new choice, and the move to make at once, if the tap is one.
TENKA_ATTACK_DICE定数The most dice an attacker throws.
TENKA_CARD_KINDS定数The three kinds a territory's card shows, in turn round the map, and the wild card that is any of them.
TENKA_CONTINENTS定数The world's six continents, each with the territories in it.
TENKA_CSV_COLUMNS定数The columns of the CSV export, in order.
TENKA_DECK定数Every card in the game: the territories' cards, then the wild cards.
TENKA_DEFEND_DICE定数The most dice a defender throws.
TENKA_EXPORT_FORMAT定数The shape of the JSON this package writes.
TENKA_FEWEST_PLAYERS定数The fewest at a table: two, joined by the neutral army.
TENKA_LEAST_REINFORCEMENT定数The fewest armies a turn brings, however little is held.
TENKA_LENGTHS定数The lengths of game startTenka takes, in rounds: 10, 20 and 60.
TENKA_MAP_LIST定数The maps in the order a set-up offers them: the world first, the usual one.
TENKA_MAPS定数Every map a game may be played on, by key.
TENKA_MEDIUM_ROUNDS定数The medium game: twenty rounds, then the count.
TENKA_MOST_PLAYERS定数The most at a table: six.
TENKA_MOVES定数The kinds of move, by name: what goes in a move's kind.
TENKA_MUST_TRADE_AT定数With this many cards in hand a player must trade before placing; after knocking somebody out, down to fewer than this.
TENKA_NAME_MOST定数The longest name a seat keeps.
TENKA_NEUTRAL定数The owner of the territories nobody at a table of two holds: the neutral army, which never takes a turn.
TENKA_PHASES定数The phases of a turn, by name: compare game.phase with these rather than with text typed out.
TENKA_PLACING定数How the starting armies are placed: scattered at random (auto), or by the players in turn (hand).
TENKA_SEED_MOST定数The largest seed a game keeps: the random's state is one 32-bit number.
TENKA_SHORT_ROUNDS定数The short game: ten rounds, then the count.
TENKA_STARTING_ARMIES定数THE ARMIES EACH PLAYER STARTS WITH, by how many are playing: the standard table.
TENKA_STRINGS定数The package's words in each language it speaks: TENKA_STRINGS.en, TENKA_STRINGS.ja.
TENKA_TERRITORIES定数The world's territories: the map a game is played on unless it says otherwise.
TENKA_TERRITORIES_PER_ARMY定数How many territories held bring one army each turn: three.
TENKA_TERRITORY_CARD_BONUS定数The armies placed straight onto a territory the trader holds, when a card of the set shows it.
TENKA_TERRITORY_COUNT定数How many territories the world has: forty-two.
TENKA_TRADE_STEP定数How much more each set is worth than the last, once TENKA_TRADE_VALUES runs out: 20, 25, 30…
TENKA_TRADE_VALUES定数WHAT A SET OF CARDS IS WORTH, by how many sets anybody has traded in before it: 4, 6, 8, 10, 12, 15, and five more for every set after that — the escalating standard schedule.
TENKA_VERSION定数The version of this package, as package.json has it.
TENKA_WILD定数The kind of a wild card, which stands for whatever a set needs.
TENKA_WILD_CARDS定数How many wild cards are in the deck.
TENKA_WORLD_ROUNDS定数The whole world: played to the last player standing, and counted after sixty rounds if nobody is.
tenkaAgain関数The same table again, from nothing, with a new seed: a new deal, a new first player, new dice.
TenkaCard型A territory's card (0–41) or a wild card (42, 43).
TenkaCardKind型What a card shows: one of three kinds, or a wild card that stands for any of them.
TenkaChoice型A choice made on the map and not yet a move: where from, where to, and how many armies (tapTerritory).
tenkaContinent関数A continent of a map by its key.
TenkaContinent型A continent: its name, the armies holding all of it is worth each turn, and its territories.
TenkaContinentKey型A continent of any map, by key: the world's continents and Europe's regions.
tenkaDailySeed関数Today's seed, the date as a number: 2026-10-01 is 20261001.
tenkaDay関数The day a moment falls on, in UTC, written YYYY-MM-DD.
tenkaDeckFor関数Every card of a game on this map: a card for each territory, numbered as the territories are, then the wild cards.
TenkaEuropeRegionKey型Europe's eleven regions, by key: the continents of the Europe map.
tenkaExported関数A game as the JSON export's object: its table, its moves, and where it stands.
TenkaExported型A whole JSON export of one game: what tenkaToJSON writes and tenkaFromJSON reads.
tenkaFromJSON関数A game from JSON that tenkaToJSON wrote, or text that encodeTenka did.
TenkaGame型A game, as its moves make it.
TenkaLocale型The languages the package speaks: English and Japanese.
TenkaMap型A map as the rules read it: its territories, its continents and each territory's neighbours by land and by sea.
TenkaMapKey型The maps a game may be played on.
TenkaMapMarks型What the map lights up for a choice (marksFor): the territory chosen, what it can reach, and the target.
tenkaMapOf関数The map a game is played on: the one it was started on, and the world for a game saved before there was a choice.
TenkaMove型A move, as playTenka takes it.
TenkaMoveKind型The kinds of move, by name.
tenkaMoves関数Every move the player to move may make now, each one playTenka accepts.
tenkaNeighbours関数A territory's neighbours, by land and by sea.
tenkaOver関数Whether the game is over.
TenkaOwner型Who holds a territory: a seat, or TENKA_NEUTRAL.
TenkaPhase型Where a turn is.
TenkaPlacing型Starting armies placed at random, or by hand in turn.
tenkaPlayerName関数A seat's name as the table reads it: the one given, or "Player 3".
tenkaRecord関数THE RECORD OF A GAME, move by move, with the dice and everything else each move brought: made by playing the game again from its seed.
TenkaRecordEntry型One move of a game's record, with what came of it: what the text and the CSV are written from.
TenkaRoll型One roll of the dice — or the last of a run of them (blitz) — what each side threw, highest first, and what each lost in all.
tenkaSay関数A line from a table of strings with its braces filled in: tenkaSay(strings.moveIn, { n: 3 }) is "Move 3 in".
TenkaSeat型A player's place round the table: 0 for the first name given, up to 5.
TenkaShapes型How the world is drawn, in map units (tenkaShapes.data.ts, written by scripts/map.mjs).
tenkaStrings関数The table of strings for a locale with a page's own words laid over it.
TenkaStrings型Every table word, including local embed error feedback.
TenkaTerritoryData型One territory as the map script writes it: neighbours by land and by sea are indices into the same list.
tenkaToCSV関数A game as CSV, a row to a move, for a spreadsheet: TENKA_CSV_COLUMNS.
tenkaToJSON関数A game as JSON, two spaces deep, with the format's number first.
tenkaToText関数A game as plain text, a line to a move, for a chat or a log: who placed what where, every throw of the dice, every territory taken, and how it ended.
TenkaTrade型The last set of cards traded in, for the table to see: by whom, for how many, and the territory that got two more.
TenkaWorldContinentKey型The world's six continents, by key.
territoriesHeld関数How many territories an owner holds.
territoryNameIn関数A territory's name in a table of strings, by its key (TENKA_TERRITORIES[n].key, such as "alaska"); "" for a key that is no territory's.
throwDice関数count dice, highest first, and the state after them.
tradeValue関数What the next set traded in is worth, when trades sets have been traded before it: 4, 6, 8, 10, 12, 15, 20, 25…
writeTenkaMove関数A move as the short list it is kept as — and sent as, to the other devices at a table played on several.

ソースを見るGitHub で編集@johnmorrisdotca/tenka 2.2.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。