Stop the AI from sorting hands in place; unskip full-game tests

Under Emacs 28 and earlier, sort relinks a list destructively, so the
variable that held the old head can end up holding only a tail.  Four
computer-player choices sorted a list that shared structure with the
player's stored hand (cl-remove-if-not returns its argument when it
removes nothing), so Bridge, Briscola, Pitch and Euchre dropped cards
from hands mid-deal and then stopped on (= nil N).  Emacs 29's sort
reorders in place, which hid the bug there.

The previous commit skipped cgt-bridge-full and cgt-trick-ext-full
unless SVG is available, but both render text in batch; they failed
on Emacs 27 for this reason, not for want of SVG.

* card-games-bridge.el (card-games-bridge--ai-play):
* card-games-trick-ext.el (card-games-tx--ai)
(card-games-trick--ai-play) <pitch>: Sort a copy, never the hand.
* test/card-games-tests.el (cgt-bridge-full, cgt-trick-ext-full):
Drop the SVG skip.
(cgt--hands-snapshot, cgt-ai-play-leaves-hands-alone): New test; it
fails without the fix on Emacs 27 and on Emacs 29.
* NEWS: Note the fix.

Assisted-by: Mentat (for Corwin; claude-opus-5-5)
This commit is contained in:
Corwin Brust 2026-10-05 15:58:25 -05:00
parent e78fe38381
commit 74af63a089
4 changed files with 57 additions and 7 deletions

10
NEWS
View file

@ -3,6 +3,16 @@ card-games NEWS -- user-visible changes
* Version 1.0.92 (pretest3: MELPA review)
** Bug fixes
- Bridge, Briscola, Pitch and Euchre no longer lose cards from a
hand part-way through a deal under Emacs 28 and earlier. The
computer players sorted a list that shared structure with the
hand; ~sort~ before Emacs 29 relinks the list, which cut cards
out of the hand and later stopped play with a type error. Emacs
29 and later were unaffected. The full-game Bridge and trick
tests no longer skip without SVG, and a new test checks that a
computer player's choice leaves every hand unchanged.
** Packaging and internals
- card-games-net requires subr-x. It calls ~string-empty-p~, which
lives in subr-x before Emacs 29, so a fresh Emacs 27 failed every