Recipe catalog / take-turn
Assess whether a player can act now
take-turn is a Jev recipe from the jev-recipes TypeScript package. Interpret game rules and current state to label a player's turn or reaction opportunity as act, wait, inactive, or unclear. Use it when you need to decide whether it is a player's turn to act or react using narrative game rules, state, and previous actions.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use take-turn in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { takeTurn } from 'jev-recipes/take-turn';
const result = await takeTurn({
"player": "Blue",
"rules": "A challenge pauses the normal turn. The challenged player must defend or concede before the normal turn resumes.",
"environment": "Red's normal turn is paused while Blue answers a challenge. The challenge is unresolved.",
"history": [
{
"player": "Red",
"action": "Challenged Blue; the challenge is awaiting Blue's response."
}
]
});
console.log(result);
What input does take-turn take?
| Field | Type | Needed |
|---|---|---|
| player | string | Required |
| rules | string | Required |
| environment | string | Required |
| history | array | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"player": {
"type": "string",
"description": "The player whose current turn or reaction eligibility should be assessed."
},
"rules": {
"type": "string",
"description": "Applicable turn, phase, reaction, and participation rules."
},
"environment": {
"type": "string",
"description": "The current game snapshot available to the player, after the supplied history."
},
"history": {
"maxItems": 100,
"type": "array",
"items": {
"type": "object",
"properties": {
"player": {
"type": "string",
"description": "The player who took the recorded action."
},
"action": {
"type": "string",
"description": "The observed action, including its known outcome when relevant."
}
},
"required": [
"player",
"action"
]
},
"description": "Optional observed actions by any players, oldest first. May be empty or incomplete."
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"player",
"rules",
"environment"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"act",
"wait",
"inactive",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"act",
"wait",
"inactive",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"act",
"wait",
"inactive",
"unclear"
]
}
},
"required": [
"model",
"usage",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}What does a take-turn result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo take-turn.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"verdict": "act",
"confidence": 0.94,
"probabilities": {
"act": 0.94,
"wait": 0.02,
"inactive": 0.02,
"unclear": 0.02
}
}
Input
Supply non-empty text describing the player, applicable rules, and current environment. Include phase, unresolved reactions, elimination, and game completion when relevant. This recipe is useful when that information needs interpretation from narrative text; use ordinary code when an authoritative engine already provides turn eligibility.
Optional history contains at most 100 { player, action } entries, oldest first. Both fields must contain non-empty text. Repeated actions and an empty list are allowed. History may be incomplete; missing history does not imply the game just started. environment describes the current snapshot after these events.
minConfidence defaults to 0.8 and accepts values from 0 to 1. See shared options and behavior for configuration and errors.
Result
| Verdict | Meaning |
|---|---|
act |
The player has a current normal turn, response, reaction, or simultaneous-action opportunity. |
wait |
The player cannot act now, but their participation is not established to be over. |
inactive |
The game is over or this player has no remaining participation or reaction right. |
unclear |
Missing or conflicting facts prevent determining current eligibility. |
status is ready when confidence meets the threshold and the verdict is not unclear; otherwise it is review. An unclear verdict always requires review, even with a zero threshold. ready can accompany wait or inactive: it describes confidence in the assessment, not permission to move. Even act does not choose a move or say whether an optional reaction is worth using. Model, token usage, confidence, and per-verdict probabilities are preserved.
Decision boundaries
These are intended policy examples, not measured gameplay results.
| Situation | Intended verdict |
|---|---|
| It is Blue's normal turn and the rules permit Blue to choose an action. | act for Blue. |
| It is Red's normal turn, paused until Blue answers a challenge. | act for Blue and wait for Red. |
| The rules explicitly give Blue an optional reaction right now. | act, regardless of whether reacting is strategically useful. |
| All active players must submit simultaneous choices; Blue has not submitted. | act for Blue. |
| Blue has already submitted and must wait for others. | wait. |
| Blue's turn is skipped this round but Blue stays in the game. | wait. |
| Blue is eliminated with no remaining participation or reaction rights. | inactive. |
| The game has ended. | inactive. |
| History says Blue acted, but a current rule grants Blue another turn. | act if the current state establishes that extra turn. |
| The active player or pending reaction cannot be resolved. | unclear. |
Reuse
Use choose-action to recommend a move after checking eligibility; its guide shows how to combine the calls. Use step-complete to inspect evidence that a turn has already been completed.
Uses the shared choice helper and makes one logical Jev request. It does not invoke another recipe or perform game actions.
Limits
- An exact game engine should own turn eligibility whenever it can compute it. This recipe interprets supplied text and can be wrong.
- It does not execute or complete the turn, choose a move, or advance state.
- Game state can change while the request is running. Check the current state before acting on a result.
How accurate is take-turn?
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of take-turn?
- Assesses narrative turn eligibility, not a legality proof. When a game engine provides an exact turn or reaction flag, use that directly.
- Does not take a turn, select an action, update state, or verify that a player already completed a turn.
- Act includes optional reactions and does not mean using that opportunity is strategically best. Missing or conflicting facts require review.
Which recipes are related to take-turn?
- choose-action: Use choose-action to compare candidate moves after establishing the player can act.
- step-complete: Use step-complete to check whether a defined turn-completion condition was met; take-turn assesses the current opportunity to act.
- response-needed: Use response-needed for conversational follow-through, rather than turn and reaction eligibility under game rules.