Recovers the shuffled 40-card main deck seed of a KOTOR I/II pazaak match, from cards that have already been dealt.
Record every main-deck card in the order it hit the table, including your opponent's. Both players draw from the same deck, which is shuffled once at the start of the match, and again when the main-deck has all its cards drawn (it is not reshuffled between sets). It takes about 10 cards to find the seed, sometimes more.
Once the deck has been exhausted, you need to record main-deck draws from scratch to find the next seed. This is because the PRNG state continues to advance every frame while you play.
KOTOR builds the deck with selection-sampling
Fisher–Yates driven by rand_wincompatible(), the MSVC LCG. The entire 40-card order is a function of one 32-bit LCG seed, so recovering that seed reveals every future draw.
This also means that the 40-card deck can be card-counted traditionally (each value 1-10 only appears 4 times total for the shuffle).