: : : I auusme that you want to return a fixed number between 1 and 100 wrt x, y, and screen number. You choose 625 for the upper limit (that's where your 244,140,625 came from.)
: : : It's not that hard for a normal program to do this, but DinkC does not support a complicated operation. What Ric suggested might work in the following way:
: : : int &crapx = sp_x(1, -1);
: : : if (&crapx == 0)
: : : {
: : : &crapx = 1;
: : : }
: : : int &drapy = sp_y(1, -1);
: : : if (&drapy == 0)
: : : {
: : : &drapy = 1;
: : : }
: : : int &erapN = &player_map;
: : : int &frap1 = 0;
: : : int &grap2 = 0;
: : : wait(1);
: : : &frap1 = &erapN;
: : : &frap1 * &crapx;
: : : &frap1 / &drapy;
: : : &grap2 = &frap1;
: : : &frap1 = &erapN;
: : : &frap1 * &drapy;
: : : &frap1 * 2;
: : : &frap1 / &crapx;
: : : &grap2 += &frap1;
: : : &frap1 = &crapx;
: : : &frap1 * &drapy;
: : : &frap1 * 3;
: : : &frap1 / &erapN;
: : : &grap2 += &frap1;
: : : mainloop:
: : : if (&grap2 > 100)
: : : {
: : : &grap2 -= 100;
: : : goto mainloop;
: : : }
: : : The script above would give you a number between 1 and 100 from the following formula:
: : : Nx/y + 2Ny/x + 3xy/N
: : : You can come up other better formula. I don't know the upper limit of an integer in DinkC, but I think this should work.
: : Ya but Paul, what kind of input will start it?, keystroke, choice menu, or dinks' position? And how big a number can it be?We can get a formula to look random o.k. , but we need to know you input and output.
: I should warn that this might give away a few parts of my d-mod, so there's no need to read it unless you're trying to help. (or just want to know of course :p)
: Okay, as I explained before, there are two seperate situations where I want to do this. In one case the input is 12 knobs, each of which can be in 5 positions. Story aside, it's basicially a combination lock. This one is probably really okay with the lame formula I have now.
: In the other the input is co-ords (one unit being one screen) on a map from 0 to infinity for X and minus infinity to infinity for Y. But the number will actually be much smaller becuase dink will have to actually walk the whole way, starting from 0, 0. This is the one I'm concerned about, because if it's not random enough, the player could easily see the partern as dink walks from room to room.
i do not know much dinkc, but i think that if you still want a more random output you could make several scripts and draw a random one (?).
: The script above would give you a number between 1 and 100 from the following formula:
: ( Nx/y + 2Ny/x + 3xy/N ) mod 100
The beauty of the formula I proposed is that you can't really figure it out unless you do know the formula. It looks very simple, but the outcome does look like random. I didn't try to see if you can get an equal probability from 1 to 100, but I did run it with Dink engine and it seems just great for your application. You can simply change the coefficients 1, 2, and 3 and get a completely different set of numbers. And nobody can figure it out the pattern.
: The script above would give you a number between 1 and 100 from the following formula:
: ( Nx/y + 2Ny/x + 3xy/N ) mod 100
I just tested the upper limit of an integer in DinkC and found out it's about 2,145,032,703. So if you like, you can make the formula even more complicated like
( Nx/y + 2Ny/x + 3xy/N + 123456/Nxy) mod 100
The reason that I add the last term is to remove the obvious trivial output for small x, y, and N.
: : The script above would give you a number between 1 and 100 from the following formula:
: : ( Nx/y + 2Ny/x + 3xy/N ) mod 100
: The beauty of the formula I proposed is that you can't really figure it out unless you do know the formula. It looks very simple, but the outcome does look like random. I didn't try to see if you can get an equal probability from 1 to 100, but I did run it with Dink engine and it seems just great for your application. You can simply change the coefficients 1, 2, and 3 and get a completely different set of numbers. And nobody can figure it out the pattern.
Thanks. I also got an answer from sci.math recomending I use mod a couple time, like this:
(37*(37*(n mod 10) + n/10)) mod 30
Which also sounds good. They also told me, "what you're looking for is usually called a 'hash function'. In addition, you're looking for one that cryptographically secure (although perhaps very weakly so)." Good to know. ;)
Anyway now I've got a couple methods to try out now. I'm sure one of the two (if not both) will work well for what I need.
For that use I like what Mimifish had cooking. I would try it in a test script first to see if the numbers came out in the range you need, then start trying it with graphics. Hope it works , that sounds cool.