Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Statsman1

Pages: [1]
1
QB64 Discussion / Bad random numbers, or TIMER limitation...?
« on: October 25, 2021, 08:18:02 pm »
Hey guys...

Picture 6 horses in a race, using the TIMER function at the START and FINISH to calculate elapsed time.  They finish with the following times (in seconds)...

Racer 1    31.30453     
Racer 2    31.48992     
Racer 3    31.50592     
Racer 4    31.8607     
Racer 5    32.23148     
Racer 6    32.41687

Then picture 6 different horses in a race, but same distance as race 1.  This time, the results (in seconds) are...

Racer 7    30.93375     
Racer 8    30.94975     
Racer 9    31.11914     
Racer 10  31.30453     
Racer 11  31.48992     
Racer 12  31.50592

Note that Racer 11 and Racer 12 have EXACTLY the same times as Racer 2 and Racer 3.  The fact that all 6 times are not the same is encouraging, but how on earth could two identical times be possible, let alone have it happen twice?

I have seen this happen over a series of races...duplicate times (but not duplicate places in finish) come up a LOT.  For instance, the time 32.77441 has happened 6 times in 30 races.  That just doesn't seem to be right.

I have used the RANDOMIZE (-TIMER) and RANDOMIZE (TIMER) functions within the program - the first is used to determine how far forward the horse moves (the maximum is 3 pixels, the minimum is 1 pixel, so in practice, thus the average is 2 pixels).   The second is invoked after every horse has moved, to calculate a random-length system delay between each move.  To me, this means a new seed is generated every single time the program accesses the routine used to create the delay, I then take the average of 100 random numbers, and use this as the delay..maybe I misunderstand this function.

        Randomize (Timer)
        L = 0
        For J = 1 To 100
            K = Rnd(1) / 1000
            L = L + K
        Next J

        m = L / 10

        _Delay (m)

Anyway, I get that over running a series of random numbers between 1 and 3 will average 2, and that if you do that constantly over the same distance, you will get very similar times to complete the race...but introducing that random delay should be enough to avoid timing duplication down to the 100,000th of a second, shouldn't it?



2
QB64 Discussion / Plotting / erasing points on a circle
« on: September 28, 2021, 09:38:12 pm »
Hey everyone!

I hope you are all doing well. 

Here's the scenario...

Starting at the top of a circle and going counter-clockwise, I would like to...

Plot a filled dot at the top of the circle (using a radius of 1, then on an X-Y plane, center of circle at (0,0) that dot would be centered at (0,1)).

Determine at random how far along the circle the new dot will go, counter-clockwise.

Erase the previously drawn dot.

Plot the new dot.

Continue until the dot has passed through (-1,-1) and reached (0,-1).

Sort of like drawing a ball on a roulette wheel, but only one-half of a complete rotation, starting at the 12-o'clock position and going backwards to the 6-o'clock position.

I realize that the CIRCLE and PSET commands are in order here, and while I can determine the start and stop coordinates, I am having a heck of a time wrapping my head around the rest of it.  SIN and COS are long-forgotten trig functions, and I suspect I am using them to solve this...

Anybody have an idea here?

Thank you in advance!

Edited -

Using this...

Screen 12

Const Pi = 3.1415926

Circle (325, 225), 180, 6
Line (325, 225)-(x, y), 0

For j = 1 To 360
    Input "Enter value for point:"; s
    x = Int(Sin(s / 180 * Pi) * 180) + 325
    y = Int(Cos(s / 180 * Pi) * 180) + 225
    Line (325, 225)-(x, y), 15
Next j

- I bulldozed my way to learn that if s = 90, that code will draw a line from (0,0) to (1,0)

So, when s = 180, the result is a line from (0,0) to (0,1).  Yay.
And, when s = 0 or 360, the result is a line from (0,0) to (0,-1). Yay.

Accordingly, tomorrow, I have something to work on.  Any suggestions are welcome, but I think I figured out one route.

All the best, everyone!

3
QB64 Discussion / Use TIME$ to calculate elapsed time to tenth of a second?
« on: September 23, 2021, 08:02:44 pm »
Hey guys...

I am trying to capture the elapsed time of on-screen event, using Time$, and I can definitely get the seconds, but is there a way to calculate elapsed tenths of a second?

I am using val(right$(time$,2)) to get the seconds, but I am finding that capturing the tenths of a second is not evident.

Thank you!

Pages: [1]