Reference · Rules, maps and records
sensibleTenkaMovefunction
The computer player's move: one the rules accept, chosen as a person might.
random is any function returning a number from 0 up to 1, such as
Math.random; give it a seeded one and the computer plays the same game
every time.
Import it
import { sensibleTenkaMove } from "@johnmorrisdotca/tenka";
Definition
function sensibleTenkaMove(game: TenkaGame, random: () => number): TenkaMove
Parameters
| Name | Type | Description |
|---|---|---|
game | TenkaGame | The current native game state. |
random | () => number | A random source returning values in [0,1). |
Returns
TenkaMove
The computer player's move: one the rules accept, chosen as a person might. random is any function returning a number from 0 up to 1, such as Math.random; give it a seeded one and the computer plays the same game every time.
Examples
import { sensibleTenkaMove, startTenka } from "@johnmorrisdotca/tenka";
const game = startTenka(10,["Seat 1","Seat 2"],42)!;
console.log(sensibleTenkaMove(game,()=>0.5));{ kind: 'place', territory: 32, armies: 4 }What it prints (run when this page was built)