Asobiai SDK
Tallies
Cast a vote with AIGame.tally and read everyone's totals with AIGame.getTally. Use it for polls, "how many moves did everyone need today" charts, or training data for games that get smarter as people play. Only the totals are kept, never who chose what.
v2.7.0Check it from your game with window.AIGame?.version.Changelog
Usage
// Cast one vote (one vote per name per play)
window.AIGame?.tally("favorite-stage", "forest");
// Several at once (up to 10). For a daily puzzle, put the date in the name
window.AIGame?.tally({ "d20261024.result": "solved", "d20261024.moves": 5 });
// Read them
const t = await window.AIGame?.getTally("d20261024.moves");
// => { total: 128, counts: { "4": 12, "5": 61, "6": 55 } } (null outside Asobiai)
const many = await window.AIGame?.getTally(["d20261024.result", "d20261024.moves"]);
// => { "d20261024.result": { total, counts }, "d20261024.moves": { total, counts } }- One vote per name per play (from when the game starts); later votes for the same name are not counted (counted is 0). Guests can vote too.
- Names use letters, numbers, _ . : - (max 64); choices are text or numbers (max 32 characters). Up to 100 choices per name, 10,000 names per game and 100 votes per play.
- Anyone can vote, so show only the choices your game defines (ignore unknown values). It's for casual stats and can't fully prevent padded votes.
- Works on Asobiai game pages and embeds. Votes from previews of unreleased versions and automated tests are not counted.
When a round ends, let players compare with everyone else. Cast a vote with window.AIGame?.tally({ "name": result }) (e.g. "d20261024.moves": moves for a daily puzzle), read { total, counts } with window.AIGame?.getTally(["name", …]) and show a distribution chart or "x% solved it". Names use only letters, numbers, _ . : -. Show only the choices your game defines and ignore unknown values. If getTally returns null (outside Asobiai), hide that part.
