Implement blackjack_mc_prediction(policy_threshold, num_episodes, gamma=1.0, seed=42): estimate state values of simplified Blackjack under a fixed policy with first-visit Monte Carlo prediction.
Simulation, using NumPy's global RNG:
- Call
np.random.seed(seed) once at the start.
- A card is
min(np.random.randint(1, 14), 10); card 1 is an ace.
- Hand value: the card sum, plus 10 if the hand holds an ace and adding 10 does not exceed 21 (the ace is then "usable").
- Per episode draw, in this order: player card, player card, dealer showing card, dealer hidden card. The player then repeats: record the state
(player_sum, dealer_showing, usable_ace); stick if player_sum >= policy_threshold; otherwise draw one card, and stop at once on a bust (sum >21; the bust state is not recorded).
- Reward: −1 if the player busts (the dealer does not play). Otherwise the dealer draws until its hand value is ≥17; a dealer bust gives +1, else +1, −1 or 0 for a player sum greater than, less than or equal to the dealer's.
- The reward arrives only at the end: a state recorded t decisions before the last one receives return γt⋅reward. Each state's value is the mean of its first-visit returns over all episodes.
Return a plain dict (not a defaultdict) mapping (player_sum, dealer_showing, usable_ace), with usable_ace a bool, to its estimated value.