osrforge.tracing.score
The scorer: how far a trace is from its answer key, one family of numbers at a time.
score_trace lines each panel of the
trace up with the key at the whole-cell offset that fits best, then reports
the families below. It scores the trace as repaired and, when the trace has a
before_repair, the trace before repair, and each of those twice: over every
cell, and without the cells the key marks as partly floor.
The rules are in docs/tracing-conventions.md under "The scorer".
ALIGNMENT_SEARCH
module-attribute
How far, in cells, the alignment looks for each panel's best offset in each direction.
FAMILIES
module-attribute
FAMILIES: tuple[str, ...] = (
"floor",
"areas",
"keys",
"joins",
"doors",
"edges",
"reachability",
"entrance",
"transitions",
"passages",
"halves",
"verdicts",
"repairs",
)
The family names, in the order ScoreSet lists them.
AreaOverlap
Bases: BaseModel
One key's area in the key and in the trace.
trace_cells
class-attribute
instance-attribute
0 when the trace has no area with this key on this level.
AreasScore
Bases: BaseModel
Each area's cell overlap.
areas
class-attribute
instance-attribute
areas: tuple[AreaOverlap, ...] = ()
One entry per area of the key, in key order.
extra
class-attribute
instance-attribute
Areas the trace has and the key lacks, as dungeon/level/key.
mean_overlap
property
mean_overlap: float | None
The mean of the areas' overlaps, or None with no areas.
perfect
property
perfect: bool
True when every area covers the same cells in both and the trace has no extra area.
DoorTally
Bases: BaseModel
Precision and recall for one door kind.
matched
class-attribute
instance-attribute
Edges that are this kind in both.
DoorsScore
EdgeTally
Bases: BaseModel
Passable or blocked, over a set of edges.
total
class-attribute
instance-attribute
Edges in the key's universe: edges that touch floor or water.
right
class-attribute
instance-attribute
Edges the trace reads as passable or blocked the way the key does.
walls_read_as_open
class-attribute
instance-attribute
Edges blocked in the key and passable in the trace.
open_read_as_blocked
class-attribute
instance-attribute
Edges passable in the key and blocked in the trace.
EdgesScore
Bases: BaseModel
Passable or blocked, with cave edges apart from straight walls.
FloorScore
Bases: BaseModel
How much of the floor the trace and the key agree on: the . cells of the panels, after alignment.
trace_cells
class-attribute
instance-attribute
Floor cells in the trace, after alignment.
HalvesScore
Bases: BaseModel
Whether each pair of halves was joined at the key's offset, or left apart as the key says.
JoinsScore
Bases: BaseModel
Whether the areas adjoin the same way.
Two areas of one level adjoin when a passable edge or a door joins a cell of one to a cell of the other.
missing
class-attribute
instance-attribute
Joins in the key the trace lacks, as dungeon/level/key~key.
extra
class-attribute
instance-attribute
Joins in the trace the key lacks.
KeysScore
Bases: BaseModel
Whether each printed key landed in the right area.
A key is right when the trace's placed cell for it lies in the key's area of the same name, and the key's placed cell lies in the trace's area of that name.
wrong
class-attribute
instance-attribute
The keys that landed wrong, as dungeon/level/label.
PlacementScore
Bases: BaseModel
Whether each entrance, transition, or passage stands where the key puts it, leading where the key says.
right
class-attribute
instance-attribute
Items the trace has on the same cell with the same kind, side, and destination.
extra
class-attribute
instance-attribute
Items in the trace that match nothing in the key.
wrong
class-attribute
instance-attribute
The key's items the trace lacks, as dungeon/level/cell.
ReachabilityScore
Bases: BaseModel
Per dungeon, whether the same areas are reachable from the entrance.
The walk crosses passable edges, doors of every kind, transitions, and passages. A dungeon is right when the trace reaches the areas the key reaches and no others.
wrong
class-attribute
instance-attribute
The dungeons that differ, with what differs, as dungeon: ....
RepairsScore
Bases: BaseModel
What the trace repaired, and whether each repaired edge ended up as the key reads it.
per_level
class-attribute
instance-attribute
Repairs per level, keyed dungeon/level, for levels with at least one.
edges_matching
class-attribute
instance-attribute
Changed edges whose final reading matches the key.
ScoreSet
TraceScore
Bases: BaseModel
A trace scored against its key.
after_whole
instance-attribute
after_whole: ScoreSet
The trace as repaired, without the cells the key marks as partly floor and the edges that touch them.
before
class-attribute
instance-attribute
before: ScoreSet | None = None
The trace before repair, over every cell, or None when the trace has no before_repair.
before_whole
class-attribute
instance-attribute
before_whole: ScoreSet | None = None
The trace before repair, without the partly-floor cells.
VerdictsScore
Bases: BaseModel
Whether refusals, registration failures, and fallbacks are right.
A region is right when its verdict, style, scale, north, and legend page match the key's. A level is right when its verdict matches.
wrong
class-attribute
instance-attribute
The regions and levels that differ, with what differs.
score_trace
score_trace(trace: GeometryTruth, key: GeometryTruth) -> TraceScore
Score a trace against its answer key.
A 5-foot panel in either document is converted with
convert_five_foot before
anything is compared. Panels are matched by id. Each panel of the trace is
then lined up with the key's panel of the same id at the whole-cell offset
(dx, dy) within ALIGNMENT_SEARCH cells that makes the most floor cells
agree, ties going to the smallest |dx| + |dy|, then the smallest dy,
then the smallest dx. A panel with no partner of the same id is left out
of the reading families, and the halves family reports the difference.
The floor, edges, and doors families compare the panels: the reading, with
the trace's panels as repaired and before_repair's as read. A panel used
only by a level that fell back in either document is left out of them. The
areas, keys, joins, reachability, entrance, transitions, passages, and
repairs families compare the levels: the resolution. A level cell is
mapped through the panel it lies on: back to that panel's page coordinates
by undoing the trace's panel origin and turn, across by the panel's
offset, and onto the key's level by the key's panel turn and origin. A
destination cell is mapped the same way through its target level's panels,
and when the target level fell back in either document the destination
compares by level number alone. A level that fell back in either document
scores in the verdicts family only. The whole-cell scores leave the
partly-floor cells and their edges out of the floor, edges, and doors
families and change nothing else. The rules are in
docs/tracing-conventions.md under "The scorer".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
GeometryTruth
|
The trace. |
required |
key
|
GeometryTruth
|
The answer key, or a synthetic map's answer. |
required |
Returns:
| Type | Description |
|---|---|
TraceScore
|
The score. |