Jump to content

Minesweeper bot: Advanced level in 1 second

Recommended Posts

What do you think? Do you like it? :P

It solves minesweeper in only 1 second, and it's only 15 lines long!

```WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)

Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To \$m
MouseMove(251, 299 + \$i * 16, \$speed)
For \$k = 0 To \$n
MouseMove(251 + \$k * 16, 299 + \$i * 16, \$speed)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
Else
MouseClick("right")
EndIf
Next
NextoÝ÷ ÚÈ³zì¥©ì·)^```
Edited by Kiti
• Replies 46
• Created
• Last Reply

Top Posters In This Topic

What do you think? Do you like it? :P

It solves minesweeper in only 2 seconds, and it's only 15 lines long!

```Run(@SystemDir & "\winmine.exe")
WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To 8
MouseMove(251, 299 + \$i * 16, 0)
For \$k = 0 To 8
MouseMove(251 + \$k * 16, 299 + \$i * 16, 0)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
Next
Next```
doesnt work on Vista.
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Share on other sites

doesnt work on Vista.

I didn't ever had vista, but I'm sure that's because it's called in a diffrent way. Do this:

1. Open Minesweeper.

2.Run this:

```WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To 7
MouseMove(251, 299 + \$i * 16, 0)
For \$k = 0 To 7
MouseMove(251 + \$k * 16, 299 + \$i * 16, 0)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
Next
Next```

3.Maximize Minesweeper.

Easy guide in three steps )

Share on other sites

I didn't ever had vista, but I'm sure that's because it's called in a diffrent way. Do this:

1. Open Minesweeper.

2.Run this:

```WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To 7
MouseMove(251, 299 + \$i * 16, 0)
For \$k = 0 To 7
MouseMove(251 + \$k * 16, 299 + \$i * 16, 0)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
Next
Next```

3.Maximize Minesweeper.

Easy guide in three steps )

nope, also, you cant maximize it on vista
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Share on other sites

nope, also, you cant maximize it on vista

not maximze, just unminimze... you have 400 posts... is it that hard to get it? or you just want to laugh at me? Edited by Kiti
Share on other sites

not maximze, just unminimze... you have 400 posts... is it that hard to get it? or you just want to laugh at me?

no, I know what you mean, but the entire layout is different,

anyone try this on XP?

the oddly colored one is the one my mouse is over...

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Share on other sites

Could you explain how this works?

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Share on other sites

Actually "xyzzy" is a cheat code for Minesweeper. It will activate a pixel on the left (or right ... not sure) upper part of the screen. When the mouse cursor is over a square with a bomb the pixel will change color to a bright one, when the cursor is over a free square (no bomb) the pixel will stay dark.

I haven't used this for a long time - I know it was possible in Win 3.1 and Win 95 but I had no idea it still worked (that's why I'm not sure about details).

Basically what Kiti does is move the cursor over the table and checks the pixel color - if the pixel says "no bomb" it will left-click and move to next one.

Nice one Kiti ... but not a real AI here

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share on other sites
• Moderators

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share on other sites

Pretty cool though it didn't work for me. The mouse clicked on a mine.

Edit: nvm It works

The comments are more interesting then the bs that guy puts out.

Edited by Deltaforce229

[size="1"]Please stop confusing "how to" with "how do"[/size]

Share on other sites
• Moderators

What do you think? Do you like it? :P

It solves minesweeper in only 2 seconds, and it's only 15 lines long!

```Run(@SystemDir & "\winmine.exe")
WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To 8
MouseMove(251, 299 + \$i * 16, 0)
For \$k = 0 To 8
MouseMove(251 + \$k * 16, 299 + \$i * 16, 0)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
Next
NextoÝ÷ ØGbµ.q©Ü©àyº-Ø^Ó~¢jwtß©-¢«¨µ:5æ«¨µú+¶¢×«çbj×¥z÷¥æÇ¢wlbjw!jxÓ~¢¶®¢Ôè×®¢Ö§wMúÚ*ºS£ojº_¢»ay§ojwvW¯z_,yÊ'vÏêº^b¢é]±ëmí7ë§wMúÉ·¥£"¶(ëaxºËhX¤zë"¢g­>-¢­¶¬7¨~Ø^Â)Ý£§vØ^Ø^Ó~²NyÂ¥vZ(X¤{MúÉ:4ß©Ø^®Ú+²¶§(ºWgßÛ`zÜ¨º»-£
+)â¶&¥&î¶Þ¶§ý½çèºwh½êíg¢²'ò¢ë¬yÉbz{¢Ý²¶­êí©ìr·Ê(­Û0éé¬¢"¶¬¥ç"~'0whÂØb ¢kÉ¨¢Ø^­«­¢+ØíÍ¹¥ÁÁ¸¸¸Í½Ñ¡ÈáµÁ±```
Edited by SmOke_N
revision

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share on other sites

It's very cool, SmOke_N. But 1/2 times I run it, it marks all cells as bombs. I thought of a way of highly increasing the speed, and maybe I'll achieve better timings. I'm working on it and I'll post something in like 2 or 3 hours.

Share on other sites

This is my second script. I thought it would be much faster, because it moves in a spiral shape, tangent to the interior edges of the cells, so the mouse is moved for an extremely less distance than the first script. Although, it makes 2 secods as well . You can run it in notepad while pressing the mouse, and empty the check function, to see what a beautiful and perfect spiral it does. Any ideea why it's not faster?

```Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
Run(@SystemDir & "\winmine.exe")
WinWaitActive("Minesweeper")
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")

Global \$sp = 0 ; speed

For \$a = 0 To 7
MouseMove(259 + \$a * 16, 306, \$sp)
_check()
Next
For \$b = 0 To 7
MouseMove(372, 306 + \$b * 16, \$sp)
_check()
Next
For \$c = 0 To 7
MouseMove(372 - \$c * 16, 419, \$sp)
_check()
Next
For \$d = 0 To 6
MouseMove(259, 419 - \$d * 16, \$sp)
_check()
Next
For \$e = 0 To 6
MouseMove(259 + \$e * 16, 322, \$sp)
_check()
Next
For \$f = 0 To 5
MouseMove(356, 322 + \$f * 16, \$sp)
_check()
Next
For \$g = 0 To 5
MouseMove(356 - \$g * 16, 403, \$sp)
_check()
Next
For \$h = 0 To 4
MouseMove(275, 403 - \$h * 16, \$sp)
_check()
Next
For \$i = 0 To 4
MouseMove(275 + \$i * 16, 338, \$sp)
_check()
Next
For \$j = 0 To 3
MouseMove(340, 338 + \$j * 16, \$sp)
_check()
Next
For \$k = 0 To 3
MouseMove(340 - \$k * 16, 387, \$sp)
_check()
Next
For \$l = 0 To 2
MouseMove(291, 387 - \$l * 16, \$sp)
_check()
Next
For \$m = 0 To 2
MouseMove(291 + \$m * 16, 354, \$sp)
_check()
Next
For \$n = 0 To 1
MouseMove(324, 354 + \$n * 16, \$sp)
_check()
Next
For \$o = 0 To 1
MouseMove(324 - \$o * 16, 371, \$sp)
_check()
Next
MouseMove(307, 371, \$sp)
_check()
MouseMove(307, 370, \$sp)
_check()
MouseMove(308, 370, \$sp)
_check()

Func _check()
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
EndFunc   ;==>_check```

Edit: When you press a cell, much more empty blocks are turning gray. Now I'm working at a version that avoids them. This has to be fast...

Edit2: Lol Why no one told me that if I add mousedelay 0 the script will finish in 1 second ?

I thought this is possible only by a spiral shape, or by getting the client choords. So I lost a full day by measuring that spiral. I've edited both scripts and they finish in a second

Edited by Kiti
Share on other sites

try under windows xp, but doesn't work...

anyone can help me ?

Share on other sites
• Moderators

It's very cool, SmOke_N. But 1/2 times I run it, it marks all cells as bombs. I thought of a way of highly increasing the speed, and maybe I'll achieve better timings. I'm working on it and I'll post something in like 2 or 3 hours.

Put this after the "Next"

```ControlSend("[CLASS:Minesweeper]", "", "", "xyzzy+{ENTER}")oÝ÷ ØGbµ8b³¬z÷§}«-z´Z­}µßV®¶­sd÷BgV÷C´Ö÷W6T6ö÷&DÖöFRgV÷C²Â"¤÷BgV÷C´Ö÷W6T6Æ6´FVÆgV÷C²Â¤÷BgV÷C´Ö÷W6T6Æ6´F÷väFVÆgV÷C²Â¤÷BgV÷CµVÄ6ö÷&DÖöFRgV÷C²Â"¤Æö6Âb33c¶FW6·F÷ÒvävWDæFÆRgV÷Cµ´4Ä53¥v÷&¶W%uÒgV÷C²¤Æö6Âb33c¶ÖæU7vVWÒvävWDæFÆRgV÷Cµ´4Ä53¤ÖæW7vVWW%ÒgV÷C²¥våvD7FfRb33c¶ÖæU7vVW¤Æö6Âb33c¶u÷2ÒvävWE÷2b33c¶ÖæU7vVW ¤b4'&b33c¶u÷2ÒFVâW@¤Æö6Âb33c·GRÒRÂb33c·GRÂb33c·Âb33c·Âb33c·2Âb33c·2Âb33c¶÷@ ¤bb33c¶u÷5³%ÒfwC²SFVà¢b33c·GRÒ#¤VÇ6Tbb33c¶u÷5³%ÒfwC²#FVà¢b33c·GRÒP¤VÇ6P¢b33c·GRÒ¢b33c·GRÒ¤VæD` ¤6öçG&öÅ6VæBgV÷Cµ´4Ä53¤ÖæW7vVWW%ÒgV÷C²ÂgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C·§§·´TåDU'ÒgV÷C²¤f÷"b33c·ÒFòb33c·GP f÷"b33c·ÒFòb33c·GP b33c·2ÒB²b33c·¢b b33c·2ÒSr²b33c·¢b Ö÷W6TÖ÷fRb33c·2Âb33c·2Â bVÄvWD6öÆ÷"b33c·2ÓÂb33c·2Âb33c¶ÖæU7vVWÓÒdddddbFVà bVÄvWD6öÆ÷"ÂÂb33c¶FW6·F÷ÓÒdddddbFVà Ö÷W6T6Æ6²gV÷C·&Ö'gV÷C²Âb33c·2Âb33c·2ÂÂ VÇ6P Ö÷W6T6Æ6²gV÷C·6V6öæF'gV÷C²Âb33c·2Âb33c·2ÂÂ VæD` VæD` æW@¤æW@¤6öçG&öÅ6VæBgV÷Cµ´4Ä53¤ÖæW7vVWW%ÒgV÷C²ÂgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C·§§·´TåDU'ÒgV÷C²oÝ÷ ØGb·c«jëh×6Opt("MouseCoordMode", 2)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
Opt("PixelCoordMode", 2)
Local \$hDesktop = WinGetHandle("[CLASS:WorkerW]")
Local \$hMineSweep = WinGetHandle("[CLASS:Minesweeper]")
WinWaitActive(\$hMineSweep)
Local \$aWPos = WinGetPos(\$hMineSweep)

If IsArray(\$aWPos) = 0 Then Exit
Local \$ytype = 15, \$xtype, \$y, \$x, \$xc, \$yc, \$opt

If \$aWPos[2] > 500 Then
\$xtype = 29
ElseIf \$aWPos[2] > 200 Then
\$xtype = 15
Else
\$ytype = 8
\$xtype = 8
EndIf

ControlSend("[CLASS:Minesweeper]", "", "", "xyzzy+{ENTER}")
For \$y = 0 To \$ytype
For \$x = 0 To \$xtype
\$xc = 14 + (\$x * 16)
\$yc = 57 + (\$y * 16)
PixelSearch(\$xc - 1, \$yc, \$xc - 1, \$yc, 0xFFFFFF, 0, 14, \$hMineSweep)
If Not @error Then
MouseMove(\$xc, \$yc, 0)
If (PixelGetColor(0, 0, \$hDesktop) == 0xFFFFFF) Then
MouseClick("primary", \$xc, \$yc, 1, 0)
Else
MouseClick("secondary", \$xc, \$yc, 1, 0)
EndIf
EndIf
Next
Next
ControlSend("[CLASS:Minesweeper]", "", "", "xyzzy+{ENTER}")```

I suppose there are a ton of things you could do... I'm done though lol.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share on other sites

Whats the

Send("xyzzy{LSHIFT}{ENTER}")

Its some kind of code?

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share on other sites

try under windows xp, but doesn't work...

anyone can help me ?

Run this:

```Run(@SystemDir & "\winmine.exe")
WinWaitActive("Minesweeper")
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
WinGetHandle("Minesweeper")
WinMove("Minesweeper", "", 229, 187)
Send("xyzzy{LSHIFT}{ENTER}")
For \$i = 0 To 8
MouseMove(251, 299 + \$i * 16, 0)
For \$k = 0 To 8
MouseMove(251 + \$k * 16, 299 + \$i * 16, 0)
\$x = PixelGetColor(0, 0)
If \$x = 16777215 Then
MouseClick("left")
EndIf
Next
Next```

Are you sure you have minesweeper installed? I also had a SP2 windows which hadn't had any game, calculator or paint.

If you have it, why it's not working? Minesweeper does not start? It starts but nothing happens? It clicks on mines? It doesn't click in the area of the screen where the minesweeper is?

Share on other sites

Edit2: Lol Why no one told me that if I add mousedelay 0 the script will finish in 1 second ?

I thought this is possible only by a spiral shape, or by getting the client choords. So I lost a full day by measuring that spiral. I've edited both scripts and they finish in a second

"Intellectuals solve problems, geniuses prevent them." - Doesn't count for you then
Share on other sites
This topic is now closed to further replies.
• Recently Browsing   0 members

No registered users viewing this page.

×

• Wiki
• AutoIt Resources

• FAQ
×
• Create New...