Zufallsgenerator: es werden nicht alle arrays 1x ausgegeben

  • Mein Problem besteht darin das ich ein Zufallsgenerator habe der auch recht gut funktioniert, Dennoch sendet der nicht alle arrays 1 mal sondern hört dann auf wann er irgendwie lust hat :D

    Quelltext


    Spoiler anzeigen
    [autoit]

    Global $banzahl = "26"
    Global $wert4 = "1"
    Global $wert5 = "1"
    Global $wert6 = "1"
    Global $wert7 = "1"
    Global $wert8 = "1"

    [/autoit] [autoit][/autoit] [autoit]

    $check4 = GUICtrlRead($Checkbox4)
    $check5 = GUICtrlRead($Checkbox5)
    $check6 = GUICtrlRead($Checkbox6)
    $check7 = GUICtrlRead($Checkbox7)
    $check8 = GUICtrlRead($Checkbox8)

    [/autoit] [autoit][/autoit] [autoit]

    Local $array[26]
    $array[0]="A"
    $array[1]="B"
    $array[2]="C"
    $array[3]="D"
    $array[4]="E"
    $array[5]="F"
    $array[6]="G"
    $array[7]="H"
    $array[8]="I"
    $array[9]="J"
    $array[10]="K"
    $array[11]="L"
    $array[12]="M"
    $array[13]="N"
    $array[14]="O"
    $array[15]="P"
    $array[16]="Q"
    $array[17]="R"
    $array[18]="S"
    $array[19]="T"
    $array[20]="U"
    $array[21]="V"
    $array[22]="W"
    $array[23]="X"
    $array[24]="Y"
    $array[25]="Z"

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $check4 = GUICtrlRead($Checkbox4)
    $check5 = GUICtrlRead($Checkbox5)
    $check6 = GUICtrlRead($Checkbox6)
    $check7 = GUICtrlRead($Checkbox7)
    $check8 = GUICtrlRead($Checkbox8)

    [/autoit] [autoit][/autoit] [autoit]

    $nMsg = GUIGetMsg ()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch

    ;positive checkbox
    If $check4 = "1" Then
    If $wert4 = "1" Then
    $banzahl += "1"
    $wert4 -= "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check5 = "1" Then
    If $wert5 = "1" Then
    $banzahl += "1"
    $wert5 -= "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check6 = "1" Then
    If $wert6 = "1" Then
    $banzahl += "1"
    $wert6 -= "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check7 = "1" Then
    If $wert7 = "1" Then
    $banzahl += "1"
    $wert7 -= "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check8 = "1" Then
    If $wert8 = "1" Then
    $banzahl += "1"
    $wert8 -= "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf

    ;negative checkbox
    If $check4 = "4" Then
    If $wert4 = "0" Then
    $banzahl -= "1"
    $wert4 += "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check5 = "4" Then
    If $wert5 = "0" Then
    $banzahl -= "1"
    $wert5 += "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check6 = "4" Then
    If $wert6 = "0" Then
    $banzahl -= "1"
    $wert6 += "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check7 = "4" Then
    If $wert7 = "0" Then
    $banzahl -= "1"
    $wert7 += "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf
    If $check8 = "4" Then
    If $wert8 = "0" Then
    $banzahl -= "1"
    $wert8 += "1"
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    EndIf
    EndIf

    if $nMsg = -3 Then Exit
    If $Start = $nMsg Then
    _AZ($AZ)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;Buchstabengenerator
    Func _AZ($AZ)
    Do
    $nMsg = GUIGetMsg ()
    $y = Ubound($array)-1
    $i = Round(Random (0, $y))
    GUICtrlSetData ($AZ, $array[$i])
    Until $Stopp = $nMsg
    If $i > 0 Then
    _ArrayDelete($array,$i)
    $banzahl -= "1"
    $buchstabe = GUICtrlRead($AZ)
    If $buchstabe = "W" And $check8 = "4" Then
    $wert8 += "5"
    Return
    EndIf
    If $buchstabe = "Q" And $check7 = "4" Then
    $wert7 += "5"
    Return
    EndIf
    If $buchstabe = "Z" And $check6 = "4" Then
    $wert6 += "5"
    Return
    EndIf
    If $buchstabe = "Y" And $check5 = "4" Then
    $wert5 += "5"
    Return
    EndIf
    If $buchstabe = "X" And $check4 = "4" Then
    $wert4 += "5"
    Return
    EndIf
    GUICtrlSetData ($banzahllabel, "Übrige Buchstaben: " & $banzahl)
    GUICtrlSetData ($buchstabelabel, $buchstabe)
    _alle()
    Else
    MsgBox(0,"Ende","alle Buchstaben waren 1x mal dran!",5)
    Exit
    EndIf
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Wenn du wirklich Hilfe bekommen willst, solltest du dein komplettes Script posten.
    So kann das niemand ausführen.

    • Offizieller Beitrag

    Um alle Zahlen eines Bereiches zufällig und nicht doppelt auszugeben, kannst du folgende Funktion nutzen:

    Spoiler anzeigen
    [autoit]

    ;==============================================================================
    ; Gibt eine Anzahl Zufallszahlen ohne Doppel als String oder Array zurück
    ; Bereich von - bis festlegbar (positiv Integer)
    ; mit -1 für Anzahl werden alle Zahlen des Bereichs in zufälliger Reihenfolge
    ; ausgegeben
    ;==============================================================================
    Func _RandomExt($iBis, $iVon=1, $iAnzahl=-1, $array=0)
    Local $count = $iBis -$iVon +1
    If $iAnzahl = -1 Then $iAnzahl = $count
    Local $aValue[$count], $start = $iVon, $sOut = '', $random
    For $i = 0 To $count -1
    $aValue[$i] = $start
    $start += 1
    Next
    For $i = 0 To $iAnzahl -1
    $random = Random(0, $count -1 -$i, 1)
    $sOut &= $aValue[$random] & ','
    $aValue[$random] = $aValue[$count -1 -$i]
    Next
    $sOut = StringTrimRight($sOut, 1)
    If $array Then Return StringSplit($sOut, ',', 2)
    Return $sOut
    EndFunc ;==>_RandomExt

    [/autoit]