This looks like the perfect place for a std::discrete_distribution.
Walkthrough:
#include <algorithm>
#include <iostream>
#include <map>
#include <random>
#include <vector>
// A seeded pseudo random number generator:
static std::mt19937 gen(std::random_device{}());
int main() {
Say you have all the player choices in a vector. You seem to have them in an array, but I'll use a vector since it's easier to handle.
// filled with some example choices:
std::vector<int> m_playerChoices{10,10,11,10,22,22,10};
I'd start by making a histogram so that you get the count of each choice:
std::map<int, int> hist;
for(int choice : m_playerChoices) {
++hist[choice];
}
Then we extract the choices and counts from the histogram and put in two separate vectors. One containing all the unique choices and a corresponding one containing the count of each, called weights.
std::vector<int> unique_choices;
std::vector<int> weights;
for(auto[choice, count] : hist) {
unique_choices.push_back(choice);
weights.push_back(count);
}
The weights are then used to create a discrete_distribution:
std::discrete_distribution<int> dist(weights.begin(), weights.end());
You can now call the pseudo random number generator and use this discrete distribution to get one of the unique numbers and the probability for each will be exactly according to the count of each choice that you started out with:
for(int i = 0; i < 100; ++i) {
std::cout << unique_choices[dist(gen)] << '\n';
}
}
Demo