def testUsingPhone(): return andlib.Init() while True: print "##################################################################################################" try: filelist = glob.glob("data/PredictionLog/*.png") for f in filelist: os.remove(f) except: pass sc = andlib.GetScreen() sc = ScreenReader.normalizeImage(sc) # io.imsave("data/history/hist_" + friendspop.getTimeStr() + ".png", sc) mat = ScreenReader.createMatrixFromScreen(sc) pprint(mat) friendspop.print_board(mat) solver = friendspop.SimpleSolver() score, [start, end] = solver.solve_board(mat) print score print(start, end) friendspop.DEBUG_EXPLOSIONS = True score, _, endboard = solver.check_direction(start, ((end[0] - start[0]), (end[1] - start[1]))) friendspop.DEBUG_EXPLOSIONS = False x1, y1 = ScreenReader.GetCellMidPoint(sc, start[0], start[1]) x2, y2 = ScreenReader.GetCellMidPoint(sc, end[0], end[1]) print((x1,y1), (x2,y2)) plt.imshow(sc) plt.plot([x1,x2], [y1,y2], 'k-', lw=2) plt.show()
def run(): andlib.Init() while True: print("#" * 70) sc = andlib.GetScreen() sc = ScreenReader.normalizeImage(sc) # io.imsave("data/history/hist_" + friendspop.getTimeStr() + ".png", sc) mat = ScreenReader.createMatrixFromScreen(sc) pprint(mat) friendspop.print_board(mat) solver = friendspop.SimpleSolver() score, [start, end] = solver.solve_board(mat) print(score) print(start, end) score, _, endboard = solver.check_direction(start, ((end[0] - start[0]), (end[1] - start[1]))) x1, y1 = ScreenReader.GetCellMidPoint(sc, start[0], start[1]) x2, y2 = ScreenReader.GetCellMidPoint(sc, end[0], end[1]) print((x1, y1), (x2, y2)) plt.imshow(sc) plt.plot([x1, x2], [y1, y2], 'k-', lw=2) plt.show()
def test2(): sc = ScreenReader.readNormalizedScreen("data/asdf.png") mat = ScreenReader.createMatrixFromScreen(sc) solver = friendspop.SimpleSolver() score, [start, end] = solver.solve_board(mat) print score print(start, end) x1, y1 = ScreenReader.GetCellMidPoint(sc, start[0], start[1]) x2, y2 = ScreenReader.GetCellMidPoint(sc, end[0], end[1]) print((x1,y1), (x2,y2)) return plt.imshow(sc) plt.plot([x1,x2], [y1,y2], 'k-', lw=2) plt.show()
def run(): andlib.Init() while True: print("#" * 70) sc = andlib.GetScreen() sc = ScreenReader.normalizeImage(sc) # io.imsave("data/history/hist_" + friendspop.getTimeStr() + ".png", sc) mat = ScreenReader.createMatrixFromScreen(sc) pprint(mat) friendspop.print_board(mat) solver = friendspop.SimpleSolver() score, [start, end] = solver.solve_board(mat) print(score) print(start, end) score, _, endboard = solver.check_direction(start, ((end[0] - start[0]), (end[1] - start[1]))) x1, y1 = ScreenReader.GetCellMidPoint(sc, start[0], start[1]) x2, y2 = ScreenReader.GetCellMidPoint(sc, end[0], end[1]) print((x1,y1), (x2,y2)) plt.imshow(sc) plt.plot([x1,x2], [y1,y2], 'k-', lw=2) plt.show()