GithubHelp home page GithubHelp logo

iyuangang / automatic-minesweeping Goto Github PK

View Code? Open in Web Editor NEW

This project forked from buaazyc/automatic-minesweeping

0.0 1.0 0.0 47.59 MB

Automatic minesweeping for Windows XP classic version minesweeper by Python3.7

License: MIT License

Python 100.00%

automatic-minesweeping's Introduction

Automatic-minesweeping(自动扫雷)

Automatic minesweeping for Windows XP classic version minesweeper by Python3.7
使用Python编写脚本,实现对经典扫雷游戏的程序自动完成游戏

exe脚本使用方法:

  1. 打开扫雷
  2. 运行exe脚本程序

My Operating environment:

Windows 10
Python 3.7
Windows经典的Minesweeper游戏

Program requirement:

Numpy:用于矩阵运算
pillow:用于截图,根据截图判断每个格子内容
pywin32:用户获取窗口,使用鼠标键盘

主要思路:

  1. 使用pywin32获取扫雷游戏的窗口,并模拟键盘鼠标操作进行点击和插旗
  2. 利用截图中,各个块像素点的和来区分各个块,比如块“1”的像素点和为128664,块“红旗”的像素点和为129165,从而将图片信息转化为矩阵信息,矩阵对应着游戏中整个棋盘
  3. 遍历矩阵每个元素,根据周边信息去判断什么时候插旗,什么时候点击,什么时候左右键同时
  4. 循环遍历直到游戏失败或者胜利

代码结构:

  1. window.py主要定义基础窗口类,用于获得基本的窗口信息
  2. use_keyboard_and_mouse.py顾名思义定义了鼠标和键盘操作类
  3. basic_operation.py封装了之前的类,实现了扫雷的基本操作,比如点击,插旗,重开等
  4. game.py是脚本运行的主逻辑,进行循环遍历判断决策等。
  5. surround.py定义了格子及其周边信息类,用于判断当前局势,方便决策

automatic-minesweeping's People

Contributors

buaazyc avatar

Watchers

 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.