View Single Post
  #12  
Old 08-30-2001, 03:21 AM
Skatche Skatche is offline
Registered User
Join Date: Aug 2001
Location: Gehennom
Posts: 353
Skatche is on a distinguished road
Send a message via AIM to Skatche
I think I know, basically, how a sine wave-ish pattern, which still has some randomness, can be achieved. Basically you have a variable that goes up and down in a wave pattern as time passes, anywhere from, say 20 gralats to 500 gralats per stock. Then you make an array with, say, 55 elements. Then you initialize it something like this:

NPC Code:
setarray possible_values, 55;
for(i = 0; i < 25; i++) {
possible_values[ i ] = median;
}
for(i = 25; i < 35; i ++) {
possible_values[ i ] = median + 5;
}
for(i = 35; i < 45; i ++) {
possible_values[ i ] = median - 5;
}
for(i = 45; i < 50; i ++) {
possible_values[ i ] = median + 15;
}
for(i = 50; i < 55; i ++) {
possible_values[ i ] = median - 15;
}



Now by accessing a random element of the array every minute, say, we get a nice, probability-adjusted new value for the stocks. I'm sure that can be optimized a lot, and needs some tweakage to get it nicely balanced, but beyond that all that'd need to be made is some way of randomly determining the high and low points of the next wave, and the length of the wave, and then change the current stock values based on a function of the time, but that shouldn't be too hard.

[edit] Whoops... I added in some important details that I originally left out.
__________________
Skatche, head priest of the Cult of Duckduck.
Praise Duckduck!

Last edited by Skatche; 08-30-2001 at 03:29 AM..
Reply With Quote