# How to represent a state in a card game environment? (Wizard)

We are attempting to build an AI that manages to play the cardgame Wizard. So far er have a working network (based on the YOLO object-detection) that is abled to detect which cards are played. When asked it returns the color and rank of the cards on the table.

But now when starting to build an agent for the actual training I just cant figure out how to represent the states for this game.

In each round, each player gets the amount of cards represented by the round(one card in round one, two in round two and so on). Based on that the players estimate how many tricks they will win in this round. With ending the round the players calculate their points w.r.t their estimation.

So the agent have to estimate its future tricks and have to play depending on that strategy. So how do I encode that into a form that a neural network can work with?

## 1 Answer

It's been almost two years now but since I had the same question and still found this post, I will also post how I plan to solve it: I have not implemented or tested this solution yet.

We will think of the input to the neural network in several blocks.

1. block: the player's hand
2. block: information about which cards have been played so far
3. block: other information

Now some more detail:

### 1. Block:

Represent every card with two input neurons: one for color, one for value .then make block 1's size as large as it can possibly be. In a game with three players, there will never be more than 20 cards on the player's hand, each one needs two neurons, so we get 40 neurons in block 1. (Less, if the AI is trained for fewer players) color can also be split into five neurons instead of one (4 colors + 1 neutral color)

### 2. Block:

60 neurons that have values 0 or 1 depending on whether the card has been played yet or not.

### 3. Block:

• Some information about how many tricks the AI should still win. For example using a single neuron with input value: "Number of tricks to be won by AI" divided by "number of tricks still available" • color the AI has to serve -> 1, 4 or 5 neurons

#### Optional Inputs:

• value of currently winning card -> 1 neuron • color of currently winning card -> 1, 4 or 5 neurons • ratios of total points each player has scores so far to the average number of points • tricks wanted to tricks available ratio (as above) for the opponents

One could also combine blocks 1 and 2 into 60 neurons with an extra possible state:

• not played yet -> 0
• played -> 1
• in own hand -> -1