Jump to content



Photo

Pick 3 number generator


  • Please log in to reply
1 reply to this topic

#1 Mast3rpyr0

Mast3rpyr0

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 419 posts

Posted 07 June 2008 - 10:50 PM

Simple 50 line app to generate 1000 numbers for each of the 3 numbers in the Pick 3. Which ever number, 0-9, is picked the most is set as one of the digits.

AutoIt         
#include <GuiConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "_exit") Global $firstPick, $secondPick, $thirdPick, $arr[10] $gui = GUICreate("Pick 3 Picker", 300, 200) $goBtn = GUICtrlCreateButton("  Generate  ", 100, 25, 100) $first = GUICtrlCreateLabel("1  -  ", 25, 80) $second = GUICtrlCreateLabel("2  -  ", 25, 120) $third = GUICtrlCreateLabel("3  -  ", 25, 160) GUISetState(@SW_SHOW, $gui) While 1     $gMsg = GUIGetMsg()     Switch $gMsg     Case $GUI_EVENT_CLOSE         _exit()     Case $goBtn         $firstPick = genDigits()         $secondPick = genDigits()         $thirdPick = genDigits()         _updateCtrls()     EndSwitch WEnd Func genDigits()     For $x = 1 To 1000 Step 1         $temp = Random(0, 9, 1)         $arr[$temp] = $arr[$temp] + 1     Next         $y = _ArrayMaxIndex($arr)     Global $arr[10]     Return $y     EndFunc Func _updateCtrls()     GUICtrlSetData($first, "1  -  " & $firstPick)     GUICtrlSetData($second, "2  -  " & $secondPick)     GUICtrlSetData($third, "3  -  " & $thirdPick) EndFunc Func _exit()     exit EndFunc






#2 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 07 June 2008 - 11:17 PM

Simple 50 line app to generate 1000 numbers for each of the 3 numbers in the Pick 3. Which ever number, 0-9, is picked the most is set as one of the digits.

AutoIt         
#include <GuiConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "_exit") Global $firstPick, $secondPick, $thirdPick, $arr[10] $gui = GUICreate("Pick 3 Picker", 300, 200) $goBtn = GUICtrlCreateButton("  Generate  ", 100, 25, 100) $first = GUICtrlCreateLabel("1  -  ", 25, 80) $second = GUICtrlCreateLabel("2  -  ", 25, 120) $third = GUICtrlCreateLabel("3  -  ", 25, 160) GUISetState(@SW_SHOW, $gui) While 1     $gMsg = GUIGetMsg()     Switch $gMsg     Case $GUI_EVENT_CLOSE         _exit()     Case $goBtn         $firstPick = genDigits()         $secondPick = genDigits()         $thirdPick = genDigits()         _updateCtrls()     EndSwitch WEnd Func genDigits()     For $x = 1 To 1000 Step 1         $temp = Random(0, 9, 1)         $arr[$temp] = $arr[$temp] + 1     Next         $y = _ArrayMaxIndex($arr)     Global $arr[10]     Return $y     EndFunc Func _updateCtrls()     GUICtrlSetData($first, "1  -  " & $firstPick)     GUICtrlSetData($second, "2  -  " & $secondPick)     GUICtrlSetData($third, "3  -  " & $thirdPick) EndFunc Func _exit()     exit EndFunc

Not a clue what it's for :)
What is the purpose of the function genDigits? It will be biased towards lower numbers and so will not be so random as Random(0, 9, 1). For example, if the scores for digits selected after 1000 selections are equal for one or more digit then _ArrayMaxIndex($arr) will return the first one it finds.
Looks to me like Random(0, 9, 1) would be better than genDigits().
Plain Text         
#include <GuiConstants.au3> HotKeySet("{ESC}", "_exit") Global $firstPick, $secondPick, $thirdPick, $arr[10] $gui = GUICreate("Pick 3 Picker", 300, 200) $goBtn = GUICtrlCreateButton("  Generate  ", 100, 25, 100) $first = GUICtrlCreateLabel("1  -  ", 25, 80) $second = GUICtrlCreateLabel("2  -  ", 25, 120) $third = GUICtrlCreateLabel("3  -  ", 25, 160) GUISetState(@SW_SHOW, $gui) While 1     $gMsg = GUIGetMsg()     Switch $gMsg     Case $GUI_EVENT_CLOSE         _exit()     Case $goBtn         _updateCtrls()     EndSwitch WEnd Func _updateCtrls()     GUICtrlSetData($first, "1  -  " & Random(0,9,1))     GUICtrlSetData($second, "2  -  " & Random(0,9,1))     GUICtrlSetData($third, "3  -  " & Random(0,9,1)) EndFunc Func _exit()     exit EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users