wangshub / wechat_jump_game Goto Github PK
View Code? Open in Web Editor NEW微信《跳一跳》Python 辅助
Home Page: https://zhuanlan.zhihu.com/p/32452473
License: Apache License 2.0
微信《跳一跳》Python 辅助
Home Page: https://zhuanlan.zhihu.com/p/32452473
License: Apache License 2.0
每跳三四步就会报找不到截图的错误,求教老司机们这是哪里的问题。谢谢。
Traceback (most recent call last):
File "auto.py", line 96, in
main()
File "auto.py", line 85, in main
im = Image.open("./1.png")
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 2530, in open
fp = builtins.open(filename, "rb")
IOError: [Errno 2] No such file or directory: './1.png'
python2的库mac安装有问题
python3一切完美
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from PIL import Image
import math
import time
import os
def pull_screenshot():
os.system('adb shell screencap -p /sdcard/1.png')
os.system('adb pull /sdcard/1.png .')
def jump(distance):
press_time = distance * 1.35
press_time = int(press_time)
cmd = 'adb shell input swipe 320 410 320 410 ' + str(press_time)
print(cmd)
os.system(cmd)
fig = plt.figure()
index = 0
cor = [0, 0]
pull_screenshot()
img = np.array(Image.open('1.png'))
update = True
click_count = 0
cor = []
def update_data():
return np.array(Image.open('1.png'))
im = plt.imshow(img, animated=True)
def updatefig(*args):
global update
if update:
time.sleep(1.5)
pull_screenshot()
im.set_array(update_data())
update = False
return im,
def onClick(event):
global update
global ix, iy
global click_count
global cor
# next screenshot
ix, iy = event.xdata, event.ydata
coords = []
coords.append((ix, iy))
print('now = ', coords)
cor.append(coords)
click_count += 1
if click_count > 1:
click_count = 0
cor1 = cor.pop()
cor2 = cor.pop()
distance = (cor1[0][0] - cor2[0][0])**2 + (cor1[0][1] - cor2[0][1])**2
distance = distance ** 0.5
print('distance = ', distance)
jump(distance)
update = True
fig.canvas.mpl_connect('button_press_event', onClick)
ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)
plt.show()
如果你遇到这个问题:no named module cv2
使用:pip install opencv-python
我用小米note2,1920*1080,然后参数修改成1.393,分出没有超出过100分。我用1.47,跑出了800+的分数。不过感觉还是不理想,还需要调整。
身边就一台lg v31,分辨率1440x2560,参数总是搞不对,哪位帮下参数设置多少合适啊
不会python的,it小白鼠,不过手机好像可以运行python了,谁手把手教下啊,要不提示下也好啊!需要手机连电脑的吗?
raceback (most recent call last):
File "wechat_jump.py", line 2, in
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 116, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/init.py", line 60, in pylab_setup
[backend_name], 0)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 6, in
from six.moves import tkinter as Tk
File "/usr/local/lib/python2.7/dist-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/usr/local/lib/python2.7/dist-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python2.7/dist-packages/six.py", line 82, in _import_module
import(name)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
安卓手机到底是怎么个操作流程啊?哪位大神说一下完整流程?我才刚刚开始学Python ,安卓编程也不太懂,adb就用过一次,用RN开发过一些简单的app
adb的调用替换成wda的api就好了,哪个api请指教
我的手机也是1920×1080,但是可能截图size不同使用效果不太好。经常第一个就跳不过去。
ths
如题,0.5秒完全足够落稳了~
每次执行adb命令都要弹个黑窗口,虽然会自动关闭,但还是不爽。用subprocess.call('adb shell screencap -p /sdcard/1.png', shell=True) 代替os.system调用可解决。
是不是我电脑太破了啊
(1514559142, 338, 1109, 788, 1369)
adb shell input swipe 500 1600 500 1601 723
PS D:\Python\wechat_jump_game> python wechat_jump_auto.py
3248 KB/s (59920 bytes in 0.018s)
1514605731 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2088 KB/s (59920 bytes in 0.028s)
1514605741 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2016 KB/s (59920 bytes in 0.029s)
1514605750 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2165 KB/s (59920 bytes in 0.027s)
1514605760 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2249 KB/s (59920 bytes in 0.026s)
1514605770 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2016 KB/s (59920 bytes in 0.029s)
1514605781 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
1670 KB/s (59920 bytes in 0.035s)
1514605790 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2436 KB/s (59920 bytes in 0.024s)
1514605801 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2338 KB/s (59920 bytes in 0.025s)
1514605810 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
1949 KB/s (59920 bytes in 0.030s)
1514605820 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
1949 KB/s (59920 bytes in 0.030s)
1514605831 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2088 KB/s (59920 bytes in 0.028s)
1514605840 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2088 KB/s (59920 bytes in 0.028s)
1514605850 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2339 KB/s (59920 bytes in 0.025s)
1514605860 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
2339 KB/s (59920 bytes in 0.025s)
1514605870 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
1949 KB/s (59920 bytes in 0.030s)
1514605880 338.54135338345867 1109 788.5 1385.4159479214936
adb shell input swipe 320 410 320 410 735
3479 KB/s (602572 bytes in 0.169s)
1514605889 0 0 0 0
adb shell input swipe 320 410 320 410 200
2284 KB/s (524254 bytes in 0.224s)
1514605898 0 0 0 0
adb shell input swipe 320 410 320 410 200
2382 KB/s (524873 bytes in 0.215s)
...
board_y = piece_y + abs(board_x - piece_x) * abs(1122 - 831) / abs(813 - 310) # 按实际的角度来算,找到接近下一个 board 中心的坐标
这里面的数值是怎么来的?
我观察了好长时间运行结果,发现在我手机上设置比较好的参数(小米5s Plus,参数设置为1.418),在中远距离很完美,最高连续八九次跳到中心,然后距离较近时跳的不够远,掉了下来。这说明按压不是线性的,按压时间越长跳的距离增加速度越快。所以乘以一个参数不够,要用一个二次函数或者对数函数模拟吧。
手机型号华为5S
颜色很类似的时候好像也会有这样的问题?距离远的时候就超完美的! 小米5:press_time = distance * 1.45
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/init.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-sZqIwC-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
:'cp' 不是内部或外部命令,也不是可运行的程序
求指导
魅族MX5,1080p;不是每一次都是正中心 0.0
on Ubuntu 17.04, I got this error while running 'pip install -r requirements.txt';
Collecting ir
Could not find a version that satisfies the requirement ir (from versions: )
No matching distribution found for ir
in set_data raise TypeError("Image data cannot be converted to float")
有人出现这个类型错误么
从第一格开始,每一次跳跃距离鼠标点的起始位置相差非常大,所以跳个4,5格就完了。。
欢迎可用的同学把自己的参数贴在这里,这里不接受问题 参数没设置好的发这里 · Issue #62
模板如下
机型:
分辨率(写明宽高):
具体参数:
under_game_score_y =
press_coefficient =
piece_base_height_1_2 =
piece_body_width =
最高打到了多少分(欢迎截图):
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe D:/work/wechat_jump_game/wechat_jump_py3.py
'adb' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
'adb' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Traceback (most recent call last):
File "D:/work/wechat_jump_game/wechat_jump_py3.py", line 25, in
img = np.array(Image.open('1.png'))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\PIL\Image.py", line 2530, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '1.png'
实际使用的时候,遇到有一定几率
测量准确,也有一定几率
测量出现误差的情况。
仔细观察了一下,有一个原因是:
当你在某一个方块跳歪了的同时转向, 测量的距离就100%会有误差。此时起始点不能是人,而是人投影在方块中线上的那个点。
这种情况在现在简单实现的基础上并不是特别好处理。可以先实现人的识别,以及方块的识别(比如说边缘检测啊这种)。
我的安卓设备是2k分辨率,我将时间系数变成了2.5,横跳可以,纵跳总是最大力气跳出
老哥啊!! 我是安卓开发者, 不会Python, 能不能教教我第一步该咋,第二部该咋? 我现在把Python安装到Windows上了,环境变量也配置了, 接下来该咋搞? 完全没有头绪啊!! 谢老哥。
Traceback (most recent call last):
File "D:/py/untitled/wechat_jump_py3.py", line 28, in
img = np.array(Image.open('1.png'))
File "C:\Users\WKN\Anaconda3\lib\site-packages\PIL\Image.py", line 2477, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '1.png'
现在只能做到一直跳下去(参数设置的合理的情况下),每次正中心是最终的目标。
常用调试思路:
=======
模板如下
机型:
分辨率(具体到宽高):
电脑系统:
问题描述:
(另外请尽量附一张 screenshot_backups 目录下的 _d.png 结尾画了线的图)
我直接运行的wechat_jump_auto.py,然后界面上会自己去跳,结果得分还没我高呢,就二三十分就挂了,没明白啊
改了好多次参数都是第一个就掉下去了
大概思路是靠颜色来定位棋子和板子的坐标。
代码在这里:
https://github.com/binderclip/wechat_jump_game/blob/master/wechat_jump_auto.py
可以 PR 一下吗?
1.请关闭你手机上的所有在system的Window的浮窗,例如:魅族的小点点,请关闭,因为是截图到电脑上进行坐标的计算,但是是通过颜值来计算的,有类似的漂窗就会影响到计算,导致一条就会失败
2.请开启开发者模式。允许adb的模拟输入。
本人的测试过华为,魅族都可以
3.刚作者发布的系数请按照设备分辨率来跳。如果不知道可以在
def find_piece_and_board(im):
w, h = im.size
print('W = ,H = ',w,h)
通过运行一次来查看分辨率
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8100): Max retries exceeded with url: /screenshot (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x116590b70>: Failed to establish a new connection: [Errno 61] Connection refused',))
我是iOS,在本地浏览器上打开http://localhost:8100/status
能看见json数据,也做了端口转发 iproxy 8100 8100
,一直运行不成功
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.