Skip to main content

Module weigh

Module weigh 

Source
Expand description

Weighted features: a bot’s score as the game’s named counts times weights from a file, and personas (how a bot thinks and what it cares about) as data.

A game declares a fixed list of feature names (["won", "lost", "hp lost"]) and a function that counts each of them between the state a decision began in and where a copy got to. Weights holds what one kind of player cares about each, read by name, and its score is the sum of count × weight, in integers that saturate rather than wrap. Weighted pairs the two into an Evaluate for the bots that plan. What a feature means and how it is counted stay the game’s.

A Persona is one kind of player: its PlanSettings, its weights by name, and whatever the game adds of its own (a game mode, a difficulty). A map of them by name is a personas file:

{
    "careful": (
        settings: (width: 4, candidates: 10, depth: 6, samples: 2, temperature: 0),
        weights: {"won": 1000, "hp lost": -4},
        game: (mode: Classic),
    ),
}

A weight naming a feature the game didn’t declare is an error (UnknownFeature); a feature with no weight weighs 0.

Structs§

Persona
One kind of player: how it thinks, what it cares about, and the game’s own extras X (a game mode, a difficulty; () for none).
UnknownFeature
A weight naming a feature the game didn’t declare.
Weighted
An Evaluate made of the game’s counts and a kind of player’s weights: it scores weights.score(&counts(start, end, side)).
Weights
What a kind of player cares about each of a game’s N features, in the order of the game’s names.