51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 957|回复: 1
打印 上一主题 下一主题

[资料] 想做网上斗地主的王者,教你用Python做个AI出牌器!

[复制链接]
  • TA的每日心情
    无聊
    2024-6-21 09:06
  • 签到天数: 45 天

    连续签到: 2 天

    [LV.5]测试团长

    跳转到指定楼层
    1#
    发表于 2022-8-16 13:32:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    最近在网上看到一个有意思的开源项目,基于快手团队开发的开源AI斗地主——DouZero做的一个“成熟”的AI,项目开源地址【https://github.com/tianqiraf/DouZero_For_HappyDouDiZhu – tianqiraf】。

    今天我们就一起来学习下是如何制作一个基于DouZero的出牌器,看看AI是如何来帮助斗地主的!
    一、核心功能设计
    首先这款出牌器是基于DouZero开发的,核心是需要利用训练好的AI模型来帮住我们,给出最优出牌方案。
    其次关于出牌器,先要需要确认一个AI出牌角色,代表我们玩家自己。我们只要给这个AI输入玩家手牌和三张底牌。确认好地主和农民的各个角色,告诉它三个人对应的关系,这样就可以确定队友和对手。
    我们还要将每一轮其他两人的出牌输入,这样出牌器就可以根据出牌数据,及时提供给我们最优出牌决策,带领我们取得胜利!
    那么如何获取三者之间的关系呢?谁是地主?谁是农民?是自己一人作战还是农民合作?自己玩家的手牌是什么?三张底牌是什么?这些也都需要在开局后确认好。
    大致可以整理出要实现的核心功能如下:
    UI设计排版布局
    显示三张底牌
    显示AI角色出牌数据区域,上家出牌数据区域,下家出牌数据区域,本局胜率区域
    AI玩家手牌区域
    AI出牌器开始停止
    手牌和出牌数据识别

    游戏刚开始根据屏幕位置,截图识别AI玩家手牌及三张底牌
    确认三者之间的关系,识别地主和农民角色,确认队友及对手关系
    识别每轮三位玩家依次出了什么牌,刷新显示对应区域
    AI出牌方案输出

    加载训练好的AI模型,初始化游戏环境
    每轮出牌判断,根据上家出牌数据给出最优出牌决策
    自动刷新玩家剩余手牌和本局胜率预测
    二、实现步骤
    1. UI设计排版布局
    根据上述功能,首先考虑进行简单的UI布局设计,使用的是pyqt5。核心设计代码如下:
    1. <font size="3">def setupUi(self, Form):
    2.     Form.setObjectName("Form")
    3.     Form.resize(440, 395)
    4.     font = QtGui.QFont()
    5.     font.setFamily("Arial")
    6.     font.setPointSize(9)
    7.     font.setBold(True)
    8.     font.setItalic(False)
    9.     font.setWeight(75)
    10.     Form.setFont(font)
    11.     self.WinRate = QtWidgets.QLabel(Form)
    12.     self.WinRate.setGeometry(QtCore.QRect(240, 180, 171, 61))
    13.     font = QtGui.QFont()
    14.     font.setPointSize(14)
    15.     self.WinRate.setFont(font)
    16.     self.WinRate.setAlignment(QtCore.Qt.AlignCenter)
    17.     self.WinRate.setObjectName("WinRate")
    18.     self.InitCard = QtWidgets.QPushButton(Form)
    19.     self.InitCard.setGeometry(QtCore.QRect(60, 330, 121, 41))
    20.     font = QtGui.QFont()
    21.     font.setFamily("Arial")
    22.     font.setPointSize(14)
    23.     font.setBold(True)
    24.     font.setWeight(75)
    25.     self.InitCard.setFont(font)
    26.     self.InitCard.setStyleSheet("")
    27.     self.InitCard.setObjectName("InitCard")
    28.     self.UserHandCards = QtWidgets.QLabel(Form)
    29.     self.UserHandCards.setGeometry(QtCore.QRect(10, 260, 421, 41))
    30.     font = QtGui.QFont()
    31.     font.setPointSize(14)
    32.     self.UserHandCards.setFont(font)
    33.     self.UserHandCards.setAlignment(QtCore.Qt.AlignCenter)
    34.     self.UserHandCards.setObjectName("UserHandCards")
    35.     self.LPlayer = QtWidgets.QFrame(Form)
    36.     self.LPlayer.setGeometry(QtCore.QRect(10, 80, 201, 61))
    37.     self.LPlayer.setFrameShape(QtWidgets.QFrame.StyledPanel)
    38.     self.LPlayer.setFrameShadow(QtWidgets.QFrame.Raised)
    39.     self.LPlayer.setObjectName("LPlayer")
    40.     self.LPlayedCard = QtWidgets.QLabel(self.LPlayer)
    41.     self.LPlayedCard.setGeometry(QtCore.QRect(0, 0, 201, 61))
    42.     font = QtGui.QFont()
    43.     font.setPointSize(14)
    44.     self.LPlayedCard.setFont(font)
    45.     self.LPlayedCard.setAlignment(QtCore.Qt.AlignCenter)
    46.     self.LPlayedCard.setObjectName("LPlayedCard")
    47.     self.RPlayer = QtWidgets.QFrame(Form)
    48.     self.RPlayer.setGeometry(QtCore.QRect(230, 80, 201, 61))
    49.     font = QtGui.QFont()
    50.     font.setPointSize(16)
    51.     self.RPlayer.setFont(font)
    52.     self.RPlayer.setFrameShape(QtWidgets.QFrame.StyledPanel)
    53.     self.RPlayer.setFrameShadow(QtWidgets.QFrame.Raised)
    54.     self.RPlayer.setObjectName("RPlayer")
    55.     self.RPlayedCard = QtWidgets.QLabel(self.RPlayer)
    56.     self.RPlayedCard.setGeometry(QtCore.QRect(0, 0, 201, 61))
    57.     font = QtGui.QFont()
    58.     font.setPointSize(14)
    59.     self.RPlayedCard.setFont(font)
    60.     self.RPlayedCard.setAlignment(QtCore.Qt.AlignCenter)
    61.     self.RPlayedCard.setObjectName("RPlayedCard")
    62.     self.Player = QtWidgets.QFrame(Form)
    63.     self.Player.setGeometry(QtCore.QRect(40, 180, 171, 61))
    64.     self.Player.setFrameShape(QtWidgets.QFrame.StyledPanel)
    65.     self.Player.setFrameShadow(QtWidgets.QFrame.Raised)
    66.     self.Player.setObjectName("Player")
    67.     self.PredictedCard = QtWidgets.QLabel(self.Player)
    68.     self.PredictedCard.setGeometry(QtCore.QRect(0, 0, 171, 61))
    69.     font = QtGui.QFont()
    70.     font.setPointSize(14)
    71.     self.PredictedCard.setFont(font)
    72.     self.PredictedCard.setAlignment(QtCore.Qt.AlignCenter)
    73.     self.PredictedCard.setObjectName("PredictedCard")
    74.     self.ThreeLandlordCards = QtWidgets.QLabel(Form)
    75.     self.ThreeLandlordCards.setGeometry(QtCore.QRect(140, 10, 161, 41))
    76.     font = QtGui.QFont()
    77.     font.setPointSize(16)
    78.     self.ThreeLandlordCards.setFont(font)
    79.     self.ThreeLandlordCards.setAlignment(QtCore.Qt.AlignCenter)
    80.     self.ThreeLandlordCards.setObjectName("ThreeLandlordCards")
    81.     self.Stop = QtWidgets.QPushButton(Form)
    82.     self.Stop.setGeometry(QtCore.QRect(260, 330, 111, 41))
    83.     font = QtGui.QFont()
    84.     font.setFamily("Arial")
    85.     font.setPointSize(14)
    86.     font.setBold(True)
    87.     font.setWeight(75)
    88.     self.Stop.setFont(font)
    89.     self.Stop.setStyleSheet("")
    90.     self.Stop.setObjectName("Stop")

    91.     self.retranslateUi(Form)
    92.     self.InitCard.clicked.connect(Form.init_cards)
    93.     self.Stop.clicked.connect(Form.stop)
    94.     QtCore.QMetaObject.connectSlotsByName(Form)

    95. def retranslateUi(self, Form):
    96.     _translate = QtCore.QCoreApplication.translate
    97.     Form.setWindowTitle(_translate("Form", "AI欢乐斗地主--Dragon少年"))
    98.     self.WinRate.setText(_translate("Form", "胜率:--%"))
    99.     self.InitCard.setText(_translate("Form", "开始"))
    100.     self.UserHandCards.setText(_translate("Form", "手牌"))
    101.     self.LPlayedCard.setText(_translate("Form", "上家出牌区域"))
    102.     self.RPlayedCard.setText(_translate("Form", "下家出牌区域"))
    103.     self.PredictedCard.setText(_translate("Form", "AI出牌区域"))
    104.     self.ThreeLandlordCards.setText(_translate("Form", "三张底牌"))
    105.     self.Stop.setText(_translate("Form", "停止"))
    106. </font>
    复制代码
    2. 手牌和出牌数据识别
    接下来需要所有扑克牌的模板图片与游戏屏幕特定区域的截图进行对比,这样才能获取AI玩家手牌、底牌、每一轮出牌、三者关系(地主、地主上家、地主下家)。
    识别AI玩家手牌及三张底牌:
    我们可以截取游戏屏幕,根据固定位置来识别当前AI玩家的手牌和三张底牌。核心代码如下:
    1. <font size="3"># 牌检测结果滤波
    2. def cards_filter(self, location, distance):  
    3.     if len(location) == 0:
    4.         return 0
    5.     locList = [location[0][0]]
    6.     count = 1
    7.     for e in location:
    8.         flag = 1  # “是新的”标志
    9.         for have in locList:
    10.             if abs(e[0] - have) <= distance:
    11.                 flag = 0
    12.                 break
    13.         if flag:
    14.             count += 1
    15.             locList.append(e[0])
    16.     return count

    17. # 获取玩家AI手牌
    18. def find_my_cards(self, pos):
    19.     user_hand_cards_real = ""
    20.     img = pyautogui.screenshot(region=pos)
    21.     for card in AllCards:
    22.         result = pyautogui.locateAll(needleImage='pics/m' + card + '.png', haystackImage=img, confidence=self.MyConfidence)
    23.         user_hand_cards_real += card[1] * self.cards_filter(list(result), self.MyFilter)
    24.     return user_hand_cards_real

    25. # 获取地主三张底牌
    26. def find_three_landlord_cards(self, pos):
    27.     three_landlord_cards_real = ""
    28.     img = pyautogui.screenshot(region=pos)
    29.     img = img.resize((349, 168))
    30.     for card in AllCards:
    31.         result = pyautogui.locateAll(needleImage='pics/o' + card + '.png', haystackImage=img,
    32.                                      confidence=self.ThreeLandlordCardsConfidence)
    33.         three_landlord_cards_real += card[1] * self.cards_filter(list(result), self.OtherFilter)
    34.     return three_landlord_cards_real

    35. </font>
    复制代码
    效果如下所示:

    地主、地主上家、地主下家:

    同理我们可以根据游戏屏幕截图,识别地主的图标,确认地主角色。核心代码如下:

    1. <font size="3"># 查找地主角色
    2. def find_landlord(self, landlord_flag_pos):
    3.     for pos in landlord_flag_pos:
    4.         result = pyautogui.locateOnScreen('pics/landlord_words.png', region=pos, confidence=self.LandlordFlagConfidence)
    5.         if result is not None:
    6.             return landlord_flag_pos.index(pos)
    7.     return None
    8. </font>
    复制代码

    这样我们就可以得到玩家AI手牌,其他玩家手牌(预测),地主三张底牌,三者角色关系,出牌顺序。核心代码如下:

    1. <font size="3"># 坐标
    2. self.MyHandCardsPos = (414, 804, 1041, 59)  # AI玩家截图区域
    3. self.LPlayedCardsPos = (530, 470, 380, 160)  # 左侧玩家截图区域
    4. self.RPlayedCardsPos = (1010, 470, 380, 160)  # 右侧玩家截图区域
    5. self.LandlordFlagPos = [(1320, 300, 110, 140), (320, 720, 110, 140), (500, 300, 110, 140)]  # 地主标志截图区域(右-我-左)
    6. self.ThreeLandlordCardsPos = (817, 36, 287, 136)      # 地主底牌截图区域,resize成349x168

    7. def init_cards(self):
    8.     # 玩家手牌
    9.     self.user_hand_cards_real = ""
    10.     self.user_hand_cards_env = []
    11.     # 其他玩家出牌
    12.     self.other_played_cards_real = ""
    13.     self.other_played_cards_env = []
    14.     # 其他玩家手牌(整副牌减去玩家手牌,后续再减掉历史出牌)
    15.     self.other_hand_cards = []
    16.     # 三张底牌
    17.     self.three_landlord_cards_real = ""
    18.     self.three_landlord_cards_env = []
    19.     # 玩家角色代码:0-地主上家, 1-地主, 2-地主下家
    20.     self.user_position_code = None
    21.     self.user_position = ""
    22.     # 开局时三个玩家的手牌
    23.     self.card_play_data_list = {}
    24.     # 出牌顺序:0-玩家出牌, 1-玩家下家出牌, 2-玩家上家出牌
    25.     self.play_order = 0
    26.     self.env = None
    27.     # 识别玩家手牌
    28.     self.user_hand_cards_real = self.find_my_cards(self.MyHandCardsPos)
    29.     self.UserHandCards.setText(self.user_hand_cards_real)
    30.     self.user_hand_cards_env = [RealCard2EnvCard[c] for c in list(self.user_hand_cards_real)]
    31.     # 识别三张底牌
    32.     self.three_landlord_cards_real = self.find_three_landlord_cards(self.ThreeLandlordCardsPos)
    33.     self.ThreeLandlordCards.setText("底牌:" + self.three_landlord_cards_real)
    34.     self.three_landlord_cards_env = [RealCard2EnvCard[c] for c in list(self.three_landlord_cards_real)]
    35.     # 识别玩家的角色
    36.     self.user_position_code = self.find_landlord(self.LandlordFlagPos)
    37.     if self.user_position_code is None:
    38.         items = ("地主上家", "地主", "地主下家")
    39.         item, okPressed = QInputDialog.getItem(self, "选择角色", "未识别到地主,请手动选择角色:", items, 0, False)
    40.         if okPressed and item:
    41.             self.user_position_code = items.index(item)
    42.         else:
    43.             return
    44.     self.user_position = ['landlord_up', 'landlord', 'landlord_down'][self.user_position_code]
    45.     for player in self.Players:
    46.         player.setStyleSheet('background-color: rgba(255, 0, 0, 0);')
    47.     self.Players[self.user_position_code].setStyleSheet('background-color: rgba(255, 0, 0, 0.1);')

    48.     # 整副牌减去玩家手上的牌,就是其他人的手牌,再分配给另外两个角色(如何分配对AI判断没有影响)
    49.     for i in set(AllEnvCard):
    50.         self.other_hand_cards.extend([i] * (AllEnvCard.count(i) - self.user_hand_cards_env.count(i)))
    51.     self.card_play_data_list.update({
    52.         'three_landlord_cards': self.three_landlord_cards_env,
    53.         ['landlord_up', 'landlord', 'landlord_down'][(self.user_position_code + 0) % 3]:
    54.             self.user_hand_cards_env,
    55.         ['landlord_up', 'landlord', 'landlord_down'][(self.user_position_code + 1) % 3]:
    56.             self.other_hand_cards[0:17] if (self.user_position_code + 1) % 3 != 1 else self.other_hand_cards[17:],
    57.         ['landlord_up', 'landlord', 'landlord_down'][(self.user_position_code + 2) % 3]:
    58.             self.other_hand_cards[0:17] if (self.user_position_code + 1) % 3 == 1 else self.other_hand_cards[17:]
    59.     })
    60.     print(self.card_play_data_list)
    61.     # 生成手牌结束,校验手牌数量
    62.     if len(self.card_play_data_list["three_landlord_cards"]) != 3:
    63.         QMessageBox.critical(self, "底牌识别出错", "底牌必须是3张!", QMessageBox.Yes, QMessageBox.Yes)
    64.         self.init_display()
    65.         return
    66.     if len(self.card_play_data_list["landlord_up"]) != 17 or \
    67.         len(self.card_play_data_list["landlord_down"]) != 17 or \
    68.         len(self.card_play_data_list["landlord"]) != 20:
    69.         QMessageBox.critical(self, "手牌识别出错", "初始手牌数目有误", QMessageBox.Yes, QMessageBox.Yes)
    70.         self.init_display()
    71.         return
    72.     # 得到出牌顺序
    73.     self.play_order = 0 if self.user_position == "landlord" else 1 if self.user_position == "landlord_up" else 2
    74. </font>
    复制代码

    效果如下:

    3. AI出牌方案输出

    下面我们就需要用到DouZero开源的AI斗地主了。DouZero项目地址:https://github.com/kwai/DouZero。我们需要将该开源项目下载并导入项目中。

    创建一个AI玩家角色,初始化游戏环境,加载模型,进行每轮的出牌判断,控制一局游戏流程的进行和结束。核心代码如下:

    1. <font size="3"># 创建一个代表玩家的AI
    2. ai_players = [0, 0]
    3. ai_players[0] = self.user_position
    4. ai_players[1] = DeepAgent(self.user_position, self.card_play_model_path_dict[self.user_position])
    5. # 初始化游戏环境
    6. self.env = GameEnv(ai_players)
    7. # 游戏开始
    8. self.start()

    9. def start(self):
    10.     self.env.card_play_init(self.card_play_data_list)
    11.     print("开始出牌\n")
    12.     while not self.env.game_over:
    13.         # 玩家出牌时就通过智能体获取action,否则通过识别获取其他玩家出牌
    14.         if self.play_order == 0:
    15.             self.PredictedCard.setText("...")
    16.             action_message = self.env.step(self.user_position)
    17.             # 更新界面
    18.             self.UserHandCards.setText("手牌:" + str(''.join(
    19.                 [EnvCard2RealCard[c] for c in self.env.info_sets[self.user_position].player_hand_cards]))[::-1])

    20.             self.PredictedCard.setText(action_message["action"] if action_message["action"] else "不出")
    21.             self.WinRate.setText("胜率:" + action_message["win_rate"])
    22.             print("\n手牌:", str(''.join(
    23.                     [EnvCard2RealCard[c] for c in self.env.info_sets[self.user_position].player_hand_cards])))
    24.             print("出牌:", action_message["action"] if action_message["action"] else "不出", ", 胜率:",
    25.                   action_message["win_rate"])
    26.             while self.have_white(self.RPlayedCardsPos) == 1 or \
    27.                     pyautogui.locateOnScreen('pics/pass.png',
    28.                                              region=self.RPlayedCardsPos,
    29.                                              confidence=self.LandlordFlagConfidence):
    30.                 print("等待玩家出牌")
    31.                 self.counter.restart()
    32.                 while self.counter.elapsed() < 100:
    33.                     QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)
    34.             self.play_order = 1
    35.         elif self.play_order == 1:
    36.             self.RPlayedCard.setText("...")
    37.             pass_flag = None
    38.             while self.have_white(self.RPlayedCardsPos) == 0 and \
    39.                     not pyautogui.locateOnScreen('pics/pass.png',
    40.                                                  region=self.RPlayedCardsPos,
    41.                                                  confidence=self.LandlordFlagConfidence):
    42.                 print("等待下家出牌")
    43.                 self.counter.restart()
    44.                 while self.counter.elapsed() < 500:
    45.                     QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)
    46.             self.counter.restart()
    47.             while self.counter.elapsed() < 500:
    48.                 QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)
    49.             # 不出
    50.             pass_flag = pyautogui.locateOnScreen('pics/pass.png',
    51.                                                  region=self.RPlayedCardsPos,
    52.                                                  confidence=self.LandlordFlagConfidence)
    53.             # 未找到"不出"
    54.             if pass_flag is None:
    55.                 # 识别下家出牌
    56.                 self.other_played_cards_real = self.find_other_cards(self.RPlayedCardsPos)
    57.             # 找到"不出"
    58.             else:
    59.                 self.other_played_cards_real = ""
    60.             print("\n下家出牌:", self.other_played_cards_real)
    61.             self.other_played_cards_env = [RealCard2EnvCard[c] for c in list(self.other_played_cards_real)]
    62.             self.env.step(self.user_position, self.other_played_cards_env)
    63.             # 更新界面
    64.             self.RPlayedCard.setText(self.other_played_cards_real if self.other_played_cards_real else "不出")
    65.             self.play_order = 2
    66.         elif self.play_order == 2:
    67.             self.LPlayedCard.setText("...")
    68.             while self.have_white(self.LPlayedCardsPos) == 0 and \
    69.                     not pyautogui.locateOnScreen('pics/pass.png',
    70.                                                 region=self.LPlayedCardsPos,
    71.                                                 confidence=self.LandlordFlagConfidence):
    72.                 print("等待上家出牌")
    73.                 self.counter.restart()
    74.                 while self.counter.elapsed() < 500:
    75.                     QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)
    76.             self.counter.restart()
    77.             while self.counter.elapsed() < 500:
    78.                 QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)
    79.             # 不出
    80.             pass_flag = pyautogui.locateOnScreen('pics/pass.png',
    81.                                                  region=self.LPlayedCardsPos,
    82.                                                  confidence=self.LandlordFlagConfidence)
    83.             # 未找到"不出"
    84.             if pass_flag is None:
    85.                 # 识别上家出牌
    86.                 self.other_played_cards_real = self.find_other_cards(self.LPlayedCardsPos)
    87.             # 找到"不出"
    88.             else:
    89.                 self.other_played_cards_real = ""
    90.             print("\n上家出牌:", self.other_played_cards_real)
    91.             self.other_played_cards_env = [RealCard2EnvCard[c] for c in list(self.other_played_cards_real)]
    92.             self.env.step(self.user_position, self.other_played_cards_env)
    93.             self.play_order = 0
    94.             # 更新界面
    95.             self.LPlayedCard.setText(self.other_played_cards_real if self.other_played_cards_real else "不出")
    96.         else:
    97.             pass

    98.         self.counter.restart()
    99.         while self.counter.elapsed() < 100:
    100.             QtWidgets.QApplication.processEvents(QEventLoop.AllEvents, 50)

    101.     print("{}胜,本局结束!\n".format("农民" if self.env.winner == "farmer" else "地主"))
    102.     QMessageBox.information(self, "本局结束", "{}胜!".format("农民" if self.env.winner == "farmer" else "地主"),
    103.                             QMessageBox.Yes, QMessageBox.Yes)
    104.     self.env.reset()
    105.     self.init_display()
    106. </font>
    复制代码

    到这里,整个AI斗地主出牌流程基本已经完成了。

    三、出牌器用法

    按照上述过程,这款AI出牌器已经制作完成了。后面应该如何使用呢?如果不想研究源码,只想使用这款AI斗地主出牌器,验证下效果,该怎么配置环境运行这个AI出牌器呢?下面就开始介绍。

    1. 环境配置

    首先我们需要安装这些第三方库,配置相关环境,如下所示:

    1. <font size="3">torch==1.9.0
    2. GitPython==3.0.5
    3. gitdb2==2.0.6
    4. PyAutoGUI==0.9.50
    5. PyQt5==5.13.0
    6. PyQt5-sip==12.8.1
    7. Pillow>=5.2.0
    8. opencv-python
    9. rlcard
    10. </font>
    复制代码
    2. 坐标调整确认

    我们可以打开游戏界面,将游戏窗口模式下最大化运行,把AI出牌器程序窗口需要移至右下角,不能遮挡手牌、地主标志、底牌、历史出牌这些关键位置。

    其次我们要确认屏幕截图获取的各个区域是否正确。如果有问题需要进行区域位置坐标调整。

    1. <font size="3"># 坐标
    2. self.MyHandCardsPos = (414, 804, 1041, 59)  # 我的截图区域
    3. self.LPlayedCardsPos = (530, 470, 380, 160)  # 左边截图区域
    4. self.RPlayedCardsPos = (1010, 470, 380, 160)  # 右边截图区域
    5. self.LandlordFlagPos = [(1320, 300, 110, 140), (320, 720, 110, 140), (500, 300, 110, 140)]  # 地主标志截图区域(右-我-左)
    6. self.ThreeLandlordCardsPos = (817, 36, 287, 136)      # 地主底牌截图区域,resize成349x168
    7. </font>
    复制代码

    3. 运行测试

    当所有环境配置完成,各区域坐标位置确认无误之后,下面我们就可以直接运行程序,测试效果啦~

    首先我们运行AI出牌器程序,打开游戏界面,进入游戏。当玩家就位,手牌分发完毕,地主身份确认之后,我们就可以点击画面中开始按钮,让AI来帮助我们斗地主了。

    基于这个DouZero项目做一个“成熟”的AI,项目开源地址【https://github.com/tianqiraf/DouZero_For_HappyDouDiZhu – tianqiraf】。

    今天我们就到这里,明天继续努力!











    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

    x
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    该用户从未签到

    2#
    发表于 2022-9-18 18:59:51 | 只看该作者
    感谢楼主分享
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-7-3 19:18 , Processed in 0.074572 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表