A framework for playing the card game Regicide.
The package requires python version 3.7+ and should be compatible with Linux, Windows and macOS.
The Regicide framework can be installed in python using pip.
$ pip install regicide
The implementation follows the official rules.
The following is an example of implementing an agent with custom behavior. In this example the agent will always choose to play the six of diamonds if available. Otherwise, it will choose randomly from the available actions.
import random
import regicide
from regicide import actions, card, players
class CustomPlayer:
"""
A player that always plays the Six of Diamonds if possible.
Otherwise it will choose a random action.
"""
def play(self, state):
legal_actions = state.action_space()
c = card.Card(card.CardSuit.Diamonds, card.CardValue.Six)
special_action = actions.ActionPlay(c)
if special_action in legal_actions:
return special_action
else:
return random.choice(legal_actions)
players = [CustomPlayer(), CustomPlayer(), CustomPlayer()]
game = regicide.RegicideGame(players, seed=1337)
result = game.playout()
print(result, game.reward())
The framework has three submodules: actions
, card
and players
. Each module contains python classes that can be instantiated and used in the framework.
Available actions are:
Play(card: Card)
AnimalCombo(cards: List[Card])
Combo(cards: List[Card])
Yield()
Discard(cards: List[Card])
ChangePlayer(id: int)
RefillHand
Available cards are:
Card(suit: CardSuit, value: CardValue)
CardSuit
that can be:Spades
,Hearts
,Diamonds
,Clubs
orNone
.CardValue
that can beAce
...King
or the special valueJester
.
InputPlayer()
that allows user input for taking actions.RandomPlayer(seed: int)
MCTSPlayer(playouts: int, num_threads: int, uct_variation: int, use_heuristics: bool)
Currently, the python package does not support code suggestions in IDE's, making it more difficult to work with the package. This is a result of the method used to generate the python bindings and has no implication on actual performance or correctness of the program.