redneck wrote:
-∞
Is luck is a pure luck?!
- optimist - it's pure and it's an unpredictable random event.
- pessimist - luck in computing is created using the function void rand(void) which can be calculated mathematically :
U(0) = 0 (by default)
U(n+1) = ƒ(U(n))
U(0) is called the "grain". It's a constant so every execution of the program will give the same "random" number. In another word, randomness is determinist.
An example in C (u can compile this to test):
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i;
float a;
for (i=0; i<10; i++) {
a = rand();
printf("%f\n", a);
}
system("PAUSE");
return 0;
}
If u really want a random number, u have to change the grain which is modified everytime. For ex:
Code:
srand(time(NULL));
will set the grain to the UNIX time so that i can be modified
every second.
To code the chance of success, u can code like this : (for ex success 20%)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i;
float a;
srand(time(NULL));
for (i=0; i<10; i++) {
a = rand()/(RAND_MAX+0.0);
if (a<0.2) {//success instructions}
else {//fail instructions}
printf("%f\n", a);
}
system("PAUSE");
return 0;
}
If u have the source code of alchemy, making an item +255 is not so very difficult. The only thing u have to do is making a 3rd pt program that "hack" the success.