Answers.Body: <p>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.</p>
  <p>We will think of the input to the neural network in several blocks.</p>
  <ol>
  <li>block: the player's hand</li>
  <li>block: information about which cards have been played so far</li>
  <li>block: other information</li>
  </ol>
  <p>Now some more detail:</p>
  <h3>1. Block:</h3>
  <p>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)</p>
  <h3>2. Block:</h3>
  <p>60 neurons that have values 0 or 1 depending on whether the card has been played yet or not.</p>
  <h3>3. Block:</h3>
  <p>• Some information about how many tricks the AI should still win. For example using a single neuron with input value:
  &quot;Number of tricks to be won by AI&quot; divided by &quot;number of tricks still available&quot;
  • color the AI has to serve -&gt; 1, 4 or 5 neurons</p>
  <h4>Optional Inputs:</h4>
  <p>• value of currently winning card -&gt; 1 neuron
  • color of currently winning card -&gt; 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</p>
  <p>One could also combine blocks 1 and 2 into 60 neurons with an extra possible state:</p>
  <ul>
  <li>not played yet -&gt; 0</li>
  <li>played -&gt; 1</li>
  <li>in own hand -&gt; -1</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-09T06:27:05.740Z
Answers.Text: You should maybe ask a question about this representation. The main issue that I can see is that it has is large amounts of redundancy in block 1 due to cards being essentially the same data point (having a card in your hand is not reliant on its position but the encoding you use varies the position). IMO you would be better off with block 1 a fixed representation for all cards, same as block 2, although possibly a sorting approach to block 1 and using LSTM or transformer architecture to help process it would also work well.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-23T23:35:20.233Z
Answers.LastActivityDate: 2021-12-23T23:35:20.233Z
Answers.UserDisplayName: Sebastian
Body: <p>We are attempting to build an AI that manages to play the cardgame <a href="https://en.wikipedia.org/wiki/Wizard_(card_game)" rel="nofollow noreferrer">Wizard</a>. 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. </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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? </p>
  
Tags: <reinforcement-learning><q-learning>
Title: How to represent a state in a card game environment? (Wizard)
UserDisplayName: Voß
ThreadText: # How to represent a state in a card game environment? (Wizard)
  
  (Asked by: username_0 on 2020-02-10)
  
  We are attempting to build an AI that manages to play the cardgame [Wizard](https://en.wikipedia.org/wiki/Wizard_(card_game)). 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?
  
  **Tags:** reinforcement-learning, q-learning
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-23. Score: 0
  
  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
  
  > **Comments:**
  > **username_2**: You should maybe ask a question about this representation. The main issue that I can see is that it has is large amounts of redundancy in block 1 due to cards being essentially the same data point (having a card in your hand is not reliant on its position but the encoding you use varies the position). IMO you would be better off with block 1 a fixed representation for all cards, same as block 2, although possibly a sorting approach to block 1 and using LSTM or transformer architecture to help process it would also work well.  
  
  ---
  
  