* Takes the state of one complete game and returns features suitable for * training. Returns an object containing features = player1's hand represented * using oneHot encoding, and label = whether player 1 won. * @param {*} gameState
(gameState)
| 54 | * @param {*} gameState |
| 55 | */ |
| 56 | function gameToFeaturesAndLabel(gameState) { |
| 57 | return tf.tidy(() => { |
| 58 | const player1Hand = tf.tensor1d(gameState.player1Hand, 'int32'); |
| 59 | const handOneHot = tf.oneHot( |
| 60 | tf.sub(player1Hand, tf.scalar(1, 'int32')), |
| 61 | game.GAME_STATE.max_card_value); |
| 62 | const features = tf.sum(handOneHot, 0); |
| 63 | const label = tf.tensor1d([gameState.player1Win]); |
| 64 | return {xs: features, ys: label}; |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Collects one random play of the game. Processes the sample to generate |
no outgoing calls
no test coverage detected