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

本文介绍了一款游戏的自动化脚本编写技巧,包括初级和高级策略,如多人协作加速处理和自动化操作。提供了针对特定设备的LUA脚本实现,详细解释了如何利用脚本提高游戏分数,并分享了实际应用效果。脚本适用于特定设备,建议在关闭其他应用、调整消除时机等情况下使用以获取最佳效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

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

 

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

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

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

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

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

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

 

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

--/********************************************************
-- * AUTHOR: 翟敏                                         *
-- * TIME  : 2013-08-26 20:07                            *
-- * MAIL  : zhaimin.cn@gmail.com                         *
-- ********************************************************/
-- 注意:适用iphone4及iphone4s. iphone5没测试过。
SCREEN_RESOLUTION="640x960";
SCREEN_COLOR_BITS=32;

WIDTH=7;--横竖都是7个动物
HEIGHT=7;
START_X=5;--左上角第一个动物的像素坐标为(5,208)
START_Y=208;
ANIMAL_SIZE=90;--每个动物大小为90*90个像素

-- 二维数组,记录分析出来的各种动物。
animals = {}
animals[0]={}
animals[1]={}
animals[2]={}
animals[3]={}
animals[4]={}
animals[5]={}
animals[6]={}

-- 各种动物枚举。有些动物真不知道叫什么!汗!
UNKNOWN=0
PURPLE=1
PANDA=2
BROWNBEAR=3
GREEN=4
DUCK=5
BLUE=6
RED=7

-- 抓屏。按特殊点判断是什么动物。
function fillAnimalTable()
    x = 0
    y = 0
    keepScreen(true) --加快效率。不连续抓屏,只捉一次。
    for i=0,6,1 do
        for j=0,6,1 do
            x = START_X+i*ANIMAL_SIZE+79
            y = START_Y+j*ANIMAL_SIZE+53
            animals[i][j]=UNKNOWN
            c=getColor(x,y)
            if (c==0x8262B0) then animals[i][j]=PURPLE
            elseif (c==0xCACACA) then animals[i][j]=PANDA
            elseif (c==0xD1683A) then animals[i][j]=BROWNBEAR
            elseif (c==0x3B4642 or c==0x343E3A) then animals[i][j]=GREEN
            elseif (c==0x69552E or c==0x6E5B33) then animals[i][j]=DUCK
            elseif (c==0x1C1F2A or c==0x252833) then animals[i][j]=BLUE
            elseif (c==0x97626E or c==0x945E6B) then animals[i][j]=RED
            end
        end
    end
    keepScreen(false)
end

-- 游戏是否开始中?
function isProcessing()
    unkouwn_count=WIDTH*HEIGHT -- 未知动物个数。如太多认为游戏没开始,暂停触控
    for i=0,6,1 do
        for j=0,6,1 do
            if animals[i][j]~=UNKNOWN then unkouwn_count=unkouwn_count-1 end
        end
    end
    return unkouwn_count<WIDTH*HEIGHT/2
end

-- 把二维坐标(i,j)的动物拉到(i+deltax,j+deltay)
function moveAnimal(i,j,deltax,deltay)
    touchDown(9, START_X+i*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+j*ANIMAL_SIZE+ANIMAL_SIZE/2)
    mSleep(0);
    touchMove(9, START_X+(i+deltax)*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+(j+deltay)*ANIMAL_SIZE+ANIMAL_SIZE/2)
    mSleep(0);
    touchUp(9)
end

-- 按一下正在闪烁的动物,把同种颜色的消掉
function removeShanShuoAnimals()
    for i=0,6,1 do
        for j=0,6,1 do
            touchDown(9, START_X+i*ANIMAL_SIZE+ANIMAL_SIZE/2, START_Y+j*ANIMAL_SIZE+ANIMAL_SIZE/2)
            touchUp(9)
        end
    end
end

-- 主入口
function main()
    rotateScreen(0);
    --mSleep(0);
    
    fillAnimalTable()
    if not isProcessing() then return end
    
    --各种可以移动的情况都找出来,从上到下找避免影响二维数组。先消下面的会改变上面的情况!
    for j=0,6,1 do
        for i=0,6,1 do
            if ( animals[i][j]~=UNKNOWN) then --只凭一个点位可能确定不出来是什么动物,比如那个点位正好被特效盖住了。
                if (i - 1 >= 0 and j - 1 >= 0 and animals[i][j]==(animals[i - 1][j - 1])) then 
                    if (i - 2 >= 0 and animals[i][j]==(animals[i - 2][j - 1]))  then moveAnimal(i, j, 0, -1); end
                    if (j - 2 >= 0 and animals[i][j]==(animals[i - 1][j - 2]))  then moveAnimal(i, j, -1, 0); end
                    if (j + 1 < WIDTH and animals[i][j]==(animals[i - 1][j + 1]))  then moveAnimal(i, j, -1, 0); end
                end
                if (i - 1 >= 0 and j + 1 < WIDTH and animals[i][j]==(animals[i - 1][j + 1])) then 
                    if (i - 2 >= 0 and animals[i][j]==(animals[i - 2][j + 1]))  then moveAnimal(i, j, 0, 1); end
                    if (j + 2 < WIDTH and animals[i][j]==(animals[i - 1][j + 2]))  then moveAnimal(i, j, -1, 0); end
                    if (i + 1 < HEIGHT and animals[i][j]==(animals[i + 1][j + 1]))  then moveAnimal(i, j, 0, 1); end
                end
                if (i + 1 < HEIGHT and j + 1 < WIDTH and animals[i][j]==(animals[i + 1][j + 1])) then 
                    if (i + 2 < HEIGHT and animals[i][j]==(animals[i + 2][j + 1]))  then moveAnimal(i, j, 0, 1); end
                    if (j + 2 < WIDTH and animals[i][j]==(animals[i + 1][j + 2]))  then moveAnimal(i, j, 1, 0); end
                    if (j - 1 >= 0 and animals[i][j]==(animals[i + 1][j - 1]))  then moveAnimal(i, j, 1, 0); end
                end
                if (i + 1 < HEIGHT and j - 1 >= 0 and animals[i][j]==(animals[i + 1][j - 1])) then 
                    if (i + 2 < HEIGHT and animals[i][j]==(animals[i + 2][j - 1]))  then moveAnimal(i, j, 0, -1); end
                    if (j - 2 >= 0 and animals[i][j]==(animals[i + 1][j - 2]))  then moveAnimal(i, j, 1, 0); end
                    if (i - 1 >= 0 and animals[i][j]==(animals[i - 1][j - 1]))  then moveAnimal(i, j, 0, -1); end
                end
                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, -1, 0); end
                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
                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, 1, 0); end
                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, 0, 1); end
            end
        end
    end
    
    --removeShanShuoAnimals()
    mSleep(0);
end


 

 

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

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深山老宅

鸡蛋不错的话,要不要激励下母鸡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值