Expand description
§MSR — Morpion Solitaire Record format
A small, self-describing interchange format for Morpion Solitaire games:
the move list plus optional provenance (who/what/when produced it, how hard,
and a few derived facts), in either a compact MS1: envelope or plain JSON.
This crate is the reference reader, writer and validator for the format.
It is deliberately self-contained — it does not depend on any solver — so any
tool can read, write and verify records with it. The published crate is
morpion-solitaire-record; it is imported as msr.
§Why MSR (vs. Pentasol)
The community Pentasol text format covers only the 5T/5D variants and stores moves alone. MSR is lossless for all four variants (4T/4D/5T/5D), carries provenance metadata, and offers both a compact and a human-readable form. A Pentasol bridge is provided for migration.
§Example
use msr::{Record, RecordMove, Variant, Direction};
let moves = vec![RecordMove { x: 3, y: -1, dir: Direction::V, pos: 4 }];
let mut rec = Record::new(Variant::T5, moves);
rec.description = Some("a one-move demo".into());
let compact = msr::encode(&rec).unwrap(); // "MS1:…"
let back = msr::decode(&compact).unwrap();
assert_eq!(rec, back);§Specification & references
The normative format definition is the MSR specification shipped with the
source (docs/spec/0.1/msr.md) and the JSON Schema (docs/spec/0.1/). The rules
validated here are those of Morpion Solitaire; see the project bibliography
(docs/BIBLIOGRAPHY.md).
Structs§
- Record
- A complete MSR record: the move list plus self-describing metadata.
- Record
Move - One move: a new point
(x, y)and the line it completes.posis the index of the new point within that line, in0..line_len; the line’s origin is therefore(x, y) - pos * dir.delta(). - Solver
- Provenance of the automated search that produced a game. Every field is optional; the block as a whole is omitted for records not made by a solver.
Enums§
- Direction
- Line direction. The unit step
delta()defines the coordinate convention the whole format depends on, so it is normative. - Error
- Errors from encoding or decoding a record.
- Validation
Error - Why a record failed validation. Each variant carries the offending move’s
index (0-based) in
record.moves. - Variant
- A game variant: line length (4 or 5) and touch rule (Touching / Disjoint).
Constants§
- FORMAT_
VERSION - The format version this crate reads and writes (the
versionfield),major.minor. - PREFIX
- Tag identifying the compact MSR form (version 1 of the envelope).
- SPEC_
VERSION - The specification version implemented (
docs/spec/0.1/msr.md).
Functions§
- decode
- Decode a record from either form: the
MS1:compact envelope, or raw JSON (pretty or compact). Surrounding whitespace is ignored. - encode
- Encode a record to the compact
MS1:form. - encode_
json - Encode a record to pretty-printed JSON (the readable interchange form).
- initial_
cross - The points of the initial cross for
variant, in row-major order. - validate
- Validate
record: replay its moves from the initial cross and check each is a legal Morpion move. Returns the first violation, orOk(()).