0

In a made up card game there are 2 players, each of which are dealt 5 cards (standard 52 card deck), after which some arbitrary function decides a winning player. The goal is to predict the outcome of the game, given the 5 cards that each player is holding. The training data could look something like this:

Player A      Player B      Winner

AsKs5d3h2d    JcJd8d7h6s    1
7h5d8s9sTh    2c3c4cAhAs    0
6d6s6h6cQd    AsKsQsJsTs    0

Where the 'Player' columns are 5 card hands, and the 'Winner' column is 1 when player A has won, and 0 when player A has lost.

There should be an indifference towards the order of the hands, such that after training, feeding the network mirrored input data like:

Player A      Player B

2d3d6h7s9s    TsTdJsQc3h

and

Player A      Player B

TsTdJsQc3h    2d3d6h7s9s

will always predict opposite outcomes.

It should also be indifferent to the order of the cards within the hands themselves, such that AsKsQsJsTs is the same as JsTsAsKsQs, which is the same as JsQsTsAsKs etc.

What are some reasonable ways to structure a neural net and its training data to tackle such a problem?

luna_
  • 312
  • 3
  • 15
  • 1
    ooc why do you feel neural nets were the most appropriate structure to tackle this supervised learning problem? Have you used NN's for similar problems ? – WestCoastProjects Feb 16 '16 at 08:13

2 Answers2

1

You are going to need a network with 104 inputs (players * number of cards) The first 52 inputs correspond to player A, the next 52 correspond to player B. Initialize all inputs to 0, then for each card each player has, set the corresponding input to 1.

For the output layer there are usually two options for binary classification. You can have one output neuron, and if the output of this neuron is greater than a certain threshold, player A wins, else player B wins. Or you can have two output neurons and just look at which one produces the highest output. Both generally work fine.

For training data, instead of something like "AsKs5d3h2d", you will need a one-hot encoding, something like "0001000001000000100100000100000000011001000000001001" (pretend there are 104 numbers, 10 of them are 1's and the rest are 0s) And for output data you just need a 1 or a 0 corresponding to who won (in the case of having one output neuron)

This will make your network invariant to the order of the cards (all possible orders of a given hand will create the same input) And as for swapping player A and B's hands and getting the opposite result, this is something that should come naturally to any well trained network.

Frobot
  • 1,224
  • 3
  • 16
  • 33
  • Thanks, this explains it well. Is there a point at which using one-hot encoding doesn't make sense to use any more? e.g. let's imagine a 500 card deck (unique cards), and each player has a 5 card hand. In this case you'll end up with 990 0s and 10 1s. – luna_ Feb 17 '16 at 18:34
  • I haven't experimented or read anything on this specifically, but I can say that for image classification it isn't uncommon to see networks with over 100,000 inputs (a 200x200 RGB image = 120k inputs) so I would guess that one-hot would still be fine with that many inputs as well. – Frobot Feb 18 '16 at 02:20
0

First, you should understand the use of Neural Network (NN) before going ahead with this problem. NN tries to find out complex relationship between input and output. (here your input is five cards and output is predicted class).

Here in this question, relationship between input and output can easily be formulated. i.e. you can easily choose some set of rules which declares a final winner.

Still like any other problem, this problem can also be dealt with NN. First you need to prepare your data.

There are total 52 type of inputs possible. So, take 52 column in dataset. Now in these 52 column you can fill three type of categorical data. Either it belongs to 'A' or 'B' or no body. 'C' and output can be the winner .

Now you can train it using NN.

saurabh agarwal
  • 2,124
  • 4
  • 24
  • 46