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)