New question #268861 on Sikuli:
https://answers.launchpad.net/sikuli/+question/268861

I wrote a Minesweeper class which I'm using to import into the Sikuli IDE to 
solve a Minesweeper app I have on my Mac. Currently the program is working, but 
the method which searches through the game for different squares is very 
wasteful.

I have an array which holds a value for each individual square based on what it 
is. (1 for "One", 2 for "Two" ect.) Each time the search method runs, after a 
series of clicks have been made, it zeros the array and searches the entire 
game region to "refill" the array again. 

Example:

def parse_game(self):

     #Search for '1' Squares
     if self.game_reg.exists(Pattern(self.num_sq_list[0]).similar(.8)):  
#num_sq_list holds the images of different squares.
            current_ones = 
self.game_reg.findAll(Pattern(self.num_sq_list[0]).similar(.8))
            for one in current_ones:
                #sq_location() takes the targets location in pixels and returns 
an X, Y array loc
                grid_location = self.sq_location(one.getTarget()) 
                self.update_array(grid_location[0], grid_location[1], 1)

   #Search for '2' Squares
  if self.game_reg.exists(Pattern(self.num_sq_list[1]).similar(.8)):  
            current_twos = 
self.game_reg.findAll(Pattern(self.num_sq_list[1]).similar(.8))
            for two in current_twos:
                grid_location = self.sq_location(two.getTarget())
                self.update_array(grid_location[0], grid_location[1], 2)

# This same series of code runs for each different possible square image. 

We do know that once an 'unknown' square is revealed it never changes. I have 
tried to loop through the 'sq_array' and find the unknown square locations one 
at a time, then capture() the square region and find if it matches one of the 
squares in the 'num_sq_list,' but this does not seem to make the program 
faster. 

Any suggestions for optimizing the search method? 

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to