[Bf-committers] Random IPO Generator
Reuben Martin
reuben.m at gmail.com
Sat Jan 14 19:04:59 CET 2006
On 1/12/06, Reuben Martin <reuben.m at gmail.com> wrote:
> On 1/10/06, Yann Vernier <yann at donkey.dyndns.org> wrote:
> > On Tue, 10 Jan 2006 14:05:20 -0600
> > Reuben Martin <reuben.m at gmail.com> wrote:
> >
> > > I hope the following "sudo-code" will give an idea of what I'm talking
> > > about. (Yes, it's awful, but I haven't written serious code in almost
> > > 10 years)
> > <snip>
> > > Hope that gives the "general idea" of how the randomness would be
> > > controlled.
> >
> > That would be pseudo code.
>
> Ack. Too much use of "su" within my shell...
>
> >In this case, it's very nearly C99.. if you
> > just typedef int var; it basically works. But the algorithm in there is
> > a simple capped line, not at all random. I think you're looking more
> > for a randomly varying step size for a fairly smooth curve, or just
> > random values for a wilder one.
>
> Well the cap is just for setting limits. If you'll take a closer look
> the use of a random bool function will control weather or not the
> curve moves up or down. The momentum determines how often the curve
> has the chance to change directions. I'm thinking there should also be
> a way to add jitter in there somewhere, but haven't quite figured out
> where that would fit in.
>
I realize now why you said this is just a caped line. I had implied
that this algorithm would be inside of a loop, but never explicitly
said so in the email. So maybe this would make more sense:
var max_ipo_value; //sets upper limit for the IPO
var min_ipo_value; //sets lower limit for the IPO
var ipo_value; //the value that the random IPO key will have
var ipo_time; //the time at which the random IPO key will be placed
var speed; //the higher the value, the slower the IPO curves move
var momentum; //the lower the value, the more erratic the
IPO curves are
var step_sze; //the higher the value, the steeper the slope
of the IPO curves
var start_time // where in the time line to start generating IPO values
var stop_time //where in time line to stop generating IPO values
//start out between the min and max
ipo_value := min_ipo_value + ((max_ipo_value - min_ipo_value) / 2)
ipo_time := start_time
set_ipo_key (ipo_value, ipo_time)
//start the loop
while (ipo_time < stop_time) do {
direction := generate_random_bool();
if (direction = true) then {
for (i = 0, i < momentum, i++) do {
ipo_value += step_size;
if (ipo_value > max_ipo_value) then ipo_value =
max_ipo_value;
ipo_time += speed;
set_ipo_key (ipo_value, ipo_time);
}
}
else {
for (i = 0, i < momentum, i++) do {
ipo_value -= step_size;
if (ipo_value < min_ipo_value) then ipo_value =
min_ipo_value;
ipo_time += speed;
set_ipo_key (ipo_value, ipo_time);
}
}
}
More information about the Bf-committers
mailing list