📧 Message Board Archive

Randomizer
So then no one has any idea how to do this? :(
Re: Randomizer
: So then no one has any idea how to do this? :(



do you want to make a script who draws random numbers between 0 and 345978345861298365, and then make them into numbers between 0 and 100?
Re: Randomizer
: : So then no one has any idea how to do this? :(

: do you want to make a script who draws random numbers between 0 and 345978345861298365, and then make them into numbers between 0 and 100?



No, I want to start with a non-random number from 0 - 244140625 and turn it into a random number from 1 to 100 (or so). And it must always have the same output for any given input value. Got it? It's a little complicated I know.



If it wasn't I would have figured it out already. :p
Re: Randomizer
: : : So then no one has any idea how to do this? :(

: : do you want to make a script who draws random numbers between 0 and 345978345861298365, and then make them into numbers between 0 and 100?

: No, I want to start with a non-random number from 0 - 244140625 and turn it into a random number from 1 to 100 (or so). And it must always have the same output for any given input value. Got it? It's a little complicated I know.

: If it wasn't I would have figured it out already. :p



hmmm, not unless you make a whole lot of vars:> i dont really understand why this is necessary, there is no alternative to what you want to do?

Re: Randomizer
: So then no one has any idea how to do this? :(



I'm sure if you tinkered with something like;

int &a = &result * 7;

int &b = &a -= 6;

if (&result > 10)int &c = &b +=3}

if( &c < 8 ) int &d = &c += 5 ;

I just don't know if dink likes negative numbers.
Re: Randomizer
: : So then no one has any idea how to do this? :(

: I'm sure if you tinkered with something like;

: int &a = &result * 7;

: int &b = &a -= 6;

: if (&result > 10)int &c = &b +=3}

: if( &c < 8 ) int &d = &c += 5 ;

:  I just don't know if dink likes negative numbers.



Hmm this looks interesting, but I'm not sure I understand what it would do. I don't think it would run in dink though, stuff like &b = &a -= 6; isn't supported.



What is that meant to do? Subtract six from &a, then store the new &a in &b? Negative numbers are okay though. Could you explain this a little more, which number is the output?
Re: Randomizer
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.
Re: Randomizer
: 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.  
Re: Randomizer (spoilly)
: : 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.
Re: Randomizer (spoilly)
: : : 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 (?).
Re: Randomizer (spoilly)
: 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.
Re: Randomizer (spoilly)
: 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.

Re: Randomizer (spoilly)
: : 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.
Re: Randomizer (spoilly)
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.
Re: Randomizer (spoilly)
: 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.



It sounds cool, but does DinkC support mod function?

Re: Randomizer (spoilly)
: : 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.

: It sounds cool, but does DinkC support mod function?



You can kinda do it.  So, 134 mod 12 is done by:



int $b = 12;

int $c = 134;



int $d = $c;

$d / $b;

$d * $b;

$c - $d;



There is probably a better way to do it, but it gets the job done (I think).
Re: Randomizer
: So then no one has any idea how to do this? :(



Doesn't seem like it.  Most of what you were writing about went right over my head.  I suppose you could just have a helluva lot of if statements :)
Re: Randomizer
: So then no one has any idea how to do this? :(



how did you make that link? did you use the URL link box or html? i hav tried with html, but it just puts the adress after http://dink.telefragged.com/cgi-bin/board

can you help me?
Re: Randomizer
: how did you make that link? did you use the URL link box or html?



URL link box