The idea of this challenge is simple: create a bot to play the card game Euchre.
For those of you who don't already know them, I've written out the rules to Euchre here as they pertain to this challenge.
I recommend using python or something similar, but the only real restriction is that it has to be compatible with the controller code
Input:
Your euchre bot will get different kinds of input depending on the current phase of the game or round. Generally speaking, you'll get the game phase on the first line followed by a comma and a the number of points your team has, and then the relevant data on the following lines.
Chronologically, your bot will get input in the following order:
Ordering Trump:
js,ah,qc,ts,jc // the cards in your hand
2 // number of points your team has
0 // number of tricks your team has taken
ordering // the phase of the game
th // the turned up card
p,p // each previous player’s decision
Naming Trump:
js,ah,qc,ts,jc // the cards in your hand
2 // number of points your team has
0 // number of tricks your team has taken
naming // the phase of the game
p // each previous player’s decision
Dealer Discarding:
js,ah,qc,ts,jc // the cards in your hand
2 // number of points your team has
0 // number of tricks your team has taken
discard // the phase of the game
th // the card you will pick up
Going alone:
js,ah,qc,ts,jc // the cards in your hand
2 // number of points your team has
0 // number of tricks your team has taken
alone // the phase of the game
h // the trump suit
n,n // each previous player’s decision
Your turn:
js,ah,qc,ts,jc // the cards in your hand
2 // number of points your team has
0 // number of tricks your team has taken
turn // the phase of the game
h // the trump suit
td,8h,p // each previous player’s card
Trick data:
// the cards in your hand (none, since this happens at the end of a trick)
2 // number of points your team has
1 // number of tricks your team has taken
trick // the phase of the game
0 // the index of the following list that is your card
js,tc,4d,js // the cards played during the trick in the order they were played
Output:
Your euchre bot will have different outputs depending on the current phase of the game or round.
Ordering Trump:
p //for pass
OR
o //for order up
Naming Trump:
p //for pass
OR ANY OF
c,s,h,d //the suit you want to name
Going alone:
n // no
OR
y // yes
Your turn:
js //the card you want to play
Scoring:
Your bot's score is the total number of games it wins.
Your bot will play against every other bot, and it will always be partnered with a copy of itself.
Notes:
Here's a simple template in python2.7:
#!/usr/bin/python2.7
import sys
data = sys.stdin.readlines()
hand = data[0].strip().split(',') # Hand as a list of strings
points = int(data[1]) # Number of points
tricks = int(data[2]) # Number of tricks
out = ''
if data[3] == 'ordering':
card = data[4] # The upturn card
prev = data[5].strip().split(',') # The previous player's decisions as a list
# Ordering logic
out = # 'o' or 'p'
elif data[3] == 'naming':
prev = data[4].strip().split(',') # The previous player's decisions as a list
# Naming logic
out = # 'p', 'h', 's', 'c', or 'd'
elif data[3] == 'discard':
card = data[4] # The card you'll take
# Discarding logic
out = # The card you want to discard
elif data[3] == 'alone':
trump = data[4] # The trump suit
prev = data[5].strip().split(',') # The previous player's decisions as a list
# Alone logic
out = # 'y' for yes, 'n' for no
elif data[3] == 'turn':
trump = data[4] # The trump suit
prev = data[5].strip().split(',')
# Turn logic
out = # The card you want to play
elif data[3] == 'trick':
trump = data[5]
cards = data[6].strip().split(',')
my_card = cards[int(data[4])]
# Data logic
print(out)
There will always be 4 total responses. If someone goes alone, then their partner's response will be "p" on their turn.
I tried to shave down the amount of redundant input, so to be extra clear:
2a. Both your position relative to the dealer/leader and the card your partner played can be determined by the number of previous outputs. There is 1 player between you and your partner. There For instance, if you get "td,8h,p" as the last line on your turn, you can see that your partner played an 8h, and the other team has a player that is going alone.
If you are curious, the deal is done in the traditional way (in two rounds alternating packets of 2 and 3 cards) but that's not really relevant to your bot, so...
If the second player decides to order up in the trump phase, that phase will continue, but their outputs will pretty much be ignored. In other words, whoever orders up first is on the Namers team regardless of any other output.
The following are the defaults for the various game phases. If you don't output a valid response for that round, then your response is changed to what's below.
Ordering Trump: p
Naming Trump: p
Discarding: (the first card in your hand)
Going Alone: n
Your Turn: (the first legal card in your hand)
Here's the controller code for your testing purposes.
6a. Notice you can pass in either 2 or 4 bot names, if you give it 4 bots then they get partnered up randomly, and with 2 they are partnered up with copies of themselves.
6b. You need a 'bots' directory in the same directory as the controller code, and your bot code needs to be in the bots directory.
For those that want their bot to remember what cards were played, you are given the opportunity during the "trick" phase, which tells your bot which cards were played. You can write to a file in the bots directory as long as that file doesn't exceed 1kb.
Scoreboard:
Old Stager: 2
Marius: 1
Random 8020: 0