程序员玩游戏之三--天天爱消除非暴力脚本

   评论:        此款游戏成功在其好友排名上。好友的分数超过了你无疑会增加你的斗志。

      中级策略:七手八脚多人一起点。这相当于多个CPU处理一个大任务了,哈哈。

      终极策略:自动化。机器总是比人快的多。你两个人一秒充其量点4下,而机器的数量级至少是10以上吧。

 

      本人编写的是LUA脚本(CSDN语言中没有LUA这门,所以才用的python格式上传的),只适用于iphone4及4s, iphone5分辨率不同于4也可能用不了,对此没测试过。其他平台有兴趣的自己改吧。把LUA脚本导入触摸精灵中修改循环次数为0间隔时间为0,开始游戏按下音量键即可使用。

      脚本中都有详细的注释,即使是初学编程的人应该也会明白的。故不再解释。

      如想试试此脚本的最大功率,建议

            1. 关闭除触摸精灵及天天爱消除之外的其他所有程序(减少系统调度开销时间&释放更多内存)

            2. 等闪烁的动物有4个左右时统一触摸消除。

            3. 注意有无找不到消除的情况发生。如有人工消除几个即可。

 

  脚本本来上传到资源里,但好像被CSDN删除了!不知违反了什么规定!大家还是拷贝复制吧。

[python]  view plain copy
  1. --/********************************************************  
  2. -- * AUTHOR: 翟敏                                         *  
  3. -- * TIME  : 2013-08-26 2007                            *  
  4. -- * MAIL  : zhaimin.cn@gmail.com                         *  
  5. -- ********************************************************/  
  6. -- 注意:适用iphone4及iphone4s. iphone5没测试过。  
  7. SCREEN_RESOLUTION="640x960";  
  8. SCREEN_COLOR_BITS=32;  
  9.   
  10. WIDTH=7;--横竖都是7个动物  
  11. HEIGHT=7;  
  12. START_X=5;--左上角第一个动物的像素坐标为(5,208)  
  13. START_Y=208;  
  14. ANIMAL_SIZE=90;--每个动物大小为90*90个像素  
  15.   
  16. -- 二维数组,记录分析出来的各种动物。  
  17. animals = {}  
  18. animals[0]={}  
  19. animals[1]={}  
  20. animals[2]={}  
  21. animals[3]={}  
  22. animals[4]={}  
  23. animals[5]={}  
  24. animals[6]={}  
  25.   
  26. -- 各种动物枚举。有些动物真不知道叫什么!汗!  
  27. UNKNOWN=0  
  28. PURPLE=1  
  29. PANDA=2  
  30. BROWNBEAR=3  
  31. GREEN=4  
  32. DUCK=5  
  33. BLUE=6  
  34. RED=7  
  35.   
  36. -- 抓屏。按特殊点判断是什么动物。  
  37. function fillAnimalTable()  
  38.     x = 0  
  39.     y = 0  
  40.     keepScreen(true) --加快效率。不连续抓屏,只捉一次。  
  41.     for i=0,6,1 do  
  42.         for j=0,6,1 do  
  43.             x = START_X+i*ANIMAL_SIZE+79  
  44.             y = START_Y+j*ANIMAL_SIZE+53  
  45.             animals[i][j]=UNKNOWN  
  46.             c=getColor(x,y)  
  47.             if (c==0x8262B0) then animals[i][j]=PURPLE  
  48.             elseif (c==0xCACACA) then animals[i][j]=PANDA  
  49.             elseif (c==0xD1683A) then animals[i][j]=BROWNBEAR  
  50.             elseif (c==0x3B4642 or c==0x343E3A) then animals[i][j]=GREEN  
  51.             elseif (c==0x69552E or c==0x6E5B33) then animals[i][j]=DUCK  
  52.             elseif (c==0x1C1F2A or c==0x252833) then animals[i][j]=BLUE  
  53.             elseif (c==0x97626E or c==0x945E6B) then animals[i][j]=RED  
  54.             end  
  55.         end  
  56.     end  
  57.     keepScreen(false)  
  58. end  
  59.   
  60. -- 游戏是否开始中?  
  61. function isProcessing()  
  62.     unkouwn_count=WIDTH*HEIGHT -- 未知动物个数。如太多认为游戏没开始,暂停触控  
  63.     for i=0,6,1 do  
  64.         for j=0,6,1 do  
  65.             if animals[i][j]~=UNKNOWN then unkouwn_count=unkouwn_count-1 end  
  66.         end  
  67.     end  
  68.     return unkouwn_count<WIDTH*HEIGHT/2  
  69. end  
  70.   
  71. -- 把二维坐标(i,j)的动物拉到(i+deltax,j+deltay)  
  72. function moveAnimal(i,j,deltax,deltay)  
  73.     touchDown(9, START_X+i*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+j*ANIMAL_SIZE+ANIMAL_SIZE/2)  
  74.     mSleep(0);  
  75.     touchMove(9, START_X+(i+deltax)*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+(j+deltay)*ANIMAL_SIZE+ANIMAL_SIZE/2)  
  76.     mSleep(0);  
  77.     touchUp(9)  
  78. end  
  79.   
  80. -- 按一下正在闪烁的动物,把同种颜色的消掉  
  81. function removeShanShuoAnimals()  
  82.     for i=0,6,1 do  
  83.         for j=0,6,1 do  
  84.             touchDown(9, START_X+i*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+j*ANIMAL_SIZE+ANIMAL_SIZE/2)  
  85.             touchUp(9)  
  86.         end  
  87.     end  
  88. end  
  89.   
  90. -- 主入口  
  91. function main()  
  92.     rotateScreen(0);  
  93.     --mSleep(0);  
  94.       
  95.     fillAnimalTable()  
  96.     if not isProcessing() then return end  
  97.       
  98.     --各种可以移动的情况都找出来,从上到下找避免影响二维数组。先消下面的会改变上面的情况!  
  99.     for j=0,6,1 do  
  100.         for i=0,6,1 do  
  101.             if ( animals[i][j]~=UNKNOWN) then --只凭一个点位可能确定不出来是什么动物,比如那个点位正好被特效盖住了。  
  102.                 if (i - 1 >= 0 and j - 1 >= 0 and animals[i][j]==(animals[i - 1][j - 1])) then   
  103.                     if (i - 2 >= 0 and animals[i][j]==(animals[i - 2][j - 1]))  then moveAnimal(i, j, 0, -1); end  
  104.                     if (j - 2 >= 0 and animals[i][j]==(animals[i - 1][j - 2]))  then moveAnimal(i, j, -10); end  
  105.                     if (j + 1 < WIDTH and animals[i][j]==(animals[i - 1][j + 1]))  then moveAnimal(i, j, -10); end  
  106.                 end  
  107.                 if (i - 1 >= 0 and j + 1 < WIDTH and animals[i][j]==(animals[i - 1][j + 1])) then   
  108.                     if (i - 2 >= 0 and animals[i][j]==(animals[i - 2][j + 1]))  then moveAnimal(i, j, 01); end  
  109.                     if (j + 2 < WIDTH and animals[i][j]==(animals[i - 1][j + 2]))  then moveAnimal(i, j, -10); end  
  110.                     if (i + 1 < HEIGHT and animals[i][j]==(animals[i + 1][j + 1]))  then moveAnimal(i, j, 01); end  
  111.                 end  
  112.                 if (i + 1 < HEIGHT and j + 1 < WIDTH and animals[i][j]==(animals[i + 1][j + 1])) then   
  113.                     if (i + 2 < HEIGHT and animals[i][j]==(animals[i + 2][j + 1]))  then moveAnimal(i, j, 01); end  
  114.                     if (j + 2 < WIDTH and animals[i][j]==(animals[i + 1][j + 2]))  then moveAnimal(i, j, 10); end  
  115.                     if (j - 1 >= 0 and animals[i][j]==(animals[i + 1][j - 1]))  then moveAnimal(i, j, 10); end  
  116.                 end  
  117.                 if (i + 1 < HEIGHT and j - 1 >= 0 and animals[i][j]==(animals[i + 1][j - 1])) then   
  118.                     if (i + 2 < HEIGHT and animals[i][j]==(animals[i + 2][j - 1]))  then moveAnimal(i, j, 0, -1); end  
  119.                     if (j - 2 >= 0 and animals[i][j]==(animals[i + 1][j - 2]))  then moveAnimal(i, j, 10); end  
  120.                     if (i - 1 >= 0 and animals[i][j]==(animals[i - 1][j - 1]))  then moveAnimal(i, j, 0, -1); end  
  121.                 end  
  122.                 if (i - 2 >= 0 and i - 3 >= 0 and animals[i][j]==(animals[i - 2][j]) and animals[i][j]==(animals[i - 3][j]))  then moveAnimal(i, j, -10); end  
  123.                 if (j - 2 >= 0 and j - 3 >= 0 and animals[i][j]==(animals[i][j - 2]) and animals[i][j]==(animals[i][j - 3]))  then moveAnimal(i, j, 0, -1); end  
  124.                 if (i + 2 < HEIGHT and i + 3 < HEIGHT and animals[i][j]==(animals[i + 2][j]) and animals[i][j]==(animals[i + 3][j]))  then moveAnimal(i, j, 10); end  
  125.                 if (j + 2 < WIDTH and j + 3 < WIDTH and animals[i][j]==(animals[i][j + 2]) and animals[i][j]==(animals[i][j + 3]))  then moveAnimal(i, j, 01); end  
  126.             end  
  127.         end  
  128.     end  
  129.       
  130.     --removeShanShuoAnimals()  
  131.     mSleep(0);  
  132. end  


 

 

    下面玩了几局的截图,有图有真相!

最高分,但腾讯给算成25000,排名倒数了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值