dict["pressDpadUp"] = robot.pressDpadUp dict["pressDpadDown"] = robot.pressDpadDown dict["pressDpadLeft"] = robot.pressDpadLeft dict["pressDpadRight"] = robot.pressDpadRight dict["pressDpadCenter"] = robot.pressDpadCenter # dict['flick'] = scr.flick dict["ARGS"] = args dict["DEVICE_SERIAL_NUMBER"] = serialno dict["DEVICE_MODEL"] = device.getProperty("build.model") dict["DEVICE_RESOLUTION"] = (int(device.getProperty("display.width")), int(device.getProperty("display.height"))) dict["DEVICE_PLATFORM_VERSION"] = device.getProperty("build.version.release") dict["DEVICE_API_LEVEL"] = int(device.getProperty("build.version.sdk")) # set bundle path. sys.argv[0] always returns full path of the script. import sys, os.path as path from org.sikuli.script import Settings Settings.BundlePath = path.normpath(path.dirname(sys.argv[0])) _init() from org.sikuli.script import Settings from org.sikuli.script import Pattern from org.sikuli.script import FindFailed from org.sikuli.script.natives import Vision Settings.WaitScanRate = 0.25 Vision.setParameter("MinTargetSize", 24) Settings.DebugLogs = True
dict['pressSearch'] = robot.pressSearch dict['pressBackspace'] = robot.pressBackspace dict['pressEnter'] = robot.pressEnter dict['pressDpadUp'] = robot.pressDpadUp dict['pressDpadDown'] = robot.pressDpadDown dict['pressDpadLeft'] = robot.pressDpadLeft dict['pressDpadRight'] = robot.pressDpadRight dict['pressDpadCenter'] = robot.pressDpadCenter #dict['flick'] = scr.flick dict['ARGS'] = args dict['DEVICE_SERIAL_NUMBER'] = serialno dict['DEVICE_MODEL'] = device.getProperty('build.model') dict['DEVICE_RESOLUTION'] = (int(device.getProperty('display.width')), int(device.getProperty('display.height'))) dict['DEVICE_PLATFORM_VERSION'] = device.getProperty('build.version.release') dict['DEVICE_API_LEVEL'] = int(device.getProperty('build.version.sdk')) # set bundle path. sys.argv[0] always returns full path of the script. import sys, os.path as path from org.sikuli.script import Settings Settings.BundlePath = path.normpath(path.dirname(sys.argv[0])) _init() from org.sikuli.script import Settings from org.sikuli.script import Pattern from org.sikuli.script import FindFailed from org.sikuli.script.natives import Vision Settings.WaitScanRate = 0.25 Vision.setParameter('MinTargetSize', 24) Settings.DebugLogs = True
def accuracy_med(): Vision.setParameter("MinTargetSize", 12) Settings.MinSimilarity = 0.95
def accuracy_low(): Vision.setParameter("MinTargetSize", 7) Settings.MinSimilarity = 0.90
import sys import random from com.slowfrog.hexiom import Main2 from org.sikuli.script.natives import Vision print("MinTargetSize=%d" % Vision.getParameter("MinTargetSize")) Vision.setParameter("MinTargetSize", 12) # Game logic ORIG_X = 200 ORIG_Y = [None, None, 144, 87, 59, 54, 51] HEX_DX = [None, None, 48, 48, 40, 31, 25] HEX_DY = [None, None, 28, 28, 23, 18, 15] def get_hex_pos(size, x, y): x0 = ORIG_X y0 = ORIG_Y[size] hx = x0 + HEX_DX[size] * (x - y) hy = y0 + HEX_DY[size] * (x + y) return (hx, hy) def get_nearest_xy(size, hx, hy): x0 = ORIG_X y0 = ORIG_Y[size] diff_xy = int(round(float(hx - x0) / HEX_DX[size])) sum_xy = int(round(float(hy - y0) / HEX_DY[size])) return ((sum_xy + diff_xy) / 2, (sum_xy - diff_xy) / 2) # Game graphics PLAY = Pattern("play.png").similar(0.85)