Answer architecture round 2: fail a place naming no dimension, keep a ratchet until a ruling follows, leave the base on a fall-called run, let record-scoring say whether the floor blocks, and name the missing dimension in a discounted vote

This commit is contained in:
2026-10-09 11:04:01 +02:00
parent 75b0e46326
commit 9de87e04cf
8 changed files with 95 additions and 56 deletions
+23 -6
View File
@@ -23,6 +23,8 @@ def votes(seats: list[Seat]) -> dict[str, list[str]] | Failure:
line = vote_line(seat.name, seat.said)
if isinstance(line, Failure):
return line
if unnamed := [place for place in seat.places if not any(re.search(rf"\b{name}\b", place) for name in DIMENSIONS)]:
return Failure(f"{seat.name}'s place names none of {', '.join(DIMENSIONS)}, spelled so: {unnamed[0]}")
said[seat.name] = line
first, second, *more = (each[-1] for each in counted(seats, said).values())
if more and first == second:
@@ -31,12 +33,12 @@ def votes(seats: list[Seat]) -> dict[str, list[str]] | Failure:
def counted(seats: list[Seat], said: dict[str, list[str]]) -> dict[str, list[str]]:
"""Each seat's votes as they count: a dimension's vote counts as same unless one of the seat's `path:line` places names that dimension, and the overall vote unless the seat names any place."""
"""Each seat's votes as they count: a dimension's vote counts as same unless one of the seat's `path:line` places names that dimension, and the overall vote unless the seat names any such place."""
return {seat.name: [vote if names_a_place(seat, name) else "same" for name, vote in zip(DIMENSIONS, said[seat.name])] for seat in seats}
def names_a_place(seat: Seat, dimension: str) -> bool:
return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or dimension.lower() in place.lower()) for place in seat.places)
return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or re.search(rf"\b{dimension}\b", place)) for place in seat.places)
def ruling(counted: list[str]) -> str | None:
@@ -66,8 +68,22 @@ def pending_fall(chunk: list[Entry]) -> list[str]:
def standing_ratchet(chunk: list[Entry]) -> str | None:
"""The `Ratchet:` line of the chunk's newest entry, which no paired ruling has followed yet."""
return chunk[-1].ratchet if chunk else None
"""The chunk's newest `Ratchet:` line, unless a paired ruling has followed it."""
for entry in reversed(chunk):
if entry.paired:
return None
if entry.ratchet:
return entry.ratchet
return None
def floor_verdict(under: list[str], reasons: list[str]) -> str:
"""Whether the means under the floor block the merge: they do on a run due for a reason besides a fall."""
if not under:
return f"None under the floor of {FLOOR}."
if reasons:
return f"Floor: {', '.join(under)} under the floor of {FLOOR} block the merge, as the chunk {' and '.join(reasons)}."
return f"Under the floor of {FLOOR}, blocking nothing on a run due for no reason besides a fall: {', '.join(under)}."
def fall_outcome(fell: list[str], found: list[decimal.Decimal]) -> tuple[str, list[str]] | None:
@@ -103,12 +119,13 @@ def round_counts(titles: list[str]) -> dict[str, int]:
def measured_commit(changes: list[HistoryChange]) -> str | None:
"""The newest change, of changes given newest first, that adds a scoring run to the history, or whose last added paired ruling is better."""
"""The newest change, of changes given newest first, whose last added paired ruling is better, or that adds a scoring run and whose last added paired ruling names no fall."""
for change in changes:
held = {entry.heading for entry in entries(change.before)}
added = [entry for entry in entries(change.after) if entry.heading not in held]
rulings = sorted((entry for entry in added if entry.paired), key=lambda entry: entry.time)
if any(not entry.paired for entry in added) or rulings and rulings[-1].ruling == "better":
last = rulings[-1] if rulings else None
if last and last.ruling == "better" or any(not entry.paired for entry in added) and not (last and last.fell):
return change.commit
return None