Jump to content

Pick 3 number generator


Mast3rpyr0
 Share

Recommended Posts

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.

#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
Link to comment
Share on other sites

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.

#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().

#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.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...