alfa 0 Posted May 17, 2011 hello , i want to roll 4 random numbers , this part is easy But i want to check and reroll if there are any same numbers. Thanks in advance Share this post Link to post Share on other sites
dufran3 0 Posted May 17, 2011 Assign the random number a variable, split the number, then run checks against the new re-roll. Post some example code that you have already started working on. Share this post Link to post Share on other sites
wakillon 403 Posted May 17, 2011 (edited) hello , i want to roll 4 random numbers , this part is easy But i want to check and reroll if there are any same numbers. Thanks in advance Something like this ? #include <Array.au3> Global $_Array[1] While 1 $_Var = Random ( 1, 20, 1 ) If Not _AlreadyInArray ( $_Array, $_Var ) Then _ArrayAdd ( $_Array, $_Var ) If UBound ( $_Array ) -1 = 4 Then ExitLoop WEnd _ArrayDisplay ( $_Array ) Func _AlreadyInArray ( $_SearchArray, $_Item ) $_Index = _ArraySearch ( $_SearchArray, $_Item ) If @error Then Return False Else If $_Index <> 0 Then Return True Else Return False EndIf EndIf EndFunc ;==> _AlreadyInArray ( ) Edited May 17, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
Yashied 242 Posted May 17, 2011 (edited) Why _ArraySearch()? #Include <Array.au3> Dim $Val[4] For $i = 0 To UBound($Val) - 1 While 1 $Val[$i] = Random(0, 100, 1) For $j = 0 To $i - 1 If $Val[$i] = $Val[$j] Then ContinueLoop 2 EndIf Next ContinueLoop 2 WEnd Next _ArrayDisplay($Val) Edited May 17, 2011 by Yashied My UDFs:iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL HelperAnimated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF LibraryAppropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignmentMore... Share this post Link to post Share on other sites
wakillon 403 Posted May 17, 2011 Why _ArraySearch()?For searching like your loop ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
alfa 0 Posted May 17, 2011 wow you guys make it look real easy :S one last thing how can i make these numbers sort ? Share this post Link to post Share on other sites
Yashied 242 Posted May 17, 2011 _ArraySort()? My UDFs:iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL HelperAnimated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF LibraryAppropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignmentMore... Share this post Link to post Share on other sites
wakillon 403 Posted May 17, 2011 Use _ArraySort function ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites