コード例 #1
0
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()
コード例 #2
0
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()
コード例 #3
0
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()
コード例 #4
0
ファイル: run.py プロジェクト: juyoungkorea/autofpop
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()
コード例 #5
0
 def test_predict(self):
     image = Image(filename=ImageReader('BLACK_BASE').filenames()[0]).image
     ScreenReader.predict(image)
     ScreenReader.predict(image)
     ScreenReader.predict(image)
コード例 #6
0
 def test_value_of(self):
     self.assertEqual(0, ScreenReader.value_of('BLACK_BASE'))
     self.assertEqual(-1, ScreenReader.value_of('NA_BASE'))
     self.assertEqual(4, ScreenReader.value_of('PINK_BASE'))
コード例 #7
0
	def test_value_of(self):
		self.assertEqual(0, ScreenReader.value_of('BLACK_BASE'))
		self.assertEqual(-1, ScreenReader.value_of('NA_BASE'))
		self.assertEqual(4, ScreenReader.value_of('PINK_BASE'))
コード例 #8
0
	def test_predict(self):
		image = Image(filename=ImageReader('BLACK_BASE').filenames()[0]).image
		ScreenReader.predict(image)
		ScreenReader.predict(image)
		ScreenReader.predict(image)