Giter VIP home page Giter VIP logo

gamescripts's Introduction

Gamescripts

  • 扩展方便的并发按键机器人;
  • 个人练手项目,不是很规范;
  • 这是我刷YYS的小脚本发展而来的python2老版
  • 这本质上只是一个模拟按键的东西,算不上外挂;
  • 使用别过度;虽然用了很久没被封号(没有东西可以检测,难道对方要封锁PYTHON进程?)
  • 如果是做端游的脚本,一定要用管理员运行,否则,不能发送点击指令给游戏窗口

使用说明

python main.py --targets "bc_win2 bc_win1 bc_tz"

使用快捷键 F12 ,可用停止脚本;

--targets #目标,就是需要匹配的目标按钮等,图片名称,支持这些后缀vision.py/Validate_IMG_EXT = ["png","jpeg","jpg"] 
   目标名称的前两个字符用于关联相关动作
     devicebind.py/sda_map = {"bc":["mouse","click"],
               "kd":["keyboard","keyDown"],
                "None":["mouse","move"]}
--max_step=100 #count_point 的最大匹配次数
--count_point="bc_tz" #匹配到这个目标max_step+1
--imgsdir="yys1080p" #目标存放目录
(用GOOGLE  的python-fire实现的命令行命令行参数可以任意变)


在devicebind.py/下添加相关映射可用支持更多动作
devicebind.py/PC_bind = {
    "mouse":{"move":pag.moveTo,"click":pag.click},
    "keyboard":{}
}

#可以支持android模拟器/物理机(需要连接ADB),需要额外两个实现 ADB抓图和发送命令,暂时未添加,以后会加入
devicebind.py/Andriod_bind = {}

开发备忘

  • 目标:并发、分布式、扩展规则(计划支持YAML格式)
  • 版本号说明:
    • 当前:v0.1a
    • 版本格式 [新增功能:0 - inf].[bug修复:0 - 99].[ab:a - 初版非稳定;b - 稳定]

并发支持

  • 目前支持多线程、协程、多线程程运行模式
  • 但是只有多线程、协程支持机器人统一管理;多进程由于通信比较复杂,统一管理还在开发中
  • 使用示例在main.pymian_ceshi.py

程序逻辑

  • sensor --> robot -->executor(callbacks)
  • sensor: 包装了抓图和匹配目标两个功能,用于获得目标坐标/当前状态
  • executor: 执行robot发来的命令;通过调用ExecutorCallBack实例实现统计、日志、通信等各种功能
  • 命令格式 CMD = namedtuple("CMD",["device","action","code","status"],defaults=[None])
  • robot: 负责执行sensor获得目标坐标/当前状态;通过bind_status 生成相应命令CMD,然调用executor执行CMD
  • 之所以把原来几行解决的问题搞OO这么繁琐,是为了支持分布式和可扩展

计划功能

  • SIFT算子: 增强应用环境(需配合ML中的聚类算法)
  • 分离多线程和多进程入口,添加完整使用方法
  • 有时间把YAML格式支持也做了
  • 多屏幕以及屏幕分割
  • 分布式部署下的通信CALLBACK
  • 独立控制界面(这个最不想做,跑脚本的目的就是啥也不干)

gamescripts's People

Contributors

dkluffy avatar

Stargazers

 avatar

Watchers

 avatar

gamescripts's Issues

AttributeError: Can't pickle local object 'shift_coords.<locals>.shifter'

多进程下的报错,多线程模式没有

def shift_coords(func):
    def shifter(*args):
        co,st = func(*args)
          co = np.array(co)
          co_dalt = np.random.randint(0,20,co.shape)
          co = co + co_dalt
        return co,st
    return shifter

@shift_coords
def matcher_comm(input_img,targets):
    coords = []
    status = []
    for t in targets.keys():
        pts = match_gray(input_img,targets[t])
        if len(pts)>0:
            coords+=pts
            status+=([t]*len(pts))
    return coords,status
I:\Code_Public\Gamescripts>I:/Anaconda3/Scripts/activate

(base) I:\Code_Public\Gamescripts>conda activate base

(base) I:\Code_Public\Gamescripts>I:/Anaconda3/python.exe i:/Code_Public/Gamescripts/main.py
Warning: some status, don't have valide image
Traceback (most recent call last):
  File "i:/Code_Public/Gamescripts/main.py", line 60, in <module>       
    p_list.append(comm_task_on_pc(["test01"],10))
  File "i:/Code_Public/Gamescripts/main.py", line 42, in comm_task_on_pc
    p0.start()
  File "I:\Anaconda3\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "I:\Anaconda3\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "I:\Anaconda3\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "I:\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 89, in __init__
    reduction.dump(process_obj, to_child)
  File "I:\Anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'shift_coords.<locals>.shifter'

(base) I:\Code_Public\Gamescripts>Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "I:\Anaconda3\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "I:\Anaconda3\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

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.