PieceSafety
Boolean piece-safety primitives: which pieces stand en prise (attacked and undefended).
This is the building block behind the hang telemetry in the arena (dicechess.engine.bench.BotMatchRunner, a separate sbt project not linkable from here) and is deliberately shared so a safety-aware pre-ranker or feature extractor can later reuse the exact same notion of "hanging" — a metric and the signal it motivates must agree on definitions, or the metric can't validate the fix.
The definition is the deterministic-chess one, kept intentionally simple:
- attack and defense are boolean (dicechess.engine.movegen.MoveGenerator.isSquareAttacked), with no exchange evaluation — a piece defended once but attacked twice does not count as hanging;
- a king "defends" its neighbours like any other piece, even when recapturing would be suicidal against a defended attacker;
- en passant is not modeled (the capture lands on a square the victim does not occupy);
- kings are never "hanging" — an attacked king is check, a different concept with its own machinery (Evaluator.evaluateKingSafety, KingCaptureProbability).
Dice probabilities are also deliberately absent: whether the opponent can roll the attacker's die is a separate, composable concern (the chance of punishing a hang is 1 - ((6 - k) / 6)^3 for k distinct attacking piece types), and keeping this primitive dice-free lets one implementation serve both a raw blunder count and a dice-weighted risk feature.
Attributes
- Source
- PieceSafety.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PieceSafety.type