Git Product home page Git Product logo

wechat_jump_game's Issues

求教。用mac自动运行跳三四步就会报错,no such file or directory: './1.png'

每跳三四步就会报找不到截图的错误,求教老司机们这是哪里的问题。谢谢。

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'

附上python3 mac测试成功代码

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()

谁能手把手教下啊

不会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

期待进一步改进

我的手机也是1920×1080,但是可能截图size不同使用效果不太好。经常第一个就跳不过去。

关于adb弹窗

每次执行adb命令都要弹个黑窗口,虽然会自动关闭,但还是不爽。用subprocess.call('adb shell screencap -p /sdcard/1.png', shell=True) 代替os.system调用可解决。

运行python wechat_jump_auto.py成功,但是不能自动跳跃,只输出信息

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)
...

按压不是线性的,只有一个参数不合适

我观察了好长时间运行结果,发现在我手机上设置比较好的参数(小米5s Plus,参数设置为1.418),在中远距离很完美,最高连续八九次跳到中心,然后距离较近时跳的不够远,掉了下来。这说明按压不是线性的,按压时间越长跳的距离增加速度越快。所以乘以一个参数不够,要用一个二次函数或者对数函数模拟吧。

运行pip install -r requirements.txt时报错如下,哪位老哥知道呢

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'

No matching distribution found for ir

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

关于偏位具体位置

screenshot_20171230_113833
screenshot_20171230_113905
tim 20171230114100

修复:
大概位置在鼠标左下角,鼠标左下角点中跳棋下部,然后在点中心点

原来最高能+32分:smile:

实际使用发现误差极大

从第一格开始,每一次跳跃距离鼠标点的起始位置相差非常大,所以跳个4,5格就完了。。

[Errno 2] No such file or directory: '1.png'

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%会有误差。此时起始点不能是人,而是人投影在方块中线上的那个点。

这种情况在现在简单实现的基础上并不是特别好处理。可以先实现人的识别,以及方块的识别(比如说边缘检测啊这种)。

老哥能教教我怎么使用么?

老哥啊!! 我是安卓开发者, 不会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'

pip install -r requirements.txt 时报错

mac 使用 pip install -r requirements.txt 报错内容
"Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'"
已经安装了pip
image
本人android开发~不懂python..

参数不行的发这里

现在只能做到一直跳下去(参数设置的合理的情况下),每次正中心是最终的目标。
常用调试思路:

  • 直线的时候每次都跳的近那么调大 press_coefficient,反之调小

=======

  1. 更新最新的代码
  2. 按下面的方式填写

模板如下

机型:
分辨率(具体到宽高):
电脑系统:
问题描述:
(另外请尽量附一张 screenshot_backups 目录下的 _d.png 结尾画了线的图)

如果自动运行失败的,请注意一下一些小问题

1.请关闭你手机上的所有在system的Window的浮窗,例如:魅族的小点点,请关闭,因为是截图到电脑上进行坐标的计算,但是是通过颜值来计算的,有类似的漂窗就会影响到计算,导致一条就会失败
2.请开启开发者模式。允许adb的模拟输入。
本人的测试过华为,魅族都可以
3.刚作者发布的系数请按照设备分辨率来跳。如果不知道可以在

def find_piece_and_board(im):
w, h = im.size
print('W = ,H = ',w,h)

通过运行一次来查看分辨率

一直报“Failed to establish a new connection”

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 ,一直运行不成功

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.