WO2018176650A1 - 基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法 - Google Patents

基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法 Download PDF

Info

Publication number
WO2018176650A1
WO2018176650A1 PCT/CN2017/089220 CN2017089220W WO2018176650A1 WO 2018176650 A1 WO2018176650 A1 WO 2018176650A1 CN 2017089220 W CN2017089220 W CN 2017089220W WO 2018176650 A1 WO2018176650 A1 WO 2018176650A1
Authority
WO
WIPO (PCT)
Prior art keywords
game
image recognition
card
artificial intelligence
information
Prior art date
Application number
PCT/CN2017/089220
Other languages
English (en)
French (fr)
Inventor
张加佳
刘宏
陈佳辉
Original Assignee
北京大学深圳研究生院
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京大学深圳研究生院 filed Critical 北京大学深圳研究生院
Publication of WO2018176650A1 publication Critical patent/WO2018176650A1/zh

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F1/00Card games
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F1/00Card games
    • A63F1/06Card games appurtenances
    • A63F1/18Score computers; Miscellaneous indicators
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/20Scenes; Scene-specific elements in augmented reality scenes
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F1/00Card games
    • A63F2001/008Card games adapted for being playable on a screen

Definitions

  • the invention belongs to the technical field of artificial intelligence and machine game, and particularly relates to a method for establishing an automatic game robot based on image recognition technology and automatic control technology combined with machine game technology.
  • the invention can provide a test platform for large-scale online and human game testing for researchers and scientific research institutions that research machine game technology; the platform can be used for machine game by establishing an automated game robot and conducting large-scale testing with human players. Domain research provides more convincing intelligence level verification.
  • the present invention provides a method for establishing a large-scale human-machine game information database, and provides a data foundation for the research represented by the deep learning method in the field of artificial intelligence.
  • the invention is realized by designing a game scene recognition method, a game information recognition method and an automatic mouse operation method.
  • Machine game is one of the means to test the development level of artificial intelligence.
  • machine gaming has been a hotbed of innovation in artificial intelligence, and the resulting success is an important milestone in the history of artificial intelligence development.
  • dark blue (chess) to Cepheus (Texas Hold'em) to AlphaGo (Go) the machine game system challenges humanity's highest intelligence in one area after another.
  • the machine game system can already compete with human players.
  • current machine gaming systems do not have the ability to operate on common chess-based gaming Internet platforms.
  • the present invention adopts an image recognition-based method to enable a computer to understand various scenes in the game platform and obtain relevant information therefrom.
  • Image recognition refers to the technique of using a computer to process, analyze, and understand images to identify targets and objects in various modes.
  • image recognition technology is becoming more and more perfect, and new records are constantly being created in various image recognition competitions.
  • image recognition is relatively simple in the task of the present invention. The main reasons are as follows: (1) The original picture obtained on the game platform is relatively stable and the noise is relatively small; (2) The features of the category to be identified are relatively simple, and there is a big difference between the game scene and the game information.
  • the present invention proposes a method for establishing a chess game automatic game robot based on image recognition technology and automatic control technology.
  • the system of the present invention is actually a human player based Internet blog
  • the automated game robot of the game platform includes the "eye” of the robot: the game information recognition system based on image recognition technology; the "hand”: automated operating system; and the "brain”: artificial intelligence machine game system.
  • the recognition system converts human-recognizable visual information into a computer-recognizable data structure, performs a policy calculation through a machine game system, and finally realizes an operation interaction with an Internet game platform through an automated operating system.
  • the method for establishing an automatic game robot based on image recognition and automatic control based on image recognition and automatic control comprises the following steps:
  • a method for establishing a chess game automatic game robot based on image recognition and automatic control the steps of which include:
  • step 4) Passing the information identified in step 3) into the artificial intelligence computing system, and the artificial intelligence computing system gives a response strategy;
  • the results of the game of the game are recorded after the game of the game is divided, and then the game scene is automatically recognized to enter the next game.
  • step 1) distinguishes different game scenes using features of various scenes of the gaming platform; the features include RGB features of a plurality of reference locations.
  • the action sequence of the game participant in step 3) includes whether it is their turn to play cards, and the current game information includes a hand card and a card that each player displays.
  • step 3 when performing the identification, first converts the game process into a picture frame by using a screenshot of the windows system, and performs feature extraction on the picture frame, and then adopts k-nearest neighbor-based
  • the classifier classifies the pictures.
  • the picture feature extraction method adopted in step 3) includes binarization, edge detection, and horizontal threading feature extraction, and then selects a suitable window according to the size of the picture, and statistics information in the window is used as a feature. .
  • step 3 when step 3) classifies the picture based on the k-nearest neighbor method, a cross-validation method is adopted to select an optimal k value; the picture classification feature uses a Euclidean distance as the measurement distance.
  • the method for giving the corresponding strategy in step 4) depends on the specific artificial intelligence computing system implemented by the prior art, for example, a chess artificial intelligence system, etc.; the corresponding strategy should conform to the specific chess of the current application. The rules of the game, but the strategy itself does not affect the system operation of the claimed invention.
  • step 5 uses C++ to invoke the automation control function of the windows system to operate on the game platform to implement a complete computer automatic game.
  • An automatic game robot based on image recognition and automatic control comprising an image recognition system, an automatic operating system and an artificial intelligence calculation system, wherein the image recognition system automatically recognizes a game scene by using image recognition technology, and enters a game battle game Identifying a sequence of actions of the current game participant and current game information after the scene; the artificial intelligence computing system provides a coping strategy for the information recognized by the image recognition system; the automated operating system adopts an automated operation technique and is calculated according to artificial intelligence The system's response strategy is automated.
  • the invention makes the large-scale test of the machine game system and the human player possible, and provides a new battle test method, a large-scale experimental method and a database data accumulation method for the research of the game problem with the human player in the field of artificial intelligence.
  • the invention also has an automatic error correction function, and the accuracy of identifying the effective information of the game platform reaches 99.9%.
  • Figure 3 Feature extraction process in image recognition.
  • 1 is a general framework of the method of the present invention, the specific steps include: automatically identifying a game scene based on image recognition technology; performing corresponding operations on each scene to enter a game battle scene; identifying whether it is their turn to play cards and current table information (including Hand, the card that each player shows), sorted by k-nearest-based classifier; incoming current table information
  • the AI function is given a coping strategy by the AI; the automatic operation technique is used to perform the corresponding placard according to the strategy given by the AI; and the score of the game is recorded after the game is scored. The following is a detailed description.
  • the application scenario of the present invention is to use a mobile phone virtual machine to run a game platform in a computer, and the game is a chess game.
  • the game is a chess game.
  • we focus on the main functions in the larger operations related to the battle so it is assumed that the game platform has been opened and logged in, and the page after login is called the main page.
  • scene recognition there are three scenes: unrecognized scenes, ordinary battles, and special battles.
  • the specific implementation of the operation is implemented by an API (application programming interface) based on the windows system, which is described in detail later.
  • Unrecognized scene refers to other scenes other than the battle scene, such as the main page or the pop-up window is not closed. Collectively referred to as anomalies. This will let the computer determine which exception it belongs to and select the appropriate action for the exception. If you stop at the main page, click to match the player and enter the game match page; if there is a small window that is not closed, click the close button.
  • the extraction of image features plays a very important role, and a good feature expression has a great influence on the accuracy of subsequent recognition.
  • image feature extraction methods such as directional gradient histogram (HOG) features, local binary pattern (LBP) features, and scale-invariant feature transform (SIFT) features.
  • HOG directional gradient histogram
  • LBP local binary pattern
  • SIFT scale-invariant feature transform
  • the main feature extraction process of the present invention for a picture I is as shown in FIG. 3, and specifically includes the following contents:
  • Binarization is the first step of all operations. It is mainly used to eliminate the effects of animation and light and shadow masks in the game on image recognition. The effect of binarization is to convert the picture from the grayscale RGB value limited mode to the 01 display.
  • Figure 4 is an example of a binarized picture with a picture on the right and a binarization on the left.
  • Edge detection The purpose of edge detection is to align the recognition area to improve recognition efficiency and accuracy.
  • the object of the edge detection in this embodiment is to align the upper left coordinate point of the recognition area. This is achieved by identifying the first pixel appearing 1 and the first row appearing at the intersection of 1 pixel.
  • Color recognition is a relatively simple identification step in the system, but it plays a key role in improving the recognition speed of the system.
  • the specific method is to determine the playing card color by taking the pixel RGB value of a specific area of the playing card. The color characteristics determined by the system are shown in Table 1.
  • Playing cards R G B Square piece 0 to 25 0 to 25 200 ⁇ 255 Grass flower 0 to 25 200 ⁇ 255 0 to 25 Red peach 200 ⁇ 255 0 to 25 0 to 25 Spades 200 ⁇ 255 200 ⁇ 255 200 ⁇ 255 other -- -- --
  • Horizontal threading feature is one of the keys to identifying playing cards in this system by crossing To identify the 01 distribution in the playing card, the pixel features in the horizontal direction are acquired. In this embodiment, a total of six features of the playing card are collected, namely: a horizontal midline feature, an upper 1/4 line feature, a lower 1/4 line feature, and a first 1 feature corresponding to the three features.
  • the method of acquiring features is horizontal traversal, and the recording horizontal lines intersect a total of several pixels composed of 1.
  • the first 1 feature refers to the first intersection, which is on the left or right side of the recognition area, with 1 on the left and 0 on the right.
  • Figure 5 shows the digital threading feature of the number 5 in the playing card. It can be seen that the number of 1s crossing the three threading lines is 1, 1, and 1, respectively. The positions where the first encounter is 1 are the right side, the left side, and the right side. Therefore, the digital threading feature of 5 is 111010.
  • Figure 6 shows the results of horizontal threading feature extraction for all playing cards.
  • Sub-region digital column feature extraction This module divides the recognition area of playing cards into 9 areas of 3*3, and performs horizontal threading feature extraction again to supplement the global threading feature. The specific process is similar to step 4). I won't go into details here.
  • Feature comparison According to the size of the picture I, a suitable window w is selected, and the information in the w is used as a feature.
  • the proportion of the pixel of the statistical content is The proportion of the pixel whose statistic value is 1 in the window; the statistical feature vector X of the picture I is represented by the statistical information of all the windows. which is:
  • f(w i ) represents the proportion of pixels in the window w i having a value of 1.
  • Fig. 7 is an example of feature extraction results. As shown in Fig. 7, firstly, we obtain the original picture (player K) obtained by the interception, and then extract the feature to obtain the picture, and use an 8*10 window w to obtain the final feature vector X.
  • the window is adjustable, mainly to make the final feature vector dimension fixed, to facilitate the next step.
  • Figure 8 shows the process of image recognition: firstly pre-processing the image, mainly to crop the image and other operations to intercept the key area image. Then feature extraction is performed, and then the feature is input into the k-nearest neighbor classifier, and finally the class tag of the picture is obtained.
  • the approach taken here is to capture the required data from the game platform, including different playing cards, winning scores and other images.
  • the specific method is: statistics on the location and size of the data in the game platform, and then use the program to take screenshots, intercept the corresponding location and size.
  • a classifier is needed to classify the features to obtain the required information.
  • k-NN k-means neighbor
  • the k-nearest neighbor method is a basic classification and regression method. Its input is the feature vector of the instance, corresponding to the point of the feature space; the output is the category of the instance.
  • the k-nearest neighbor hypothesis assumes a training data set in which the instance categories have been determined. When classifying, the new instance is predicted by a majority vote according to the category of the training instances of its k nearest neighbors.
  • the main problems are: the choice of k values, distance metrics and classification decision rules.
  • T ⁇ (x 1 , y 1 ), (x 2 , y 2 ), ... (x N , y N ) ⁇ ,
  • the neighborhood N k (x) is a neighborhood of x covering the above k points;
  • the training focuses on k points adjacent to x. If the k value is too small, it means that the overall model becomes complicated and over-fitting is easy to occur, that is, if the adjacent instance point happens to be noise, the prediction will be wrong.
  • the k value generally takes a relatively small value, and a cross-validation method is usually adopted to select an optimal k value. That is to say, the choice of k value has been tested several times to ensure a better result.
  • k values are determined for different identification tasks. For example, in the recognition of playing cards, the value of k is chosen to be 1, that is, the nearest neighbor method is used here.
  • n the distance representing the sum of the feature vectors
  • n the number of features
  • Euclidean distance when p 2.
  • Classification decision rule generally the majority voting rule, that is, the majority of the k training instances in the result are used as the category of x.
  • the automated operating system is mainly to allow the program to operate on the game platform, to achieve a complete computer automatic game, without the need for human intervention in the battle process.
  • the specific method is to open the program and the corresponding game platform (the game platform runs on the mobile phone virtual machine), the program uses the windows API to obtain the handle of the virtual machine, and obtains the display window of the chess game to be recognized in the windows system.
  • the location, and the window is activated, in order to ensure that each operation can be carried out in the game platform, such as screenshots or mouse operations, to obtain a handle and activate the operation before each operation.
  • the program will perform the automatic game process.
  • a screenshot is needed to identify the relevant information, and the mouse is operated to complete the necessary actions.
  • Windows provides a very well-functioning API to control the movement or click of the mouse, which facilitates the automated operation of the present invention. Similar to the screenshot, first need to collect information about each operation, such as the starting position and destination position of the card, and the dragging process needs to keep the action of clicking the card. Then rely on the information collected in need This operation is implemented using the corresponding API interface. It is worth noting that in the two consecutive mouse operations, the program needs to be suspended for a while, so that the game platform can respond to the operation. Used in this embodiment is 0.3 seconds.
  • Table 2 shows the test data of the single PC of the system of the present invention on the domestic game platform Lianzhong, February 24 to March 14, 2017. A total of 7691 lots were tested in 10 days, with a total score of 10,702 points and an average score of 1.39 points per game.
  • the recognition accuracy rate is 98.87%, which basically guarantees the correct calculation of the AI system.
  • the accuracy of the automatic operation is 95.65%.
  • the normal operation of the system is guaranteed in the case of normal and short-time disconnection, so that the average test time per day exceeds 20 hours, and the total number of test stations per day exceeds 700. It can be seen that if the invention is applied to more platforms and loaded on more computers, the accumulated amount of test data will be further greatly improved.
  • Table 2 Test data of the system in the Lianzhong platform big pineapple game

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

一种基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法。该方法包括:基于图像识别技术自动识别游戏场景;对每一个游戏场景执行相应操作,进入游戏对战博弈场景;识别当前游戏参与人的行动序列和当前游戏信息;将识别的信息传入人工智能计算系统,由人工智能计算系统给出应对策略;采用自动化操作技术根据人工智能计算系统给出的应对策略进行自动化操作。该方法使得机器博弈系统与人类玩家的大规模测试成为可能,为人工智能领域开展与人类玩家的博弈问题研究提供了新的对战测试方法、大规模实验方法及数据库数据积累方法。

Description

基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法 技术领域
本发明属于人工智能与机器博弈技术领域,具体涉及一种基于图像识别技术及自动化控制技术,结合机器博弈技术的棋牌类游戏自动博弈机器人的建立方法。本发明可为研究机器博弈技术的研究者及科研机构,提供一种大规模在线与人类玩家进行测试的试验平台;该平台通过建立自动化博弈机器人,与人类玩家进行大规模测试,可以为机器博弈领域研究提供更具说服力的智能水平验证。同时本发明提供了建立大规模人机博弈信息数据库的方法,为当前人工智能领域以深度学习方法为代表的研究提供数据基础。本发明通过游戏场景识别方法、游戏信息识别方法和自动化鼠标操作方法的设计实现。
背景技术
人工智能是计算机领域的一个重要分支,它的中心任务是研究如何使计算机去做原本只能靠人的智力才能完成的工作。机器博弈作为人工智能的一个研究领域,是检验人工智能发展水平的手段之一。半个多世纪以来,机器博弈一直是人工智能发展创新的温床,由此产生的成功更是人工智能发展史上的重要里程碑。从深蓝(国际象棋)到仙王座(德州扑克)再到AlphaGo(围棋),机器博弈系统在一个又一个领域向人类的最高智能发出了挑战。也就是说机器博弈系统已经可以与人类玩家同台竞技。但是目前的机器博弈系统并不具备在常见的棋牌类游戏互联网平台上进行操作的能力。为了让机器博弈系统与人类玩家同台竞技,本发明采用基于图像识别的方法让计算机可以理解游戏平台中各个场景并从中获得相关信息。
图像识别,是指利用计算机对图像进行处理、分析和理解,以识别各种不同模式的目标和对象的技术。目前,图像识别技术日趋完善,在各项图像识别的比赛中,新记录不断地在被创建。虽然在一些比较复杂的识别任务中,当前技术还不能做到百分百的正确率,但在本发明的任务中,图像识别相对简单。主要的原因有:(1)在游戏平台上获得的原图片相对比较稳定,噪声比较少;(2)需要识别的类别的特征比较简单,游戏场景以及游戏信息之间具有很大的区别。
发明内容
针对现有技术存在的技术问题,本发明提出一种基于图像识别技术及自动化控制技术的棋牌类游戏自动博弈机器人的建立方法。本发明的系统实际上是一个基于人类玩家互联网博 弈平台的自动化博弈机器人,包括了机器人的“眼”:基于图像识别技术的博弈信息识别系统;“手”:自动化操作系统;以及“大脑”:人工智能机器博弈系统。通过识别系统将人类可识别的视觉信息转化为计算机可识别的数据结构,通过机器博弈系统进行策略计算,并最终通过自动化操作系统实现和互联网游戏平台的操作交互。
本发明的基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法,其步骤包括:
一种基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法,其步骤包括:
1)基于图像识别技术自动识别游戏场景;
2)对每一个游戏场景执行相应操作,进入游戏对战博弈场景;
3)识别当前游戏参与人的行动序列和当前游戏信息;
4)将步骤3)识别的信息传入人工智能计算系统,由人工智能计算系统给出应对策略;
5)采用自动化操作技术根据人工智能计算系统给出的应对策略进行自动化操作。
在本发明另一实施例中,在当局游戏分出胜负后记录该局游戏的结果,然后自动识别游戏场景,进入下一局游戏。
在本发明另一实施例中,步骤1)利用游戏平台各个场景的特点来区分不同的游戏场景;所述特点包括多个参照位置的RGB特征。
在本发明另一实施例中,步骤3)所述游戏参与人的行动序列包括是否轮到自己出牌,所述当前游戏信息包括手牌、各玩家亮出的牌。
在本发明另一实施例中,步骤3)在进行所述识别时,首先利用windows系统屏幕截图的方法将游戏进程转化为图片帧,并对该图片帧进行特征提取,然后采用基于k近邻的分类器对图片进行分类。
在本发明另一实施例中,步骤3)采用的图片特征提取方法包括二值化、边缘检测及水平穿线特征提取,然后按照图片的大小选取一个合适的窗口,统计该窗口内的信息作为特征。
在本发明另一实施例中,步骤3)基于k近邻法对图片进行分类时,采取交叉验证的方法来选取最优的k值;图片分类特征采用欧几里德距离作为度量距离。
在本发明另一实施例中,步骤4)中对应策略的给出方法依赖于现有技术实现的特定人工智能计算系统,例如:象棋人工智能系统等等;对应策略应符合当前应用的具体棋牌游戏规则,但策略本身好坏并不影响本发明声明的系统运行。
在本发明另一实施例中,步骤5)利用C++调用windows系统的自动化控制功能在游戏平台上操作,实现完全的计算机自动博弈。
一种基于图像识别及自动化控制的棋牌类游戏自动博弈机器人,包括图像识别系统、自动化操作系统和人工智能计算系统,所述图像识别系统采用图像识别技术自动识别游戏场景,并在进入游戏对战博弈场景后识别当前游戏参与人的行动序列和当前游戏信息;所述人工智能计算系统对所述图像识别系统识别出的信息给出应对策略;所述自动化操作系统采用自动化操作技术并根据人工智能计算系统给出的应对策略进行自动化操作。
本发明的主要意义和有益效果在于:
现有技术中尚未有一种自动化的人机对弈的自动博弈机器人。即使是AlphaGo挑战人类李世石的比赛中,AlphaGo系统仍然需要一个人帮助其进行场景识别及实现操作。该情况导致以往机器博弈系统研究中的训练和测试,主要来自于自身及其他机器博弈系统之间的对战,因为只有这样才能实现大规模的对战测试。偶尔会有研究机构邀请职业的人类玩家进行小规模对战测试。因此,本发明使得机器博弈系统与人类玩家的大规模测试成为可能,为人工智能领域开展与人类玩家的博弈问题研究提供了新的对战测试方法、大规模实验方法及数据库数据积累方法。本发明同时具备自动纠错功能,对游戏平台各项有效信息的识别的准确率达到了99.9%。
附图说明
图1.本发明方法的总体框架图。
图2.确定摆牌流程图。
图3.图像识别中的特征提取流程。
图4.特征提取中的二值化示例。
图5.数字5的水平穿线特征提取过程。
图6.扑克牌牌面的水平穿线特征提取结果。
图7.统计特征提取结果示例。
图8.图像识别流程。
具体实施方式
下面通过实例图和附图,对本发明做进一步说明。
图1为本发明方法的总体框架,具体步骤包括:基于图像识别技术自动识别游戏场景;对每一个场景执行相应操作,进入游戏对战场景;识别是否轮到自己出牌以及当前牌桌信息(包括手牌,各玩家亮出的牌),采用基于k近邻的分类器进行分类;将当前牌桌信息传入 AI函数,由AI给出应对策略;采用自动化操作技术根据AI给出的策略进行相应摆牌;在游戏分出胜负后记录该局游戏的得分。下面做具体说明。
1、识别游戏场景
本发明的应用场景是在计算机中运用手机虚拟机来运行游戏平台,游戏为棋牌类游戏。为了减少操作流程,我们把主要的功能集中在跟对战相关较大的操作中,所以假定已经打开游戏平台并登录了,并把登录后的页面称为主页面。在场景识别中,一共有三个场景:未识别场景,普通对战,特殊对战。在每个场景中都有其对应的操作,在这里,操作的具体实施依靠基于windows系统的API(应用程序编程接口)来实现,后续进行详细介绍。
1)未识别场景:指的是对战场景之外的其他场景,如主页面或者弹出的窗口没关闭等。统称为异常。这时会让计算机判断属于哪种异常,并针对异常选择相应操作。若停在主页面则点击进行匹配玩家并进入游戏对战页面;若存在未关闭的小窗口,则点击关闭按钮。
2)普通对战:在普通对战页面的操作也是本发明的主要内容所在。在这里需要先让计算机了解这时候牌桌情况并做出相应的操作。把普通对战分为三种情况:(1)第一轮,这时我们会先识别第一轮发下来的五张牌以及其他两家的摆牌情况,并将这些信息传入人工智能计算系统(即图1中的AI,也可称为机器博弈系统),然后按照得到的这五张牌的摆法进行摆牌,并确定摆牌是否正确。接着查看上一局的游戏记录,把上一局游戏的结果记录下来以统计机器博弈系统的表现。(2)等待其他玩家,这个不需要做任何操作,简单的让进程休眠一段时间以减少计算机开销。(3)其他轮次,这时会识别发下来的三张手牌,其他两家的摆牌情况以及剩余的牌,并将这些信息传入人工智能计算系统,然后按照得到的摆法进行摆牌,并确定摆牌是否正确。
3)特殊对战:在大菠萝游戏中会在某些情况进入特殊的对战,有的平台称之为梦幻大陆。这时候的场景会与普通对战的布局有些不同,不过相应的操作也由一些不同。首先识别发下来的所有手牌以及其他两家的摆牌情况,并将这些信息传入人工智能计算系统,然后按照得到的摆法进行摆牌,并确定摆牌是否正确。接着查看上一局的游戏记录,把上一局游戏的结果记录下来以统计机器博弈系统的表现。
在摆牌中需要确定摆牌是否正确。在实际的运行过程中,会遇到一些游戏平台自己会处理的异常,比如在网络连接不稳定的时候,摆牌会出现这样的情况:在操作鼠标的过程中,网络连接断开了。这时候其实任何的摆牌操作都不能成功,也就是说鼠标在那里空操作却起不到任何效果。为了解决这种情况,我们制定了确定摆牌的方案,具体流程如图2所示,具体的做法是:在程序操作摆完一张牌后,识别目的位置是否有牌,若没有牌,则重新进行摆 牌;若有牌,则识别该牌是否为此次操作中应该摆上的牌,若不是,则撤下该牌,并重新摆牌。
2、图像特征提取
在图像识别任务中,图像特征的提取扮演了非常重要的角色,一个好的特征表达对之后识别的准确率的影响非常大。现在的图像特征提取方法非常多,如方向梯度直方图(HOG)特征,局部二值模式(LBP)特征,尺度不变特征变换(SIFT)特征等。在本发明的任务中,需要识别的图片内容比较简单,但为了跟上游戏流程,进行的识别次数比较多,所以需要减少运算量,加快图片识别的速度。为此,在不影响之后的识别准确率的情况下,本发明采用了一个更为简单的统计信息作为特征。
本发明对于一张图片I的主要特征提取过程如图3所示,具体包括以下内容:
1)二值化:二值化是所有操作的第一步,主要用于消除游戏中的动画和光影蒙版对图片识别产生的影响。二值化的作用是将图片由灰度RGB值限时的模式转化为01显示。图4是一个二值化图片的示例,其中右边为一张图片,左边为二值化处理结果。
2)边缘检测:边缘检测的目的是对齐识别区域,以提高识别效率和准确性。本实施例中边缘检测的目标是对齐识别区域的左上角坐标点。通过识别第一列出现1和第一行出现1的交叉像素点实现。
3)花色识别:花色识别是系统中较为简单的识别步骤,但却对提升系统识别速度起到了关键作用。具体方法是:通过取扑克牌特定区域的像素RGB值,确定扑克牌花色。本系统确定的花色特征如表1所示。
表1:花色识别特征区间
扑克牌花色 R G B
方片 0~25 0~25 200~255
草花 0~25 200~255 0~25
红桃 200~255 0~25 0~25
黑桃 200~255 200~255 200~255
其他 -- -- --
系统通过上表确认扑克牌花色,如果未落到任何花色的识别区间内,则识别为非扑克牌或者牌背图案,系统跳出本张扑克的识别过程。否则,花色识别结果将和其他流程识别的扑克牌内容结合形成最终结果。例如:黑桃+K=黑桃K。
4)水平穿线特征提取:水平穿线特征是本系统中识别扑克牌的关键之一,方法是通过横 向识别扑克牌中的01分布,获取水平方向的像素特征。本实施例总共采集了扑克牌的6个特征,分别是:水平中线特征、上1/4线特征,下1/4线特征,以及该三个特征对应的首1特征。获取特征的方法是横向遍历,记录水平线总共与几条由1组成的像素点相交。首1特征指的是:首次相交,是在识别区域的左侧还是右侧,左侧为1,右侧为0。
图5给出了扑克牌中数字5的数字穿线特征,可以看到3条穿线交叉的1的数量分别是1、1、1,首次遇到1的位置分别是右侧、左侧、右侧,因此5的数字穿线特征为111010。
图6给出了全部扑克牌牌面的水平穿线特征提取结果。
5)分区域数字列特征提取:本模块将扑克牌的识别区域分割为3*3的9个区域,再次进行水平穿线特征提取,以作为全局穿线特征的补充,具体过程类似于步骤4),这里不再敖述。
6)特征比对:按照图片I的大小选取一个合适的窗口w,统计w内的信息作为特征,在这里,由于原始图片背景与内容的区别较明显,所以统计内容像素点的占比,即统计值为1的像素点在窗口中的占比;图片I的统计特征向量X由所有窗口的统计信息表示。即:
X=(f(w1),...,f(wn))
其中f(wi)表示在窗口wi中值为1的像素点的占比。
图7为特征提取结果示例。如图7所示,首先我们得到的截取得到的原始图片(扑克牌K),然后对其进行特征提取,得到如图图片,采用一个8*10的窗口w,获得最后的特征向量X。在这里这个窗口是可调的,主要是让最后的特征向量维数固定,方便下一步操作。
3、图像识别
图8表示了图像识别的过程:首先对图片进行预处理,主要是对图片进行裁剪等操作,以截取关键区域图片。然后进行特征提取,之后将特征输入到k近邻法分类器中,最后获得图片的类标签。
为了进行图像识别,需要为k近邻分类器准备足够的训练数据集,即进行数据集收集。在这里采取的方法是从游戏平台中截取所需要的数据,包括不同的扑克牌,胜负的分数等图片。具体的做法是:统计游戏平台中各项数据的位置,以及大小,然后用程序进行屏幕截图,截取相应的位置和大小。
在提取完图像的特征后,需要一个分类器来对这些特征进行分类,以获得需要的信息。在本发明的任务中,希望可以用同样的方法来对不同平台的游戏信息进行识别,并且在适配不同平台的时候可以减少额外操作。通过调研发现k近邻法(k-means neighbor,k-NN)符合上述的要求。首先它在简单任务中的效果不错,并且这是一个不需要显示学习的分类器,也就是说不需要提前在训练数据集进行训练。这意味着在适配平台时只需要将要适配的平台的 游戏信息数据集收集后就可以了。
k近邻法是一种基本分类与回归的方法。它的输入为实例的特征向量,对应于特征空间的点;输出为实例的类别。k近邻法假设给定一个训练数据集,其中的实例类别已定。分类时,对新的实例,根据其k个最近邻的训练实例的类别,通过多数表决等方式进行预测。主要的问题有:k值的选择,距离度量及分类决策规则。
k近邻法算法:
1)输入训练集:
T={(x1,y1),(x2,y2),......(xN,yN)},,
其中,
Figure PCTCN2017089220-appb-000001
为特征向量,yi∈Y={c1,c2…ck}为类别;
2)邻域Nk(x):为涵盖上述k个点的x的邻域;
3)确定x的类别y:
Figure PCTCN2017089220-appb-000002
(当yi=cj时I=1,否则为0)
下面说明任务中对三要素的具体选择:
a)k值选择:
训练集中与x相邻近的k个点。如果k值太小就意味着整体模型变得复杂,容易发生过拟合,即如果邻近的实例点恰巧是噪声,预测就会出错。k值的增大意味着整体的模型变得简单,极端的情况是k=N,其中N表示训练集中实例的个数,那么无论输入实例是什么,都只是简单地预测它属于训练集中最多的类,这样的模型过于简单。k值一般取一个比较小的值,通常采取交叉验证的方法来选取最优的k值。也就是说k值的选择得通过多次试验,以确保有一个较好的结果。
在多次试验后,为不同的识别任务确定不同的k值。比如扑克牌的识别中,k值选择1,即这里采用的是最近邻法。
b)距离度量:
Figure PCTCN2017089220-appb-000003
其中,表示特征向量和的距离,n表示特征的个数,当p=1时为曼哈顿距离,当p=2时为欧几里德距离。在我们的任务中我们选择p=2。
c)分类决策规则:一般为多数表决规则,即采用结果中k个训练实例中的多数类作为x的类别。
4、自动化操作系统
自动化操作系统主要是让程序可以在游戏平台上进行操作,实现完全的计算机自动博弈,而不需要人为干预对战过程。可以利用C++调用windows系统的自动化控制功能在游戏平台上操作。具体的做法是,打开本程序以及对应的游戏平台(游戏平台在手机虚拟机上运行)后,程序借助windows的API来获得虚拟机的句柄,得到需要识别的棋牌游戏在windows系统中的显示窗口的位置,并将该窗口激活,为了确保每次操作都能够在游戏平台中进行,比如截图或者鼠标操作,在每次操作之前都做一次获得句柄并激活的操作。主要有下面两个原因:
(a)若游戏平台全部或者部分被其他程序覆盖,将会导致在需要被覆盖部分的信息时,截到的图片不能反映真实发生在游戏平台中的内容,导致之后的信息识别没有起到效果,对博弈系统造成不利的影响。
(b)若游戏平台全部或者部分被其他程序覆盖,将会导致需要鼠标在游戏平台的该位置上操作时,不能作用在平台上,从而不能实时处理异常或者摆牌。
在激活窗口后,程序将进行自动博弈的流程,在这个过程中,需要截图以识别相关信息,并操作鼠标以完成必要的动作。具体做法如下:
(1)截图
在截图时可以截下整个界面,然后进行区域的匹配,以此来获得需要的信息。但是这样的做法计算机开销非常大,作为实时的对战,需要控制时间的消耗。考虑到游戏平台的布局不会轻易改动,所以采取以下的做法:首先,对于一个游戏平台,需要收集各个场景下的有用信息以及其相对虚拟机窗口的位置,以及大小,如手牌的位置和大小,游戏得分的位置和大小等。然后,在实际需要识别某个大小为的信息时,可以利用窗口的位置以及该信息相对窗口的位置来定位该信息在屏幕中的位置。最后,截取屏幕该位置的一张大小的图片。
(2)操作鼠标
Windows提供了功能非常完善的API来控制鼠标的移动或点击,这为本发明的自动化操作提供了便利。跟截图类似,首先需要收集各个操作的相关信息,比如摆牌操作需要牌的起始位置、目的位置,并且拖动过程需要保持单击牌的动作。然后再依赖所收集的信息在需要 该操作时利用对应的API接口来实现。值得注意的是,在连续的两个鼠标操作中需要让程序挂起一点时间,让游戏平台可以响应操作。在本实施例中使用的是0.3秒。
表2给出了本发明系统在国内游戏平台联众上面,2017年2月24至3月14日单台PC电脑的测试数据。10天时间共计测试7691盘,总得分为10702分,平均每局得分为1.39分。除了AI系统的贡献外,本发明也起到了关键贡献:1、识别准确率位98.87%,基本保障了AI系统的正确计算。2、自动化操作准确率为95.65%,在正常及短时间断线等情况下均保障了系统的正常运行,使得每天的平均测试时间超过20小时,每天总计测试局数超过700局。可以看到,如果本发明应用于更多的平台,装载于更多电脑上面,测试数据的积累数量将会得到进一步的大幅提升。
表2:系统在联众平台大菠萝游戏中的测试数据
Figure PCTCN2017089220-appb-000004
以上实施例仅用以说明本发明的技术方案而非对其进行限制,本领域的普通技术人员可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明的精神和范围,本发明的保护范围应以权利要求书所述为准。

Claims (10)

  1. 一种基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法,其步骤包括:
    1)基于图像识别技术自动识别游戏场景;
    2)对每一个游戏场景执行相应操作,进入游戏对战博弈场景;
    3)识别当前游戏参与人的行动序列和当前游戏信息;
    4)将步骤3)识别的信息传入人工智能计算系统,由人工智能计算系统给出应对策略;
    5)采用自动化操作技术根据人工智能计算系统给出的应对策略进行自动化操作。
  2. 如权利要求1所述的方法,其特征在于,在当局游戏分出胜负后记录该局游戏的结果,然后自动识别游戏场景,进入下一局游戏。
  3. 如权利要求1所述的方法,其特征在于,步骤1)利用游戏平台各个场景的特点来区分不同的游戏场景;所述特点包括多个参照位置的RGB特征。
  4. 如权利要求1所述的方法,其特征在于,步骤3)所述游戏参与人的行动序列包括是否轮到自己出牌,所述当前游戏信息包括手牌、各玩家亮出的牌。
  5. 如权利要求1所述的方法,其特征在于,步骤3)在进行所述识别时,首先利用windows系统屏幕截图的方法将游戏进程转化为图片帧,并对该图片帧进行特征提取,然后采用基于k近邻的分类器对图片进行分类。
  6. 如权利要求5所述的方法,其特征在于,步骤3)采用的图片特征提取方法包括二值化、边缘检测及水平穿线特征提取,然后按照图片的大小选取一个合适的窗口,统计该窗口内的信息作为特征。
  7. 如权利要求5所述的方法,其特征在于,步骤3)基于k近邻法对图片进行分类时,采取交叉验证的方法来选取最优的k值;图片分类特征的距离度量方法为:
    Figure PCTCN2017089220-appb-100001
    采用欧几里德距离作为度量距离。
  8. 如权利要求1所述的方法,其特征在于,步骤5)利用C++调用windows系统的自动化控制功能在游戏平台上操作,实现完全的计算机自动博弈。
  9. 如权利要求1所述的方法,其特征在于,在摆牌过程中采用以下方法确定摆牌是否正确:在程序操作摆完一张牌后,识别目的位置是否有牌,若没有牌,则重新进行摆牌;若有牌,则识别该牌是否为此次操作中应该摆上的牌,若不是,则撤下该牌,并重新摆牌。
  10. 一种基于图像识别及自动化控制的棋牌类游戏自动博弈机器人,其特征在于,包括图像 识别系统、自动化操作系统和人工智能计算系统,所述图像识别系统采用图像识别技术自动识别游戏场景,并在进入游戏对战博弈场景后识别当前游戏参与人的行动序列和当前游戏信息;所述人工智能计算系统对所述图像识别系统识别出的信息给出应对策略;所述自动化操作系统采用自动化操作技术并根据人工智能计算系统给出的应对策略进行自动化操作。
PCT/CN2017/089220 2017-03-31 2017-06-20 基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法 WO2018176650A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710208525.8A CN107019901B (zh) 2017-03-31 2017-03-31 基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法
CN201710208525.8 2017-03-31

Publications (1)

Publication Number Publication Date
WO2018176650A1 true WO2018176650A1 (zh) 2018-10-04

Family

ID=59526730

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/089220 WO2018176650A1 (zh) 2017-03-31 2017-06-20 基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法

Country Status (2)

Country Link
CN (1) CN107019901B (zh)
WO (1) WO2018176650A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113082711A (zh) * 2021-03-22 2021-07-09 北京达佳互联信息技术有限公司 游戏机器人的控制方法、装置、服务器及存储介质

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108090561B (zh) * 2017-11-09 2021-12-07 腾讯科技(成都)有限公司 存储介质、电子装置、游戏操作的执行方法和装置
CN109508789B (zh) * 2018-06-01 2022-03-15 北京信息科技大学 预测手牌的方法、存储介质、处理器以及设备
CN109529352B (zh) * 2018-11-27 2023-03-28 腾讯科技(深圳)有限公司 虚拟环境中调度策略的评估方法、装置及设备
CN110163238B (zh) * 2018-12-13 2023-04-07 腾讯科技(深圳)有限公司 一种信息预测的方法、模型训练的方法以及服务器
CN109857663B (zh) * 2019-01-26 2022-04-12 北京工业大学 关键字驱动与图像相似度结合的自动化测试平台
CN111598976B (zh) 2019-02-01 2023-08-22 华为技术有限公司 场景识别方法及装置、终端、存储介质
CN110456975A (zh) * 2019-07-26 2019-11-15 成都龙渊网络科技有限公司 一种在触摸终端上执行触控操作的方法及设备
CN110665235A (zh) * 2019-11-05 2020-01-10 淮安鱼鹰航空科技有限公司 一种无人机打靶娱乐系统
CN110909630B (zh) * 2019-11-06 2023-04-18 腾讯科技(深圳)有限公司 一种异常游戏视频检测方法和装置
CN111437608B (zh) * 2020-03-24 2023-09-08 腾讯科技(深圳)有限公司 基于人工智能的游戏对局方法、装置、设备及存储介质
CN111359213B (zh) * 2020-03-24 2022-11-25 腾讯科技(深圳)有限公司 用于控制游戏对局中的虚拟玩家的方法和设备
CN112057876A (zh) * 2020-09-10 2020-12-11 重庆五诶科技有限公司 基于个性化规则的自动结算系统及方法
CN113546399B (zh) * 2021-07-30 2024-01-23 重庆五诶科技有限公司 基于人工智能算法的棋牌游戏数据采集系统及方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2527324Y (zh) * 2002-03-26 2002-12-25 龙建 通过机器识别与操作的棋具
CN103405909A (zh) * 2013-08-05 2013-11-27 昆山塔米机器人有限公司 一种无人值守下棋机器人系统
CN106182006A (zh) * 2016-08-09 2016-12-07 北京光年无限科技有限公司 面向智能机器人的棋牌交互数据处理方法及装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102034116B (zh) * 2010-05-07 2013-05-01 大连交通大学 基于互补特征和类描述的商品图像分类方法
CN103802111A (zh) * 2013-12-23 2014-05-21 北京晨鑫意科技有限公司 下棋机器人

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2527324Y (zh) * 2002-03-26 2002-12-25 龙建 通过机器识别与操作的棋具
CN103405909A (zh) * 2013-08-05 2013-11-27 昆山塔米机器人有限公司 一种无人值守下棋机器人系统
CN106182006A (zh) * 2016-08-09 2016-12-07 北京光年无限科技有限公司 面向智能机器人的棋牌交互数据处理方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113082711A (zh) * 2021-03-22 2021-07-09 北京达佳互联信息技术有限公司 游戏机器人的控制方法、装置、服务器及存储介质
CN113082711B (zh) * 2021-03-22 2023-08-29 北京达佳互联信息技术有限公司 游戏机器人的控制方法、装置、服务器及存储介质

Also Published As

Publication number Publication date
CN107019901A (zh) 2017-08-08
CN107019901B (zh) 2020-10-20

Similar Documents

Publication Publication Date Title
WO2018176650A1 (zh) 基于图像识别及自动化控制的棋牌类游戏自动博弈机器人的建立方法
WO2020151489A1 (zh) 基于面部识别的活体检测的方法、电子设备和存储介质
CN111325115B (zh) 带有三重约束损失的对抗跨模态行人重识别方法和系统
CN110414432A (zh) 对象识别模型的训练方法、对象识别方法及相应的装置
CN106326874A (zh) 一种人眼图像中的虹膜识别方法及其装置
CN109214298B (zh) 一种基于深度卷积网络的亚洲女性颜值评分模型方法
CN109117897A (zh) 基于卷积神经网络的图像处理方法、装置及可读存储介质
CN110163111A (zh) 基于人脸识别的叫号方法、装置、电子设备及存储介质
CN111414862A (zh) 基于神经网络融合关键点角度变化的表情识别方法
Chen et al. Ibm research australia at lifeclef2014: Plant identification task.
CN110008961A (zh) 文字实时识别方法、装置、计算机设备及存储介质
Wu et al. An early evaluation of gpt-4v (ision)
CN110503099A (zh) 基于深度学习的信息识别方法及相关设备
CN114723652A (zh) 细胞密度确定方法、装置、电子设备及存储介质
CN110148133A (zh) 基于特征点及其结构关系的电路板残片图像识别方法
CN106445654A (zh) 确定响应控制命令优先顺序的方法及装置
Polap Voice control in mixed reality
CN113327212B (zh) 人脸驱动、模型的训练方法、装置、电子设备及存储介质
CN103632380A (zh) 一种基于关键点决策树的在线游戏扑克牌识别方法
Chopra TreeID: An image recognition system for plant species identification
Li et al. Chinese face dataset for face recognition in an uncontrolled classroom environment
Rankothge et al. Plant recognition system based on neural networks
Lin et al. Forecasting Results of Sport Events Through Deep Learning
US10857460B2 (en) Socially-driven modeling systems and methods
Mehta Augmented reality chess analyzer (archessanalyzer): In-device inference of physical chess game positions through board segmentation and piece recognition using convolutional neural network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17903398

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17903398

Country of ref document: EP

Kind code of ref document: A1