Just on a whim, I decided to make a random number generator for the lottery. In the code below, it correctly generates six non repeating numbers to represent the 6 numbers that are drawn and it loops as many times as I need (in this program--5000) to get hundreds of random lottery drawings and pastes them to the Random_1.txt file. It then takes these figures, counts how many times each number is used, and prints them to the Random_2.txt file. Finally, it reorganizes the figures in the Random_2.txt file and places the most often used numbers in accending order in the Random_3.txt file. Here in lies the problem. After many tests of this, it seems to pick all sixty numbers almost evenly every time. Here's an example of 5000 randomly picked number results:
(the # to the left of the = sign is how many times the # to the right of the = sign came up in Random_1.txt)
537 = 13
534 = 17
531 = 26
523 = 12
521 = 52
520 = 4
519 = 55
519 = 21
519 = 36
519 = 39
518 = 19
515 = 11
514 = 3
514 = 54
513 = 50
513 = 6
512 = 43
511 = 28
509 = 49
509 = 23
509 = 1
508 = 51
507 = 2
505 = 46
505 = 45
504 = 9
503 = 60
503 = 40
501 = 30
501 = 25
501 = 18
500 = 47
500 = 48
499 = 42
499 = 31
499 = 15
498 = 38
497 = 16
496 = 22
496 = 14
495 = 20
494 = 10
494 = 59
490 = 24
489 = 37
488 = 5
488 = 32
487 = 7
486 = 8
483 = 33
483 = 44
482 = 35
481 = 58
480 = 53
476 = 34
475 = 41
471 = 57
457 = 56
456 = 29
444 = 27
It seems to do this every time. It just doesn't seem to be pulling true random numbers. What I would like to know is why this is happening in such a seemingly unrandomly and orderly fashion. Thanks for any input on why this might be happening...
Code:
#SingleInstance Force
SetBatchLines, -1
Loop, 60
{
Number_%A_Index% = 0
}
Loop, 5000
{
Num_1 =
Num_2 =
Num_3 =
Num_4 =
Num_5 =
Num_6 =
Num_1:
Random, Num_1, 1, 60
Num_2:
Random, Num_2, 1, 60
If Num_1 = %Num_2%
Goto, Num_2
Num_3:
Random, Num_3, 1, 60
If Num_1 = %Num_3%
Goto, Num_3
If Num_2 = %Num_3%
Goto, Num_3
Num_4:
Random, Num_4, 1, 60
If Num_1 = %Num_4%
Goto, Num_4
If Num_2 = %Num_4%
Goto, Num_4
If Num_3 = %Num_4%
Goto, Num_4
Num_5:
Random, Num_5, 1, 60
If Num_1 = %Num_5%
Goto, Num_5
If Num_2 = %Num_5%
Goto, Num_5
If Num_3 = %Num_5%
Goto, Num_5
If Num_4 = %Num_5%
Goto, Num_5
Num_6:
Random, Num_6, 1, 60
If Num_1 = %Num_6%
Goto, Num_6
If Num_2 = %Num_6%
Goto, Num_6
If Num_3 = %Num_6%
Goto, Num_6
If Num_4 = %Num_6%
Goto, Num_6
If Num_5 = %Num_6%
Goto, Num_6
FileAppend, `n %Num_1%-%Num_2%-%Num_3%-%Num_4%-%Num_5%-%Num_6%, %A_WorkingDir%\Random_1.txt
}
Loop, Read, %A_WorkingDir%\Random_1.txt,
{
Loop, Parse, A_LoopReadLine, -
{
If A_LoopField = 1
Number_1 += 1
If A_LoopField = 2
Number_2 += 1
; ... etc.
If A_LoopField = 60
Number_60 += 1
}
}
FileAppend, %Number_1% = 1 `n, %A_WorkingDir%\Random_2.txt
FileAppend, %Number_2% = 2 `n, %A_WorkingDir%\Random_2.txt
; ... etc.
FileAppend, %Number_60% = 60 `n, %A_WorkingDir%\Random_2.txt
FileRead, Sort_List, %A_WorkingDir%\Random_2.txt
Clipboard =
Clipboard = %Sort_List%
Sort, Clipboard, N R
FileAppend, %Clipboard%, %A_WorkingDir%\Random_3.txt