Seed rng with time.

master
sigonasr2 2 years ago
parent 9cccbec9b7
commit 03412fcfd9
  1. 5
      Solitaire/main.cpp

@ -125,14 +125,15 @@ class Solitaire : public olc::PixelGameEngine
Card DrawCard() { Card DrawCard() {
std::uniform_int_distribution<int> distribution(0, cardDeck.size()-1); std::uniform_int_distribution<int> distribution(0, cardDeck.size()-1);
int dice_roll = distribution(generator); int dice_roll = distribution(generator);
std::cout << dice_roll << std::endl; //std::cout << dice_roll << std::endl;
Card drawnCard = cardDeck[dice_roll]; Card drawnCard = cardDeck[dice_roll];
cardDeck.erase(cardDeck.begin() + dice_roll); cardDeck.erase(cardDeck.begin() + dice_roll);
return drawnCard; return drawnCard;
} }
bool OnUserCreate() override bool OnUserCreate() override
{ {
for (int i = 0; i <= SPADE; i++) { generator.seed(time(NULL));
; for (int i = 0; i <= SPADE; i++) {
for (int j = 1; j < 14; j++) { for (int j = 1; j < 14; j++) {
cardDeck.push_back({ (Suit)i,j }); cardDeck.push_back({ (Suit)i,j });
} }

Loading…
Cancel
Save