asdfguy Posted November 20, 2014 Share Posted November 20, 2014 Hello, i've already had a look at the available #include from autoit, and noticed that the Random() Func of au3 isnt included there. Can anyone help me creating this function in c++? Cheers Link to comment Share on other sites More sharing options...
funkey Posted November 20, 2014 Share Posted November 20, 2014 Why not search for 'random c++' ?? http://www.cplusplus.com/reference/cstdlib/rand/ http://en.cppreference.com/w/cpp/numeric/random/rand Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
asdfguy Posted November 20, 2014 Author Share Posted November 20, 2014 The seeding to rand() in c++ is a bit retarded for me, considering i am using multiple instances of a programm and it always has the same time seed, which is why i want a function that doesnt randomize me a number by time. Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted November 20, 2014 Share Posted November 20, 2014 You want to know how Au3 creates Random? Or m'i misunderstanding something? Link to comment Share on other sites More sharing options...
funkey Posted November 20, 2014 Share Posted November 20, 2014 Here is an example using same algorithm AutoIt does: #include <random> #include <iostream> using namespace std; int main() { random_device rd; // non-deterministic generator mt19937 gen(rd()); // to seed mersenne twister. uniform_int_distribution<> dist(1, 1000); // distribute results between 1 and 1000 inclusive. for (int i = 0; i < 5; ++i) { cout << dist(gen) << " "; // pass the generator to the distribution. } cout << endl; } Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
asdfguy Posted November 20, 2014 Author Share Posted November 20, 2014 Thank you, exactly what i was looking for. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now