You are given a simulator for a card game with 36 cards: ranks 1 through 9 in four suits. The table starts with 16 random cards. A move removes any 3 table cards whose numeric values sum to 15 and scores 15 points. After a move, the simulator draws up to 3 replacement cards from the remaining deck. The game ends when no valid triple remains or no further progress is possible. A perfect game scores 180 points.
Starting from an existing codebase and tests, complete the following tasks:
-
Fix a bug in the draw logic so the game only removes cards that are actually on the current table.
-
Implement a simple baseline strategy that picks any valid triple summing to 15.
-
Add an experiment or unit test that simulates many games and reports how often the strategy achieves a perfect score.
-
Implement a stronger strategy using search, memoization, or dynamic programming to maximize total score.
Assume the strategy can see the current table and knows the deck composition, but it does not know the future random draw order.