Speaking of random numbers and computers and how predictable they are. Many years ago in High school I wrote a program to randomly pick different screen colours. I used 4 different Apple II's and ran the program. Each computer displayed the exact same random colour in the exact same squence. I then started the program at different times and logged each colour displayed. They matched again. Makes one wonder if random numbers really exist or just complex calculations to appear random.
Okay, now you're really pushing the memories here...
I seem to recall on the Apple ]['s measuring the time between the start of a program and when the user replied to a "hit any key to start" prompt. That number was used to seed the random number generator, otherwise I got the same result that you did...
I also think it is more important to store the "so called" random numbers in a array so they don't repeat until all sequenced numbers have been picked. I use this in my random MP3 function.
If anyone looked at the G4 screen saver program I wrote, you might have noticed that I start out creating a list of randomly ordered numbers to determine the sequence that pictures will be shown in, then re-randomize the list when the first sequence of slides has finished.
That was inspired by my dissapointment with more than one computer-based screen saver that didn't run through the whole collection of images before repeating any of them.
You should see what Casinos do to generate random numbers for their slots and video poker games. Casinos can't use the computer algorithms because the patterns could be detected by a super human and give them an advantage. I'd like to see that!
I'm picturing miniature bingo-ball machines inside the video games!
But yeah, I'd like to see what they wind up doing - out of curiosity...
This is because most computer us what is called a "seed" to start the random number process, the seed is the starting point for the randomization algorithm. That's why each computer will always get the same starting number
I seem to recall on the Apple ]
Several languages including VB have a Randomize() function which is supposed to randomly set the seed. But who randomizes the randomizer?...
That was inspired by my dissapointment with more than one computer-based screen saver that didn't run through the whole collection of images before repeating any of them.
This reminds me of a time when I was playing with the Barix Exstreamer (a reasonably priced slick little network based MP3 player for digital audio streaming) when it first came out several years ago. I hooked it up and applied power and the Exstreamer?s IP was announced from its audio output. Pretty cool idea. I like it already.
So I setup a rather lengthy playlist and put it in random mode. A short while later I heard what I thought was a song that was already played. When I heard the same song a third time (before all the other songs were played once) my initial excitement for the product dampened. I voiced my concern with the random mode and the initial response was that the random mode DID play random. Every time a song was finished it randomly picked another song (but with no regard for what was played already...Doh!). I expressed my displeasure and suggested that what they really need to do is shuffle the songs and then play the sequence (as Chip mentioned with his screen saver) They agreed and fixed the random mode in the next firmware rev.
I don?t use the random function all that much but it could come in handy for a Netlinx Magic 8 Ball module. Turn a Modero over, ask it a question, flip it back over and get your answer. I really need some sleep....
Ok, now we have really gone off topic! Anyone remember the IR pulsing thread?
There is one simple solution that I have been using for some time. Yes, change the pulse time on every use but get a function to do it. The following is an axi file I use:
Ignore the compiler directives if using this in main code. Simlpy include the target device, the channel number and a pulse duration with "0" meaning default. You can define constants for the likes of DVD and VCR, etc. so they can be different as required.
Well, TimeWarner has changed their lineup again...And I finally had to deal with 4-digit pulses (no XCH for 4-digits yet?!?!?). Well, this solution came in handy and figured I would post some of it here for suggestions/improvements.
define_call 'TuneChannel' (dev dvIRDEV, integer nChannel) // For Leading Zeroes & 4-numeral channels
{
stack_var char sCHAN[4]
stack_var integer nLength
stack_var integer nLoop
stack_var char sSinglePart
sCHAN = itoa(nChannel)
nLength = length_string (sCHAN)
for ( nLoop = 1 ; nLoop <= 4-nLength ; nLoop++ ) // pad w/ zeroes
{
sCHAN = "'0', sCHAN"
}
for ( nLoop = 1 ; nLoop <= 4; nLoop++ ) // send individual pulses
{
sSinglePart = get_buffer_char (sCHAN)
send_command dvIRDEV, "'SP', (atoi("sSinglePart") + 10)"
}
}
DATA_EVENT [dvCableBox_01]
{
ONLINE:
{
SEND_COMMAND dvCableBox_01, 'CARON'
SEND_COMMAND dvCableBox_01, 'SET MODE IR'
// send_command dvCableBox_01, 'XCHM-2' // not used, using 4 digits here
SEND_COMMAND dvCableBox_01, "'CTON',1" // set time pulse is on
SEND_COMMAND dvCableBox_01, "'CTOF',2" // set time off between pulses
SEND_COMMAND dvCableBox_01, 'SET IO LINK 1' // SETS IO LINK TO IO #1, FOR POWERING UP/DOWN THE CABLE BOX, 5VDC
}
}
Since this is thread is quite old, I figured I would revisit and see if anyone else has other neato implementations... This one works pretty reliably and quickly with the CTON/OF settings.
// added edit: sending individual cmds needs to loop up to 4 not to nLength.
I couldn't find my post with the code I use, so here it is . . . yet again.
DEFINE_FUNCTION fnSEND_STATION (* Send station to device */
(DEV dvDEVICE, INTEGER n_STATION)
{
LOCAL_VAR INTEGER nNUM[4]
// Do some math to retreieve each number
nNUM[1]=( (n_STATION/1000) +10) // THOUSANDS
nNUM[2]=(((n_STATION%1000)/100) +10) // HUNDREDS
nNUM[3]=(((n_STATION%100) / 10) +10) // TENS
nNUM[4]=( (n_STATION%10) +10) // ONES
IF (n_STATION>=1000) // HI DEF CHANNELS
SEND_COMMAND dvDEVICE,"'SP',nNUM[1]"
SEND_COMMAND dvDEVICE,"'SP',nNUM[2]" // HUNDREDS
SEND_COMMAND dvDEVICE,"'SP',nNUM[3]" // TENS
SEND_COMMAND dvDEVICE,"'SP',nNUM[4]" // ONES
SEND_COMMAND dvDEVICE,"'SP',49" // SELECT
}
I of course did not write this function, but got it from someone else. I believe that person may have written, but the sources are completely unknown to me. Anyway, this is the one I use. I use the SELECT key to enter in the station so it quickly goes to that channel. Substitute it for whichever button you need.
Of course, set the CTON & CTOF times in the DATA_EVENT, and you'll be all set to go.
Comments
Okay, now you're really pushing the memories here...
I seem to recall on the Apple ]['s measuring the time between the start of a program and when the user replied to a "hit any key to start" prompt. That number was used to seed the random number generator, otherwise I got the same result that you did...
- Chip
If anyone looked at the G4 screen saver program I wrote, you might have noticed that I start out creating a list of randomly ordered numbers to determine the sequence that pictures will be shown in, then re-randomize the list when the first sequence of slides has finished.
That was inspired by my dissapointment with more than one computer-based screen saver that didn't run through the whole collection of images before repeating any of them.
- Chip
I'm picturing miniature bingo-ball machines inside the video games!
But yeah, I'd like to see what they wind up doing - out of curiosity...
- Chip
This is genius, what an idea! I'm starting on it ASAP... You need sleep and I need consoling!
You could easilly tie it in to one of the external hard buttons that no one uses for anything else anyway...
- Chip
Ok, now we have really gone off topic! Anyone remember the IR pulsing thread?
There is one simple solution that I have been using for some time. Yes, change the pulse time on every use but get a function to do it. The following is an axi file I use:
#if_not_defined IRTX
#define IRTX
define_function ir(dev ldev,integer lcmd,integer lpulse){
stack_var oldPulse;
if (lpulse>0){
oldPulse=get_pulse_time;
set_pulse_time(lpulse);
}
pulse[ldev,lcmd];
if (lpulse>0){
set_pulse_time(oldPulse);
}
}
#end_if
Ignore the compiler directives if using this in main code. Simlpy include the target device, the channel number and a pulse duration with "0" meaning default. You can define constants for the likes of DVD and VCR, etc. so they can be different as required.
Obvious and simple but it works.
Paul Scott
Well, TimeWarner has changed their lineup again...And I finally had to deal with 4-digit pulses (no XCH for 4-digits yet?!?!?). Well, this solution came in handy and figured I would post some of it here for suggestions/improvements.
Since this is thread is quite old, I figured I would revisit and see if anyone else has other neato implementations... This one works pretty reliably and quickly with the CTON/OF settings.
// added edit: sending individual cmds needs to loop up to 4 not to nLength.
Of course, set the CTON & CTOF times in the DATA_EVENT, and you'll be all set to go.