Skip to content

Instantly share code, notes, and snippets.

@azyu
Last active August 29, 2015 14:17
Show Gist options
  • Save azyu/8e41d08133f7e45375fd to your computer and use it in GitHub Desktop.
Save azyu/8e41d08133f7e45375fd to your computer and use it in GitHub Desktop.
Gacha - Love Live!
#include <random>
#include <iostream>
#include <unordered_map>
std::discrete_distribution<> dist({
90, // 90%
9, // 9%
1, // 1%
});
std::vector<std::string> itemname = { "R", "SR", "UR" };
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::unordered_map<int, int> countmap;
for (int i = 0; i < 10000; ++i)
{
++countmap[dist(gen)];
}
for (const auto & pair : countmap)
{
std::cout << itemname[pair.first].c_str() << ": " << pair.second << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment