jeudi 22 juillet 2021

picking a truly random number from a vector in cpp [duplicate]

I have this current code

    std::string randomMove = possibleMoves[rand() % possibleMoves.size()];
    int randomMoveInt = std::stoi(randomMove);
    board[randomMoveInt-1] = "StackOverflow";

But everytime I restart the program the pattern is the same and does not change no matter how many times I run it. Is there a way to avoid this/any ideas? Thanks




Aucun commentaire:

Enregistrer un commentaire