Diamond Dash is a game in facebook. Here is the Link.
it's very easy to play. just click the cube connected with two or more other same color cube.
Then they will disappear and you will get score.
So what I use python to do is grab the screen and decide what cube could click.
#Environment
Windows 7
python 2.7
#library in python
time
PIL
win32 extention
#import library
import win32api, win32con
import time
from PIL import ImageGrab
from PIL import Image
#First, grab the screen
im = ImageGrab.grab()
pix = im.load()
#get rgb at specify pixel
pix[x,y]
#move cursor
win32api.SetCursorPos((x,y))
#click
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
Use these four method above, you can get pixel and decide whether click or not, and get the champion : )
for improve it , you can add DFS.
沒有留言:
張貼留言