Hello: We have code for our stock market on our mud, and it is supposed to have the stocks fluctuate but it seems to only send the stocks skyrocketing up to an insane price. Is there a better way to handle this? We are open to suggestions?
void stock_update() { STOCKS *stock; int gain = 0; int days; int flux = dice(1,7) - 4; int stock_flux = dice(1,9);
switch(stock->phase) { case 0: sprintf( log_buf, "STOCK: %s's new price is %d. No movement.", stock->name, stock->cost ); log_string( log_buf ); break;
case 1: gain = (stock->upordown * stock->cost + stock_flux * stock->cost + days) / 1000; sprintf( log_buf, "STOCK: %s's move is %d.", stock->name, gain ); log_string( log_buf ); stock->cost += gain; sprintf( log_buf, "STOCK: %s's new price is %d.", stock->name, stock->cost ); log_string( log_buf ); break;
case 2: /* This version is what we'd like to use, but it doesn't compile on portent. gain = stock->upordown * stock->cost * log(days + 1) / 100; */ /* This is the fallback position for when the preferred doesn't compile. */ gain = ((stock->upordown * stock->cost) * (sqrt(days + stock_flux) *(32/100))) / 1000; sprintf( log_buf, "STOCK: %s's move is %d.", stock->name, gain ); log_string( log_buf ); stock->cost += gain; sprintf( log_buf, "STOCK: %s's new price is %d.", stock->name, stock->cost ); log_string( log_buf );
We have code for our stock market on our mud, and it is supposed to have the stocks fluctuate but it seems to only send the stocks skyrocketing up to an insane price. Is there a better way to handle this? We are open to suggestions?