In this king-of-the-hill challenge, you will be making a python 3 bot to play the card game judgement!
Rules
Judgement is a hand based game similar to games like rummy. In each round, 7 cards are dealt to each player, a trump suit is chosen (trump suits are chosen sequentially from the list Spades/Hearts/Diamonds/Clubs/No Trump), and based on these cards, the trump suit, and the play order, each player must make a guess as to how many hands they will win.
The first player to play in a particular hand can play any card they want. From then on, any subsequent player must play a card of the same suit as the first player if they have it, otherwise, they can play any card.
Once every player has played a card, the winner of the hand is determined as follows:
- If a trump card has been played, the highest trump card wins
- Otherwise, the highest card in the suit played by the first player wins
(As in most card games, the ordering is 2,3,4,5,6,7,8,9,10,J,Q,K,A)
The winner of a given hand starts the next hand. Once everyone's cards are depleted, each player counts the number of hands they have won. If it is equal to their guess, they earn 10 + the number of guessed hands. Otherwise, they earn nothing.
The winner of the game is the player with the highest scores after several rounds.
Challenge
I've built the game controller here. Everything in this section is present in the link, but I'll include it here for completeness.
A submission must include 5 parts:
"name"
A name for the bot.
def make_bet(self, turn_order, trump):
...
return hands_to_make
This function takes in turn_order
, which is a list of the names of all bots in order of when they will play, and trump
, which is a string representing the trump suit for the round. It must return hands_to_make
, which is the number of hands the bot expects to win this round. self.hand
will be automatically updated to contain your current hand.
play_card(self, current_board):
...
return card_played
This function takes in the list of cards played so far this hand in the form ("bot_name", Card)
, and returns card_played
, which is the card from your hand to play.
update_round(self, current_scores, rounds_left):
...
return None
This function gets called right before every round (including at the very beginning for initializing you bot). It takes current_score
which is a dictionary of bot_name: current_score
, and rounds_left
, which is the number of rounds left to be played.
update_play(self, final_board, winner):
...
return None
This function gets called right after each hand. final_board
is the list of cards played that hand in the form ("bot_name", Card)
, and winner
is a string indicating which bot won the hand.
The classes have the following specs
Card:
- self.suit accesses the suit (S,H,D, or C)
- self.rank accesses the rank (int from 2 -> 14)
- self.get_rank() accesses the rank in str form (2-10,J,Q,K,A)
Bot:
- self.hand accesses the hand (List[Card])
- self.name accesses the name of the bot. Alternatively, str(self) works as well.
- self.all_bets accesses a dictionary of bets placed by all bots.
- You can store other information you want to store by create self. class variables.
As a basic example, consider the following bot:
Basic Bot
def basic_make_bet(self, turn_order, trump):
return len(self.hand)
def basic_play_card(self, current_board):
if current_board:
for card in self.hand:
if card.suit == current_board[0].suit:
return card
return self.hand[0]
def basic_update_round(self, current_scores, rounds_left):
pass
def basic_update_play(self, final_board, winner):
pass
basic_bot = ("basic", basic_make_bet, basic_play_card, basic_update_round, basic_update_play)
The Colab link above contains an easy to use template for submissions, so I recommend using that! I will also try to update the Colab link with new bots as soon as they are posted.
Requirements
- You can only use libraries available in Google Colab. These are the libraries present in the Anaconda distribution of Python 3.
- self.hand, the variable to access to see one's hand, must be treated as read only. Modifying the variable will mess up the game, so please avoid this.
- Bots must run in a reasonable amount of time. I'm not going to provide any strict bounds but I'll remove any serious offenders.
- The competition will be run June 6th, and the winner will receive a bounty + a check mark.
- To judge the bots, I'll pick random groupings of up to 7 bots and play the game thousands of times, and evaluate the average score of the bots per game.
Current Averages
Each bot has played a total of 100 rounds. This table should be updated semi-regularly. (PlanBot is currently too slow to run 10000 rounds)
Bot | Average |
---|---|
PlanBot | 6.71 |
Conservative | 6.30 |
BasicCardStrat | 4.77 |
Half | 4.28 |
Random | 4.15 |
sans. | 3.19 |
Basic | 0.00 |