The sum of all bids may never equal the number of cards each player holds in the round; the last bidder has to adjust their bid. This was an optional "not equal" lobby setting and is now a fixed rule of the game engine, so it applies to humans, AI players and training alike. - Remove GameOptions.not_equal, the set_options field, the lobby toggle and the --not-equal training flag - Explain the rule in the lobby and show the blocked bid while bidding - Drop the option from the AI observation encoding - Tests check that no round ends with bids summing to the cards in hand Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
891 B
891 B
wizard_game
Pure-Python rules engine of Wizard (no dependencies). It is used by the game server and can be installed on its own to train AI players:
pip install ./wizard_server/game_logic
import random
from wizard_game import WizardGame, GameOptions
game = WizardGame(num_players=4, options=GameOptions(hidden_bids=True), seed=1)
rng = random.Random(1)
while not game.is_finished:
player = game.current_player
obs = game.observation(player) # what this player may see
action = rng.choice(obs.legal_actions) # Bid / PlayCard / ChooseTrump
events = game.apply(player, action) # TrickCompleted, RoundCompleted, ...
print(game.scores, game.winners())
Observation.to_dict() / Observation.from_dict() and
action_to_dict() / action_from_dict() define the JSON format that the
server sends to web clients and to the AI service.