消灭“消灭星星”这个游戏

作者:源码世界时间:2014-03-13分类:程序员碎语评论:0浏览:5992
public static void main(String[] args) {
		Monkey monkey = new Monkey("lib/android-sdk-windows/platform-tools", 5000);
		monkey.iniMonkey();
		for (int i = 0; i < 100; i++) {
			//截图
			IChimpImage image = monkey.getmDevice().takeSnapshot();
			BufferedImage bi = image.createBufferedImage();
			PopStar popStar = new PopStar();
			//识别
			popStar.setStars(PopStarDistinguish.distinguishStars(bi));
			//递归求解:消除前20棵的方案
			PopStarSolver.getMostValueActions(popStar, new ArrayList<StarSet>(), 0);
			//执行消除动作
			monkey.runActions(PopStarSolver.lastActions);
			//重设存储结果
			PopStarSolver.resetResult();
			//baby one more time.
			image = monkey.getmDevice().takeSnapshot();
			bi = image.createBufferedImage();
			popStar = new PopStar();
			popStar.setStars(PopStarDistinguish.distinguishStars(bi));
			//寻找少于80棵后局面的解的较优方案
			PopStarSolver.getMostValueActions1(popStar, new ArrayList<StarSet>(), 0);
			monkey.runActions(PopStarSolver.lastActions);
			PopStarSolver.resetResult();
			try {
				Thread.sleep(20000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
标签:Java  
返回顶部
分享按钮