Git Product home page Git Product logo

wechat_jump_game's Introduction

教你用Python来玩微信跳一跳

https://wangshub.github.io

github项目地址

更新日志:

2017-12-29 : 增加更新自动化运行脚本,感谢github上的binderclip

2017-12-30 : 请将安卓手机的usb调试模式打开,》开发者选项》USB调试

2017-12-30 : 根据大家反馈:1080屏幕距离系数1.393,2k屏幕为1

相关问题

请先查阅一下issue区

  • 参数出错请在这里提交:issues/62
  • 如果你是ios参考一下: issues/99/issues/4
  • 如果你想自动运行:请运行wechat_jump_auto.py,记得修改config.json参数
  • 如果你是1280x720屏幕分辨率:请运行wechat_jump_auto_1280_720.py
  • 如果你是ios,请运行:wechat_jump_iOS_py3.py

游戏模式

2017年12月28日下午,微信发布了 6.6.1 版本,加入了「小游戏」功能,并提供了官方 demo「跳一跳」。

这是一个 2.5D 插画风格的益智游戏,玩家可以通过按压屏幕时间的长短来控制这个「小人」跳跃的距离。可能刚开始上手的时候,因为时间距离之间的关系把握不恰当,只能跳出几个就掉到了台子下面。 玩法类似于《flappy bird》

如果能精确测量出起始和目标点之间测距离,就可以估计按压的时间来精确跳跃?所以花2个小时写了一个python脚本进行验证

希望不要把分数刷太高,容易没朋友的。。。

工具介绍

  • Python 2.7
  • Android 手机
  • Adb 驱动
  • Python Matplot绘图

如果你是iOS,请参考下面的配置:

依赖安装

    pip install -r requirements.txt

原理说明

  1. 将手机点击到《跳一跳》小程序界面;
  2. 用Adb 工具获取当前手机截图,并用adb将截图pull上来
    adb shell screencap -p /sdcard/1.png
    adb pull /sdcard/1.png .
  1. 用matplot显示截图;
  2. 用鼠标点击起始点和目标位置,计算像素距离;
  3. 根据像素距离,计算按压时间;
  4. 用Adb工具点击屏幕蓄力一跳;
    adb shell input swipe x y x y time

如果你是 iOS

  1. 运行安装好的 WebDriverAgentRunner
  2. 将手机点击到《跳一跳》小程序界面
  3. python3 wechat_jump_iOS_py3.py
  4. 依次点击起始位置和目标位置,实现蓄力一跳
  5. 打开 python3 wechat_jump_iOS_py3.py,根据蓄力一跳的精准情况更改其中的 time_coefficient,直到获得最佳取值

安卓手机操作步骤

  • 安卓手机打开USB调试,设置》开发者选项》USB调试
  • 电脑与手机USB线连接,确保执行adb devices可以找到设备id
  • 界面转至微信跳一跳游戏,点击开始游戏
  • 运行python wechat_jump_auto.py,如果手机界面显示USB授权,请点击确认

实验结果

TODO

可以对拉上来的图片进行颜色分割,识别小人和目标中心,这样就不需要手动点击自动弹跳。 事实证明,机器人比人更会玩儿游戏。

wechat_jump_game's People

Contributors

binderclip avatar f-loat avatar xiongyihui avatar thune-xiaobai avatar 0312birdzhang avatar gavin-gong avatar wowlusitong avatar zengke123 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.