Answers.Body: <p>The game state consists of the location of all the hidden cards, so you probably need a softmax layer, 52*n, where n is the number of locations.</p>
  
  <p>I'm not very sure that a NN is a good match. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T14:33:39.900Z
Answers.Text: Thanks for the reply! I had a typo saying the "state composed of a tensor with cards in the players hand", I meant in the player's own hand. The last layer could indeed be a softmax activation layer. Once i'm able to test it, I'll reply (i'm still having problems with the rest of the architecture). I tried 2 fully connected layers with relu and sigmoid activation and curiously got a worse result than with a simple weights matrix.
Answers.UserDisplayName: Paulo Neves
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T15:29:41.577Z
Answers.LastActivityDate: 2018-01-22T15:29:41.577Z
Answers.UserDisplayName: chrishmorris
Answers.Body: <p>With images, you can use CNN because of the translational invariance. A filter which is good in one area will probably be good in another area, too.</p>
  
  <p>With images, you must use CNN because otherwise, there would be too many weights to train.</p>
  
  <p>With your game, it depends on the representation and the exact rules. Note that Alpha Zero uses a set of 19 x 19 inputs with CNN for playing Go.</p>
  
  <p>In a game like Bridge, where each card has its color and rank, there's a kind of translational invariance. Having Ace and Queen is a bit similar to having King and Jack - in both cases you have a 50% chance of catching the card in between. At the same time, the strengths of AQ and KJ are very different, so a pure CNN would improbably work well.</p>
  
  <p>The more important symmetry is the one among colors. After the auction, there's one or none trump color and all other colors are equivalent. This probably means that the corresponding weights should be the same.</p>
  
  <p>In some card games, many cards are special and there's no symmetry at all. You didn't tell us anything about your game, so it's hard to give a more concrete advice.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T12:47:32.513Z
Answers.Text: (Part 1 Comment) Thanks for your response. Before I learned more about NN I though they would be more generalist. The game is not too complicated, there can be an N number of players, to which all cards in the deck are distributed in the beginning. For example 4 players mean each will start with 13 cards, and the winner is the first to have no cards in hand. To get rid of the cards they will play them in turn order and can choose to play cards or not play. The only rules are  that the players always have to play higher cards than  previously played.
Answers.UserDisplayName: Paulo Neves
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T12:54:09.387Z
Answers.Text: (Part 2 of the Comment) Once no one wants to play a card (or can't), the last player to play a card gets to play any card he wants and start a new cycle. 
  The game is highly stochastic because the players can start with low level cards and lose the game even if they played better than the opposition, which complicates the use of greedy epsilon exploration.
Answers.UserDisplayName: Paulo Neves
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-25T12:27:21.730Z
Answers.LastActivityDate: 2018-03-25T12:27:21.730Z
Answers.UserDisplayName: maaartinus
Body: <p>I am currently writing an engine to play a card game and I would like for an ANN to learn how to play the game. The game is currently playable, and I believe for this game a deep-recurrent-Q-network with a reinforcement learning approach is the way to go. </p>
  
  <p>However, I don't know what type of layers I should use, I found some examples of Atari games solved through ANN, but their layers are CNN (convolutional), which are better for image processing. I don't have an image to feed the NN, only a state composed of a tensor with cards in the player's own hand and cards on the table. And the output of the NN should be a card or the action 'End Turn'.</p>
  
  <p>I'm currently trying to use TensorFlow but I'm open to any library that can work with NN. Any type of help or suggestion would be greatly appreciated!      </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-19T16:25:20.690Z
Comments.Text: I encourage you to use some high level framework like Keras to get the work done easily. It uses Tensorflow (or Theano) as backend but it is almost transparent. The type of layer depend on you representation of the features. You should concern not only about the type of layers but also about the entire network architecture. Anyway as a baseline, I'll try with a sequential model of full conected layers combining layers with relu and sigmoid activations.
Comments.UserDisplayName: Marcelo Fornet
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-20T16:31:03.447Z
Comments.Text: Hey, thanks a lot for the feedback! I'll check Keras and I'll try to implement that idea and I'll try to reply soon.
Comments.UserDisplayName: Paulo Neves
Tags: <neural-networks><deep-learning><reinforcement-learning><tensorflow><game-ai>
Title: What layers to use in a Neural Network for card game
UserDisplayName: Paulo Neves
ThreadText: # What layers to use in a Neural Network for card game
  
  (Asked by: username_0 on 2018-01-19)
  
  I am currently writing an engine to play a card game and I would like for an ANN to learn how to play the game. The game is currently playable, and I believe for this game a deep-recurrent-Q-network with a reinforcement learning approach is the way to go.
  
  However, I don't know what type of layers I should use, I found some examples of Atari games solved through ANN, but their layers are CNN (convolutional), which are better for image processing. I don't have an image to feed the NN, only a state composed of a tensor with cards in the player's own hand and cards on the table. And the output of the NN should be a card or the action 'End Turn'.
  
  I'm currently trying to use TensorFlow but I'm open to any library that can work with NN. Any type of help or suggestion would be greatly appreciated!
  
  **Tags:** neural-networks, deep-learning, reinforcement-learning, tensorflow, game-ai
  
  > **Comments:**
  > **username_1**: I encourage you to use some high level framework like Keras to get the work done easily. It uses Tensorflow (or Theano) as backend but it is almost transparent. The type of layer depend on you representation of the features. You should concern not only about the type of layers but also about the entire network architecture. Anyway as a baseline, I'll try with a sequential model of full conected layers combining layers with relu and sigmoid activations.  
  > **username_0**: Hey, thanks a lot for the feedback! I'll check Keras and I'll try to implement that idea and I'll try to reply soon.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-01-22. Score: 2
  
  The game state consists of the location of all the hidden cards, so you probably need a softmax layer, 52\*n, where n is the number of locations.
  
  I'm not very sure that a NN is a good match.
  
  > **Comments:**
  > **username_0**: Thanks for the reply! I had a typo saying the "state composed of a tensor with cards in the players hand", I meant in the player's own hand. The last layer could indeed be a softmax activation layer. Once i'm able to test it, I'll reply (i'm still having problems with the rest of the architecture). I tried 2 fully connected layers with relu and sigmoid activation and curiously got a worse result than with a simple weights matrix.  
  
  ---
  
  ### Answer by username_3 on 2018-03-25. Score: 1
  
  With images, you can use CNN because of the translational invariance. A filter which is good in one area will probably be good in another area, too.
  
  With images, you must use CNN because otherwise, there would be too many weights to train.
  
  With your game, it depends on the representation and the exact rules. Note that Alpha Zero uses a set of 19 x 19 inputs with CNN for playing Go.
  
  In a game like Bridge, where each card has its color and rank, there's a kind of translational invariance. Having Ace and Queen is a bit similar to having King and Jack - in both cases you have a 50% chance of catching the card in between. At the same time, the strengths of AQ and KJ are very different, so a pure CNN would improbably work well.
  
  The more important symmetry is the one among colors. After the auction, there's one or none trump color and all other colors are equivalent. This probably means that the corresponding weights should be the same.
  
  In some card games, many cards are special and there's no symmetry at all. You didn't tell us anything about your game, so it's hard to give a more concrete advice.
  
  > **Comments:**
  > **username_0**: (Part 1 Comment) Thanks for your response. Before I learned more about NN I though they would be more generalist. The game is not too complicated, there can be an N number of players, to which all cards in the deck are distributed in the beginning. For example 4 players mean each will start with 13 cards, and the winner is the first to have no cards in hand. To get rid of the cards they will play them in turn order and can choose to play cards or not play. The only rules are  that the players always have to play higher cards than  previously played.  
  > **username_0**: (Part 2 of the Comment) Once no one wants to play a card (or can't), the last player to play a card gets to play any card he wants and start a new cycle.  The game is highly stochastic because the players can start with low level cards and lose the game even if they played better than the opposition, which complicates the use of greedy epsilon exploration.  
  
  ---
  
  