基于DouZero定制AI实战欢乐斗地主

Overview

DouZero_For_Happy_DouDiZhu: 将DouZero用于欢乐斗地主实战

Logo

  • 本项目基于DouZero
  • 环境配置请移步项目DouZero
  • 模型默认为WP,更换模型请修改start.py中的模型路径
  • 运行main.py即可
  • SL (baselines/sl/): 基于人类数据进行深度学习的预训练模型
  • DouZero-ADP (baselines/douzero_ADP/): 以平均分数差异(Average Difference Points, ADP)为目标训练的Douzero智能体
  • DouZero-WP (baselines/douzero_WP/): 以胜率(Winning Percentage, WP)为目标训练的Douzero智能体

说明

  • 将玩家角色设置为AI,需开局时手动输入玩家角色、初始手牌、三张底牌
  • 每轮手动输入其他两位玩家出的牌,AI给出出牌建议以及预计胜率
  • 暂未设计可视化界面,正考虑通过截屏自动识别开局手牌。
  • 欢乐斗地主窗口模式最大化运行,屏幕分辨率1920x1080。由于设计像素级操作,运行出错请检查截图区域坐标(位于MyPyQT_Form类中的__init__函数内)
  • 窗口移至右下角,避免遮挡手牌,历史牌,底牌区域。

使用步骤

  1. 确认环境正常,等待手牌出现、底牌出现、地主角色确认后,点击开始,耗时几秒完成识别。
  2. 窗口内显示识别结果,地主角色使用淡红色标出。识别完成自动开始记录出牌。
  3. 观察AI建议的出牌,在游戏中手动选择并打出。
  4. 游戏结束后弹出对话框提示输赢。
  5. 识别错误或无反应可通过结束按钮停止本局。至于游戏,就自己手动打完吧。

潜在Bug

  • 王炸时出牌特效时间较长,有一定几率导致只能识别出一个王。

鸣谢

  • 本项目基于DouZero
  • 借鉴了cardRecorder项目的部分代码以及模板图片,用于识别扑克牌

相关链接

Comments
  • 请问这是我的设置问题吗

    请问这是我的设置问题吗

    我首先按照要求安装了所需依赖,进入对局点击开始后提示输出

    等待下家出牌 等待下家出牌 等待下家出牌

    下家出牌: 44333 Traceback (most recent call last): File "c:\Users\11984\Downloads\DouZero_For_HappyDouDiZhu-master\main.py", line 170, in init_cards self.start() File "c:\Users\11984\Downloads\DouZero_For_HappyDouDiZhu-master\main.py", line 226, in start
    self.env.step(self.user_position, self.other_played_cards_env) TypeError: step() takes 1 positional argument but 3 were given

    以上这样的报错 图形界面卡死,图片附上

    report

    opened by jiahao2333 4
  • 开始以后闪退

    开始以后闪退

    看记录好像能识别出手牌,麻烦帮忙看看是为什么

    F:\Desktop\DouZero_For_HappyDouDiZhu-2.0>python main.py {'three_landlord_cards': [9, 8, 3], 'landlord_up': [17, 17, 14, 14, 13, 13, 12, 12, 10, 9, 8, 7, 7, 6, 5, 4, 3], 'landlord': [9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 14, 14, 17, 17, 20, 30], 'landlord_down': [3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]} Traceback (most recent call last): File "C:\Users\liule\AppData\Local\Programs\Python\Python38\lib\site-packages\git_init_.py", line 83, in refresh() File "C:\Users\liule\AppData\Local\Programs\Python\Python38\lib\site-packages\git_init_.py", line 73, in refresh if not Git.refresh(path=path): File "C:\Users\liule\AppData\Local\Programs\Python\Python38\lib\site-packages\git\cmd.py", line 287, in refresh raise ImportError(err) ImportError: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh()

    All git commands will error until this is rectified.

    This initial warning can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exception

    Example: export GIT_PYTHON_REFRESH=quiet

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "main.py", line 164, in init_cards ai_players[1] = DeepAgent(self.user_position, self.card_play_model_path_dict[self.user_position]) File "F:\Desktop\DouZero_For_HappyDouDiZhu-2.0\douzero\evaluation\deep_agent.py", line 25, in init self.model = load_model(position, model_path) File "F:\Desktop\DouZero_For_HappyDouDiZhu-2.0\douzero\evaluation\deep_agent.py", line 7, in load_model from douzero.dmc.models import model_dict File "F:\Desktop\DouZero_For_HappyDouDiZhu-2.0\douzero\dmc_init.py", line 1, in from .dmc import train File "F:\Desktop\DouZero_For_HappyDouDiZhu-2.0\douzero\dmc\dmc.py", line 12, in from .file_writer import FileWriter File "F:\Desktop\DouZero_For_HappyDouDiZhu-2.0\douzero\dmc\file_writer.py", line 25, in import git File "C:\Users\liule\AppData\Local\Programs\Python\Python38\lib\site-packages\git_init.py", line 85, in raise ImportError('Failed to initialize: {0}'.format(exc)) ImportError: Failed to initialize: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh()

    All git commands will error until this is rectified.

    This initial warning can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exception

    Example: export GIT_PYTHON_REFRESH=quiet

    opened by 0xbba 3
  • 区域坐标能否解答下?

    区域坐标能否解答下?

    self.MyHandCardsPos = (414, 804, 1041, 59)  # 我的截图区域
            self.LPlayedCardsPos = (530, 470, 380, 160)  # 左边截图区域
            self.RPlayedCardsPos = (1010, 470, 380, 160)  # 右边截图区域
            self.LandlordFlagPos = [(1320, 300, 110, 140), (320, 720, 110, 140), (500, 300, 110, 140)]  # 地主标志截图区域(右-我-左)
            self.ThreeLandlordCardsPos = (817, 36, 287, 136)      # 地主底牌截图区域,resize成349x168
    

    我怎么用坐标拾取工具对比了下发现完全不对

    opened by daofeng2015 1
  • 由于分辨率导致的牌面识别瓶颈改进意见

    由于分辨率导致的牌面识别瓶颈改进意见

    使用win32gui库对游戏窗口进行坐标(0,0)、尺寸(默认尺寸)自动固定,如下: win32gui.SetWindowPos(hwnd, win32con.HWND_NOTOPMOST, 0, 0, 1440, 838, win32con.SWP_SHOWWINDOW)

    然后在此基础上制作配套pics,可极大降低由分辨率问题引起的各类找图问题。

    opened by null119 0
  • pos_duge报错

    pos_duge报错

    [ WARN:[email protected]] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('QQ截图20220507102631.png'): can't open/read file: check file path/integrity Traceback (most recent call last): File "G:/python/code_py/douzero_huanledoudizhu/DouZero_For_HappyDouDiZhu/pos_debug.py", line 25, in cv2.imshow("test", img) cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' 想问一下这是什么情况

    opened by fengmianchen 0
Releases(v2.0)
AniGAN: Style-Guided Generative Adversarial Networks for Unsupervised Anime Face Generation

AniGAN: Style-Guided Generative Adversarial Networks for Unsupervised Anime Face Generation AniGAN: Style-Guided Generative Adversarial Networks for U

Bing Li 81 Dec 14, 2022
InsTrim: Lightweight Instrumentation for Coverage-guided Fuzzing

InsTrim The paper: InsTrim: Lightweight Instrumentation for Coverage-guided Fuzzing Build Prerequisite llvm-8.0-dev clang-8.0 cmake = 3.2 Make git cl

75 Dec 23, 2022
Python Implementation of algorithms in Graph Mining, e.g., Recommendation, Collaborative Filtering, Community Detection, Spectral Clustering, Modularity Maximization, co-authorship networks.

Graph Mining Author: Jiayi Chen Time: April 2021 Implemented Algorithms: Network: Scrabing Data, Network Construbtion and Network Measurement (e.g., P

Jiayi Chen 3 Mar 03, 2022
Official repository for the paper F, B, Alpha Matting

FBA Matting Official repository for the paper F, B, Alpha Matting. This paper and project is under heavy revision for peer reviewed publication, and s

Marco Forte 404 Jan 05, 2023
Deformable DETR is an efficient and fast-converging end-to-end object detector.

Deformable DETR: Deformable Transformers for End-to-End Object Detection.

2k Jan 05, 2023
Implementation for Curriculum DeepSDF

Curriculum-DeepSDF This repository is an implementation for Curriculum DeepSDF. Full paper is available here. Preparation Please follow original setti

Haidong Zhu 69 Dec 29, 2022
Source codes for the paper "Local Additivity Based Data Augmentation for Semi-supervised NER"

LADA This repo contains codes for the following paper: Jiaao Chen*, Zhenghui Wang*, Ran Tian, Zichao Yang, Diyi Yang: Local Additivity Based Data Augm

GT-SALT 36 Dec 02, 2022
Redash reset for python

redash-reset This will use a default REDASH_SECRET_KEY key of c292a0a3aa32397cdb050e233733900f this allows you to reset the password of the user ID bu

Robert Wiggins 5 Nov 14, 2022
Official Pytorch Implementation of 'Learning Action Completeness from Points for Weakly-supervised Temporal Action Localization' (ICCV-21 Oral)

Learning-Action-Completeness-from-Points Official Pytorch Implementation of 'Learning Action Completeness from Points for Weakly-supervised Temporal A

Pilhyeon Lee 67 Jan 03, 2023
Monocular 3D Object Detection: An Extrinsic Parameter Free Approach (CVPR2021)

Monocular 3D Object Detection: An Extrinsic Parameter Free Approach (CVPR2021) Yunsong Zhou, Yuan He, Hongzi Zhu, Cheng Wang, Hongyang Li, Qinhong Jia

Yunsong Zhou 51 Dec 14, 2022
WRENCH: Weak supeRvision bENCHmark

🔧 What is it? Wrench is a benchmark platform containing diverse weak supervision tasks. It also provides a common and easy framework for development

Jieyu Zhang 176 Dec 28, 2022
Wanli Li and Tieyun Qian: Exploit a Multi-head Reference Graph for Semi-supervised Relation Extraction, IJCNN 2021

MRefG Wanli Li and Tieyun Qian: "Exploit a Multi-head Reference Graph for Semi-supervised Relation Extraction", IJCNN 2021 1. Requirements To reproduc

万理 5 Jul 26, 2022
Code for Two-stage Identifier: "Locate and Label: A Two-stage Identifier for Nested Named Entity Recognition"

Code for Two-stage Identifier: "Locate and Label: A Two-stage Identifier for Nested Named Entity Recognition", accepted at ACL 2021. For details of the model and experiments, please see our paper.

tricktreat 87 Dec 16, 2022
Pytorch Performace Tuning, WandB, AMP, Multi-GPU, TensorRT, Triton

Plant Pathology 2020 FGVC7 Introduction A deep learning model pipeline for training, experimentaiton and deployment for the Kaggle Competition, Plant

Bharat Giddwani 0 Feb 25, 2022
[SIGMETRICS 2022] One Proxy Device Is Enough for Hardware-Aware Neural Architecture Search

One Proxy Device Is Enough for Hardware-Aware Neural Architecture Search paper | website One Proxy Device Is Enough for Hardware-Aware Neural Architec

10 Dec 16, 2022
DecoupledNet is semantic segmentation system which using heterogeneous annotations

DecoupledNet: Decoupled Deep Neural Network for Semi-supervised Semantic Segmentation Created by Seunghoon Hong, Hyeonwoo Noh and Bohyung Han at POSTE

Hyeonwoo Noh 74 Sep 22, 2021
Official implementation of Rethinking Graph Neural Architecture Search from Message-passing (CVPR2021)

Rethinking Graph Neural Architecture Search from Message-passing Intro The GNAS can automatically learn better architecture with the optimal depth of

Shaofei Cai 48 Sep 30, 2022
ICON: Implicit Clothed humans Obtained from Normals (CVPR 2022)

ICON: Implicit Clothed humans Obtained from Normals Yuliang Xiu · Jinlong Yang · Dimitrios Tzionas · Michael J. Black CVPR 2022 News 🚩 [2022/04/26] H

Yuliang Xiu 1.1k Jan 04, 2023
A Shading-Guided Generative Implicit Model for Shape-Accurate 3D-Aware Image Synthesis

A Shading-Guided Generative Implicit Model for Shape-Accurate 3D-Aware Image Synthesis Figure: Shape-Accurate 3D-Aware Image Synthesis. A Shading-Guid

Xingang Pan 115 Dec 18, 2022
The codes and related files to reproduce the results for Image Similarity Challenge Track 2.

The codes and related files to reproduce the results for Image Similarity Challenge Track 2.

Wenhao Wang 89 Jan 02, 2023