Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Programmers minesweeper  (Read 3437 times)
0 Members and 1 Guest are viewing this topic.
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Posted 2005-10-25 17:03:14 »

I've created a timewaster that plays another timewaster... what a waste of time...
this one was just an experiment with the Robot class... it plays Windows Minesweeper. Very quickly.

Here's what i mean...
Click to Play


That's a screenshot of my minesweeper game after running this little program a few times.

what it does is 'reads' the screen, and plays the game by manipulating the mouse. it's not a very clever algorithm, sometimes expert can take over 100 goes to get it right... sometimes less than 30... a lot of luck is involved

a word of warning before you use it... It will take control of your mouse and play until either
1. it has won
2. it has lost a specified number of games. the default is 10 games...
3. it thinks you closed Minesweeper. (or otherwise loses track or visibility of the play field)

it performs real mouse pointer movement and clicks. i take no responsibility if the program causes harm to your pc by clicking on something it shouldn't... it's good at realising when the game is gone... but if your desktop looks like the game, then it might not realise if you close Minesweeper. (it tracks squares by looking at the colour of the pixels)

to run it, first start up Minesweeper. position it toward the top left of the screen (no need for precision), and make sure the whole window is visible. Then select a dificulty and run the appropriate batch file. (be sure to move it off of minesweeper if it appears on top of it).

Also, here are some examples of running it from the command line...
java MinePlayer e 20  (Expert game, 20 attempts)
java MinePlayer b 10  (Beginner game, 10 attempts)
java MinePlayer i 10  (Intermediate game, 10 attempts)
java MinePlayer c 12 15 10  (Custom game, width 12, height 15, 10 attempts)

You can grab the source, class and bat files (to play beginner, intermediate, or advanced games) <a href="http://www.adam.com.au/kellyjones/YABB/MinePlayer.zip">here</a>...
Offline cborders

Junior Devvie





« Reply #1 - Posted 2005-10-25 17:13:32 »

 Cool Pretty Cool!
Offline Spasi
« Reply #2 - Posted 2005-10-25 18:36:27 »

Wow, awesome util! Wink

The algorithm could be greatly improved though, there're a lot of tricks that it doesn't "know" about. It plays like a n00b! Tongue Grin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #3 - Posted 2005-10-26 04:20:47 »

Haha  I did the EXACT SAME THING in C a few years ago.  I actually wanted to make a Java version a while back, but never got around to it.

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #4 - Posted 2005-10-26 06:32:55 »

i agree it is an inefficient algorithm.

could this be used as the base of an AI competition? Plenty of room for improvement and its a simple enough task

basically to see who can write the algorithm that wins the most games and the quickest (say out of 1000)... the operation to re-scan the board, for example takes a fair chunk of time so eg. an optimal algo would minimize its reliance on that operation...

the data is represented as a 2D array of ints...

of course, seconds would be nowhere near accurate enouh to decide, so eg. printing the system time taken to complete would be used.

i could easily clean it up, have it take a runnable object for the algorithm, make getters and setters for the array, and make public the method that scans the whole board and one that just checks a single tile... that sort of thing, so that you can write a swappable algorithm is run by the program (minimizes cheating by changing stuff that shouldn't be changed, and running the official tests would use the same framework)

i do know a couple of tricks...eg. where u have  121 next to a wall of unknowns, the block next to the 2 is always safe...
Offline Spasi
« Reply #5 - Posted 2005-10-26 10:29:28 »

could this be used as the base of an AI competition? Plenty of room for improvement and its a simple enough task

Clean it up and I'm in. Wink
Offline nonnus29

Senior Devvie




Giving Java a second chance after ludumdare fiasco


« Reply #6 - Posted 2005-10-26 11:58:22 »

Some guy proved that this game is turing complete on an infinite grid and an NP complete problem.  Every game is not garunteed to be solvable.

link
Offline Raghar

Junior Devvie




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #7 - Posted 2005-10-26 20:45:16 »

What about caravel drod? It's much better for AI.
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #8 - Posted 2005-10-28 03:07:55 »

no, of course u can't guarantee a win. that's the challenge.

it makes the competition less about speed and more about AI...
finding a clever way to minimize the need to guess, and when you must guess, choosing the least risky option...

there's an applet that supposedly wins 60% of the expert games it plays, but it also generates the games itself...

it would be interesting if the algorithm worked as well on the real thing.

there are also tradeoffs you can make when updating the information, which would for example trade speed for accuracy etc...

i'll tidy up the code, add comments etc. and make a standard way to access the functions then...

and see if i can organise a prize or two...
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (107 views)
2017-09-30 02:57:34

theagentd (134 views)
2017-09-26 18:23:31

cybrmynd (244 views)
2017-08-02 12:28:51

cybrmynd (236 views)
2017-08-02 12:19:43

cybrmynd (237 views)
2017-08-02 12:18:09

Sralse (251 views)
2017-07-25 17:13:48

Archive (863 views)
2017-04-27 17:45:51

buddyBro (1006 views)
2017-04-05 03:38:00

CopyableCougar4 (1564 views)
2017-03-24 15:39:42

theagentd (1372 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!