Skip to content

Instantly share code, notes, and snippets.

@xNWDD
Created October 19, 2018 22:30
Show Gist options
  • Save xNWDD/8e959d88caabd0c373a6c50cc8198a7c to your computer and use it in GitHub Desktop.
Save xNWDD/8e959d88caabd0c373a6c50cc8198a7c to your computer and use it in GitHub Desktop.
axeswordbuzz.cpp
#include <cstdio>
unsigned int rand(int & s, unsigned int l, unsigned int h) {
s = (unsigned short)((unsigned short)(s * 12829U) + 47989U);
unsigned short r = ((s >> ((s >> 13u) + 3u)) ^ s) * 62169u;
return l + (unsigned int)((((unsigned int)(((r >> 11u) ^ r))) * ((unsigned int)(1 + h - l))) >> 16);
}
int main(int argc, char *argv[]) {
for (int i = 0; i < 100000; ++i) printf("%s: %u %s: %u\n",
"sword", (rand(argc, 50, 70) * 3) / (2 + ((int)(rand(argc, 1, 100) <= 80))),
"axe", rand(argc, 1, 120) * (((int)(rand(argc, 1, 100) <= 15)) + 1)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment