@ Tony: Thanks Tony, interesting approach. Though I'm not very informed about implementation of such algorithms, how would it actually take place? Seems to be rather resource heavy.
@ Vegaseat: Nice random generator. It's also very concise and would run well without holding down a lot of resources. It's also truly random, I believe, unlike (as I think is the case) the generator I provided.
I was looking at my code again and realized that in certain scenarios the code would not at all produce random numbers. In fact, we could always determine the output of the generator in those situations (in theory). My reasoning is as follows. Since the generator depends on the time the program was started, we could write a program to execute the generator at a given time, and if everything went according to plan we would know beforehand what the number generated would be.
Of course, real world scenarios present the algorithm a different implementation. Even if we asked the program to be executed at a particular time, there is no guarantee the program will be executed at that exact time. Furthermore even if the code was executed at the time scheduled, the time the CPU got to the instruction:
a = t.time() - int(t.time())
would almost entirely depend on local variables. However, since my code depends on only the first 6 digits of decimal time, the above workaround may successfully be implemented as most computers today are fast enough to accomplish such a task. In such a light, this generator may be deemed not at all random owing to a complete lack of the need of "user input". The code I had in mind was the following; this particular implementation waits till the decimal part of time is 0:
import time as t
a = t.time() - int(t.time())
while a != 0 or a == 0:
a = t.time() - int(t.time())
if a == 0:
print "Ha ha, fooled you! ;-)"
break
A simple fix is to ask a user for "input". Taking from Vegaseat a bit we have:
#... the code before the following line has been omitted:
raw_input("Press Enter") # Prevents the aforementioned workaround.
a = t.time() - int(t.time())
# The code then continues as it did before...
Finally, I was thinking about implementing something along the lines of getting the average of the current temperature in a city in Sweden, the stock price of a S&P 500 tech company at 8:35 this morning, the exchange rate of the British Pound and the Japanese Yen yesterday at 4:15 in the morning as a random generator. However, I lack the programming know-how to implement such a program at the moment (hehe) :)