Solving

Requests with many solves

A request with then, expand or boards starts many solves. This page shows how to send many boards, follow the progress of a request, read its solves and stop it.

In short

  • A request with then, expand or boards starts many solves. The first solve is the root: budgets, progress and cancel work through it.
  • Follow the progress in tree on the root. Wait until tree.status is not running.
  • Read the solves with GET /v1/solves/{id}/children.
  • Stop a request with POST /v1/solves/{id}/cancel. Solves that wait are not charged.

Many boards in one request

Send boards in place of board to solve the same pot, stack, ranges and sizes on each board. All boards must be the same street, and each board one time.

The most is 2,000 boards. then and expand apply to each board.

jq '{boards: [["As", "Ks", "7h"], ["Qd", "Jd", "2c"]], pot, stack, ranges}' spot.json > boards.json

curl -sS -X POST "$GECKO_API/v1/solves" \
  -H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" -H "Prefer: wait=30" \
  -d @boards.json | tee batch.json | jq '{id, object, tree}'

# the root of the request, for the samples below
ROOT=$(jq -r .id batch.json)

The answer is a root with "object": "batch". The root is not a solve: it has no result (409 not_a_solve) and costs nothing itself. Its tree block shows the progress, and the solve of each board is under it at GET /v1/solves/{id}/children.

The answer: a root with "object": "batch"
{
  "id": "slv_00VcT5MXzAQu86SGrfuI0",
  "object": "batch",
  "status": "complete",
  "street": "batch",
  "board": [],
  "boards": 2,
  "credits": 0,
  "result": null,
  "tree": {
    "status": "running", "stop_reason": null, "estimated_credits": 2, "credits_charged": 1, "max_credits": 20000,
    "solves": {"pending": 1, "queued": 0, "running": 1, "complete": 0, "failed": 0, "skipped": 0, "cancelled": 0}
  }
}

Follow the progress: the tree block

The root solve of a request with then, expand or boards has a tree block. The top-level status is that of the first solve alone.

tree.status is that of the request. Wait on tree.status.

{
  "id": "slv_00VcT6pkVcfEJgZf5uvIA",
  "status": "complete",
  "tree": {
    "status": "stopped",
    "stop_reason": "max_credits",
    "estimated_credits": 181,
    "credits_charged": 100,
    "max_credits": 100,
    "solves": {"pending": 0, "queued": 0, "running": 0, "complete": 100, "failed": 0, "skipped": 81, "cancelled": 0}
  }
}
Every field of the tree block
status
running: solves wait or run. complete: every solve reached a final state. stopped: the request ended early; stop_reason says why. cancelled: you cancelled it. The last three are final.
stop_reason
max_credits (the budget of the request), insufficient_credits (no calls left), credit_limit (a limit of the key or the account), account_suspended or cancelled. null while the request runs and when it completes.
estimated_credits, credits_charged, max_credits
The estimate made when the request came in, what is charged so far, and the budget.
solves
The number of solves in each state.
problems
Present when a named line was not found under a solved street: the messages. This can happen when the real solve left out a line that no hand reaches.

A request that stopped or was cancelled keeps what is finished. To go on, send one parent request for each line and card that is missing. A new send of the whole body pays again for what is done.

Read the solves of a request

GET /v1/solves/{id}/children lists the next-street solves under a solve, in pages. Each one is a solve with its own result.

The query fields: scope, status, limit, after
scope
children (default): the solves one street below this solve. tree: every solve of the request this solve belongs to, all streets, without the root.
status
Only solves in this state, for example complete. A value that is not a state gives an empty list.
limit
1 to 500. Default 100.
after
The next value of the page before. Stop when next is null: next is set only when more rows exist.
curl -sS "$GECKO_API/v1/solves/$ROOT/children?scope=tree&status=complete&limit=500" \
  -H "Authorization: Bearer $GECKO_KEY" | jq '{count: (.data | length), next}'

Stop a request

POST /v1/solves/{id}/cancel stops the whole request, also when you name a solve under the root. Solves that wait are cancelled and not charged.

A solve that runs finishes and is charged. What is finished stays readable.

curl -sS -X POST "$GECKO_API/v1/solves/$ROOT/cancel" -H "Authorization: Bearer $GECKO_KEY" | jq '.tree'
What the answer holds

The answer is the root of the request with its tree, whichever solve of the request you named. tree.status is "cancelled" when solves were still waiting.

After a stop, the solves that will not run are counted as skipped or cancelled at once, never as pending. A request that was already finished is returned as it is.

Look it up

List your requests

GET /v1/solves

GET /v1/solves lists your requests, newest first: one row for each root. limit is 1 to 200 (default 50). For the next page send after with the next value of the page before.