Getting a random number wihout RND. - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: Getting a random number wihout RND. (/showthread.php?tid=2052) |
Getting a random number wihout RND. - Dav - 09-30-2023 A while back I found some TI-84 code for a random number generator. Played with it for a while, adapting it to QB64. Messed with the calcs. Gave it more randomness (I think) by feeding it the starting x/y position of the QB84 windows that seems to be placed randomly, and threw in TIMER for good luck. I don't really understand it, but here it is for anyone interested in such a function. - Dav Code: (Select All)
RE: Getting a random number wihout RND. - Dav - 09-30-2023 Hmm, this works in older QB64 but I just tried it in QB84-PE and it's not working. I should of tested it in that before posting . Hang on and let me see if I can get it working in QB64-PE. EDIT: Now it's working, had to add a _DELAY .25 at the beginning so _SCREENX/_SCREENY would be there. - Dav RE: Getting a random number wihout RND. - bplus - 09-30-2023 (09-30-2023, 11:06 PM)Dav Wrote: Hmm, this works in older QB64 but I just tried it in QB84-PE and it's not working. I should of tested it in that before posting . Hang on and let me see if I can get it working in QB64-PE. Your seed sucks (dont take it personal), just set it to Timer. No delay needed. RE: Getting a random number wihout RND. - Dav - 09-30-2023 (09-30-2023, 11:19 PM)bplus Wrote:(09-30-2023, 11:06 PM)Dav Wrote: Hmm, this works in older QB64 but I just tried it in QB84-PE and it's not working. I should of tested it in that before posting . Hang on and let me see if I can get it working in QB64-PE. Gosh - I could had sworn when I tried it that way I was getting patterns (I tested with PSET). But, it does seems to be working with just timer. EDIT: Oh I bet that was when I was putting seed=timer inside the function at first, which didn't work well. - Dav RE: Getting a random number wihout RND. - bplus - 09-30-2023 (09-30-2023, 11:27 PM)Dav Wrote:(09-30-2023, 11:19 PM)bplus Wrote:(09-30-2023, 11:06 PM)Dav Wrote: Hmm, this works in older QB64 but I just tried it in QB84-PE and it's not working. I should of tested it in that before posting . Hang on and let me see if I can get it working in QB64-PE. Or maybe it has to be past a certain time for timer to work? I just got lucky (i'm due). RE: Getting a random number wihout RND. - SMcNeill - 10-01-2023 http://qb64phoenix.com/forum/showthread.php?tid=173 -- Might be interested in this old read as well. RE: Getting a random number wihout RND. - TerryRitchie - 10-01-2023 I actually gave this some serious thought about 15 years ago and was going to build a proof of concept around an Arduino build. Tune a receiver to 1.42 MHz (the hydrogen band) and sample the incoming signal 64 times. Above a certain noise threshold becomes a 1, at or below becomes a 0, then normalize the result to between 0 and .9999 repeating. I envisioned Wifi chips could have the included 1.42 MHz receiver or a simple receiver circuit built into every motherboard for software to access to get true random numbers. Never built it. Maybe I should dust this project off. RE: Getting a random number wihout RND. - Dav - 10-01-2023 (10-01-2023, 12:12 AM)SMcNeill Wrote: http://qb64phoenix.com/forum/showthread.php?tid=173 -- Might be interested in this old read as well. Interesting. Thanks for the link. - Dav RE: Getting a random number wihout RND. - eoredson - 10-02-2023 I would just set seed = timer and run Code: (Select All) Do RE: Getting a random number wihout RND. - euklides - 10-02-2023 randomize timer ??? |