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
Inspired by "Freekills Minesweeper Cheats"
#CE
#include <Array.au3>
[/autoit][autoit][/autoit][autoit]Opt("MouseClickDelay",0)
Opt("MouseClickDownDelay",0)
Opt("WinTitleMatchMode", 3)
; Exit via Ctrl-Alt-X
HotKeySet("^!x", "MyExit")
dim $title = "Computer Cheats at Minesweeper"
dim $win = "MineSweeper"
dim $Width, $Height, $wX, $wY, $X, $Y, $X1, $Y1, $X2, $Y2
dim $i, $j, $color, $color1, $Cols, $Rows
If WinExists($win) = 0 then
Run(@SystemDir & "\winmine.exe")
Sleep(500)
endIf
WinActivate($win)
Sleep(50)
; Get Minesweeper info
$size = WinGetPos($win)
$wX = $size[0]
$wY = $size[1]
$Width = $size[2]
$Height = $size[3]
; Start coords of mine grid -relative to window
$X1 = 16
$Y1 = 97
; End coords of mine grid -relative to window
$X2 = $Width - 11
$Y2 = $Height - 11
; 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)
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)
WinActivate($win)
;MouseMove($Width / 2, 69)
MouseClick("left", $Width / 2, 69, 1, 0); click new game
; Send happy fun code
Send("xyzzy{RSHIFT}{ENTER}")
; 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)) -
For $j = 0 to $Cols - 1
$X = int($X1 + (($X2 - $X1) / $Cols * ($j + 1)) -
$aXY[$k][0] = $X
$aXY[$k][1] = $Y
$k += 1
Next
Next
sleep(300)
[/autoit][autoit][/autoit][autoit]; Must be 1, this version will not work without pre-search
$PreSearch = 1
; 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]
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
; Random is not just cool looking it helps! just barely faster..
ArrayRandomize2($aXY)
Opt("PixelCoordMode", 0)
For $i = 0 to ($Rows * $Cols) - 1
$X = $aXY[$i][0]
if $X == -1 then ContinueLoop
$Y = $aXY[$i][1]
$color1 = PixelGetColor($X - 7, $Y)
; Unclicked/Unknown color
If $color1 = 16777215 then
MouseMove($X, $Y, 0)
MouseClick("left")
MouseClick("middle")
EndIf
Next
; Send happy fun code again to reset the 'mode'
Send("xyzzy{RSHIFT}{ENTER}")
Exit
; Exit via Ctrl-Alt-X
Func MyExit()
Exit
EndFunc
; 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
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?^^