Skip to content

Commit

Permalink
fix bug: step requires card metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonifatius94 committed Dec 3, 2023
1 parent ba691f0 commit ecc5066
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Schafkopf.Training/Algos/MDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private void prepareRewards(GameLog[] states, Matrix2D rewards)
private Card[] cardsCache = new Card[8];
private void playGame(CardPickerEnv[] envs, GameLog[] states, TurnBatches[] batchesOfTurns)
{
var selCards = new Card[states.Length];

for (int t_id = 0; t_id < 8; t_id++)
{
var batches = batchesOfTurns[t_id];
Expand Down Expand Up @@ -129,15 +131,13 @@ private void playGame(CardPickerEnv[] envs, GameLog[] states, TurnBatches[] batc
var possCards = rules.PossibleCards(states[envId], cardsCache);
var card = cardSampler.PickCard(possCards, piSlice);
int action = card.Id % 32;
selCards[envId] = card;
actions[envId] = action;
selProbs[envId] = piSlice[action];
}

for (int envId = 0; envId < envs.Length; envId++)
{
var action = new Card((byte)actions[envId]);
states[envId] = envs[envId].Step(action).Item1;
}
states[envId] = envs[envId].Step(selCards[envId]).Item1;
}
}
}
Expand Down

0 comments on commit ecc5066

Please sign in to comment.