// ĠSPDX - License - Identifier : ĠMIT Ċ // ĠCopyright Ġ( c ) Ġ 2 0 2 2 ĠL uk as ĠZ eller Ċ Ċ package Ġcom . lz 1 0 1 0 1 0 . chess . core Ċ Ċ import Ġcom . lz 1 0 1 0 1 0 . chess . data .* Ċ Ċ object ĠPosition Evaluator Ġ{ ĊĠĠĠ Ġfun Ġis M ate ( board : ĠBoard ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġis Check ( board ) Ġ&& Ġno Moves Left ( board ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis St ale M ate ( board : ĠBoard ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ! is Check ( board ) Ġ&& Ġno Moves Left ( board ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis Check ( board : ĠBoard ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtarget Ġ= Ġfind ( Piece ( Piece Type . K , Ġboard . white To Move ), Ġboard ). first () ĊĊĠĠĠĠĠĠĠ Ġval Ġattack ed S quares Ġ= ĠAttack ed S quares Generator . generate ( board ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġattack ed S quares . contains ( target ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfind ( piece : ĠPiece , Ġboard : ĠBoard ): ĠList < Square > Ġ= ĠSquare . values (). filter Ġ{ Ġboard [ it ] Ġ== Ġpiece Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġno Moves Left ( board : ĠBoard ) Ġ= ĠMove Generator . find ( board ). isEmpty () Ċ } Ċ