1
$\begingroup$

I'm trying create neural network to predict moves in a card game. I am looking for recommendations on encoding the game state to my input layer. It's a complex turn based collectible card game (think Magic the Gathering). I need to represent cards being in various areas of the game board (deck, discard pile, hand, etc). It seems difficult to assign cards to these areas because the number of cards in these areas is never constant.

I was thinking of an approach where I assign each card in the game to being in a specific card area. The number of total cards in the game should be constant (let's assume that). This approach I feel should give me a potentially less sparse input.

Also, With this approach what is the best way to handle card duplicates? Let's say I have 3 copies of the exact same card in my deck. Maybe 1 of the copies is in my hand and 2 in my discard pile. It does not matter which of the 3 copies is in my hand because they are all the same exact card. There is now multiple ways to represent this same exact game state in my network because each individual card has it's own state. To me this does not seem good. How much will this effect my neural network's ability to learn the game?

$\endgroup$
0
$\begingroup$

I am not sure what you mean by

There is now multiple ways to represent this same exact game state in my network because each individual card has it's own state. To me this does not seem good.

We can think of game state as a column vector of the form 1xn. In this case, you can formalize cards held according to some encoding. This can be anything from a Gödel Numbering to simple integer assignment. Here is an example for poker in python: https://pypi.org/project/treys/

In the example of duplicates you would have a column vector that simply has duplicate indices. I.e: {241, 424, 112, 112, 455}

$\endgroup$
  • $\begingroup$ In this case your column vector has indices indicating the card. I mentioned in my question that this doesn't work well because in order to represent a players hand your column vector is of variable size. Instead consider the column to be a specific card in the game and the indices to be the current state of that card (deck,hand,discard,etc) $\endgroup$ – ngroover Mar 12 at 2:30
  • $\begingroup$ @ngroover Why not just pad the vector? $\endgroup$ – hisairnessag3 Mar 12 at 8:30
  • $\begingroup$ I guess that's part of my question is lots of padding bad? Does the network even learn correctly if there is more zero padding than actual relevant data? It seems to me that it would not work well $\endgroup$ – ngroover Mar 13 at 12:56
  • $\begingroup$ @ngroover, well I assume that n cards aren't possible? I.e you can't have 100000 cards. If they aren't just set the pad to the upper bound and 0 or similar encoding will represent a empty card 'slot'. You would only likely run into trouble in training an agent if the possible cards was in the hundreds $\endgroup$ – hisairnessag3 Mar 13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.