Kann mir wer erklären wie das funtzt?

  • Hi

    Bin vorhin auf das gestoßen

    [autoit]

    #CS
    Computer Cheats at Minesweeper # 2
    Works on any size grid (within reason)
    Computer plays minesweeper extremely fast - 1 second on expert

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

    Inspired by "Freekills Minesweeper Cheats"


    #CE

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

    #include <Array.au3>

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

    Opt("MouseClickDelay",0)
    Opt("MouseClickDownDelay",0)
    Opt("WinTitleMatchMode", 3)

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

    ; Exit via Ctrl-Alt-X
    HotKeySet("^!x", "MyExit")

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

    dim $title = "Computer Cheats at Minesweeper"
    dim $win = "MineSweeper"

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

    dim $Width, $Height, $wX, $wY, $X, $Y, $X1, $Y1, $X2, $Y2
    dim $i, $j, $color, $color1, $Cols, $Rows

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

    If WinExists($win) = 0 then
    Run(@SystemDir & "\winmine.exe")
    Sleep(500)
    endIf

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

    WinActivate($win)
    Sleep(50)

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

    ; Get Minesweeper info
    $size = WinGetPos($win)
    $wX = $size[0]
    $wY = $size[1]
    $Width = $size[2]
    $Height = $size[3]

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

    ; Start coords of mine grid -relative to window
    $X1 = 16
    $Y1 = 97

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

    ; End coords of mine grid -relative to window
    $X2 = $Width - 11
    $Y2 = $Height - 11

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

    ; size of each box;W=16;H=16
    ; Determine Grid size from window size
    $Cols = int(($X2 - $X1 + 1) / 16)
    $Rows = int(($Y2 - $Y1 + 1) / 16)

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

    if MsgBox(4, $title, "Ready?" & @CR & @CR & "Cols: " & $Cols & @CR & "Rows: " & $Rows & @CR ) <> 6 then exit

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

    Opt("MouseCoordMode", 0)
    Opt("PixelCoordMode", 1)

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

    WinActivate($win)
    ;MouseMove($Width / 2, 69)
    MouseClick("left", $Width / 2, 69, 1, 0); click new game

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

    ; Send happy fun code
    Send("xyzzy{RSHIFT}{ENTER}")

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

    ; Pre calculate X Y cordinates and save to an array (for random looping later on)
    dim $aXY[$Rows * $Cols][2]
    dim $k = 0
    For $i = 0 to $Rows - 1
    $Y = int($Y1 + (($Y2 - $Y1) / $Rows * ($i + 1)) - 8)
    For $j = 0 to $Cols - 1
    $X = int($X1 + (($X2 - $X1) / $Cols * ($j + 1)) - 8)
    $aXY[$k][0] = $X
    $aXY[$k][1] = $Y
    $k += 1
    Next
    Next

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

    sleep(300)

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

    ; Must be 1, this version will not work without pre-search
    $PreSearch = 1

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

    ; Find Mines & remove from array - does not count against time
    if $PreSearch Then
    For $i = 0 to ($Rows * $Cols) - 1
    $X = $aXY[$i][0]
    $Y = $aXY[$i][1]

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

    Opt("PixelCoordMode", 1)
    MouseMove($X, $Y, 0)
    $color = PixelGetColor(0, 0)
    If $color = 16777215 Then
    continueloop
    ElseIf $color = 0 Then
    MouseClick("right")
    $aXY[$i][0] = -1
    $aXY[$i][1] = -1
    EndIf
    Next
    Endif

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

    ; Random is not just cool looking it helps! just barely faster..
    ArrayRandomize2($aXY)

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

    Opt("PixelCoordMode", 0)
    For $i = 0 to ($Rows * $Cols) - 1
    $X = $aXY[$i][0]
    if $X == -1 then ContinueLoop
    $Y = $aXY[$i][1]

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

    $color1 = PixelGetColor($X - 7, $Y)
    ; Unclicked/Unknown color
    If $color1 = 16777215 then
    MouseMove($X, $Y, 0)
    MouseClick("left")
    MouseClick("middle")
    EndIf
    Next

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

    ; Send happy fun code again to reset the 'mode'
    Send("xyzzy{RSHIFT}{ENTER}")

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

    Exit
    ; Exit via Ctrl-Alt-X
    Func MyExit()
    Exit
    EndFunc

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

    ; UN-sorts a 2 dimensional array - 2 passes
    Func ArrayRandomize2 ( ByRef $a)
    local $Idx1, $Idx2
    local $Ubound = UBound($a, 1), $i, $tmp
    For $i = 0 to $Ubound * 2
    $Idx1 = Random(0, $Ubound - 1)
    $Idx2 = Random(0, $Ubound - 1)
    $tmp = $a[$Idx1][0]
    $a[$Idx1][0] = $a[$Idx2][0]
    $a[$Idx2][0] = $tmp
    $tmp = $a[$Idx1][1]
    $a[$Idx1][1] = $a[$Idx2][1]
    $a[$Idx2][1] = $tmp
    Next
    EndFunc

    [/autoit]


    aber WIE ZUM TEUFEL macht er das?

    Ich verstehe den Code - aber wie das zusammenhängt?
    Is daseine mathematische berechnung oder wie oder oO


    Hälp?^^

  • für den menschen aber nicht sichtbar , oder? oO


    bzw warum funtzt dass dann nicht :(


    While 1

    Opt("PixelCoordMode", 1)

    $color = PixelGetColor(0, 0)

    If $color = 16777215 Then


    TrayTip(0, "7777777777", 5)

    sleep(1000)

    Elseif $color = 0 Then


    TrayTip("", "0", 5)

    sleep(5000)

    Endif


    WEnd

    Einmal editiert, zuletzt von huggy (26. März 2007 um 16:14)