基于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)
Towards Representation Learning for Atmospheric Dynamics (AtmoDist)

Towards Representation Learning for Atmospheric Dynamics (AtmoDist) The prediction of future climate scenarios under anthropogenic forcing is critical

Sebastian Hoffmann 4 Dec 15, 2022
RetinaFace: Deep Face Detection Library in TensorFlow for Python

RetinaFace is a deep learning based cutting-edge facial detector for Python coming with facial landmarks.

Sefik Ilkin Serengil 512 Dec 29, 2022
Data Engineering ZoomCamp

Data Engineering ZoomCamp I'm partaking in a Data Engineering Bootcamp / Zoomcamp and will be tracking my progress here. I can't promise these notes w

Aaron 61 Jan 06, 2023
Prml - Repository of notes, code and notebooks in Python for the book Pattern Recognition and Machine Learning by Christopher Bishop

Pattern Recognition and Machine Learning (PRML) This project contains Jupyter notebooks of many the algorithms presented in Christopher Bishop's Patte

Gerardo Durán-Martín 1k Jan 07, 2023
Public scripts, services, and configuration for running a smart home K3S network cluster

makerhouse_network Public scripts, services, and configuration for running MakerHouse's home network. This network supports: TODO features here For mo

Scott Martin 1 Jan 15, 2022
The pyrelational package offers a flexible workflow to enable active learning with as little change to the models and datasets as possible

pyrelational is a python active learning library developed by Relation Therapeutics for rapidly implementing active learning pipelines from data management, model development (and Bayesian approximat

Relation Therapeutics 95 Dec 27, 2022
DANet for Tabular data classification/ regression.

Deep Abstract Networks A PyTorch code implemented for the submission DANets: Deep Abstract Networks for Tabular Data Classification and Regression. Do

Ronnie Rocket 55 Sep 14, 2022
code for ICCV 2021 paper 'Generalized Source-free Domain Adaptation'

G-SFDA Code (based on pytorch 1.3) for our ICCV 2021 paper 'Generalized Source-free Domain Adaptation'. [project] [paper]. Dataset preparing Download

Shiqi Yang 84 Dec 26, 2022
This is the official PyTorch implementation of our paper: "Artistic Style Transfer with Internal-external Learning and Contrastive Learning".

Artistic Style Transfer with Internal-external Learning and Contrastive Learning This is the official PyTorch implementation of our paper: "Artistic S

51 Dec 20, 2022
Project ArXiv Citation Network

Project ArXiv Citation Network Overview This project involved the analysis of the ArXiv citation network. Usage The complete code of this project is i

Dennis Núñez-Fernández 5 Oct 20, 2022
1st Solution For ICDAR 2021 Competition on Mathematical Formula Detection

This project releases our 1st place solution on ICDAR 2021 Competition on Mathematical Formula Detection. We implement our solution based on MMDetection, which is an open source object detection tool

yuxzho 94 Dec 25, 2022
Code to reproduce the experiments from our NeurIPS 2021 paper " The Limitations of Large Width in Neural Networks: A Deep Gaussian Process Perspective"

Code To run: python runner.py new --save SAVE_NAME --data PATH_TO_DATA_DIR --dataset DATASET --model model_name [options] --n 1000 - train - t

Geoff Pleiss 5 Dec 12, 2022
Train an RL agent to execute natural language instructions in a 3D Environment (PyTorch)

Gated-Attention Architectures for Task-Oriented Language Grounding This is a PyTorch implementation of the AAAI-18 paper: Gated-Attention Architecture

Devendra Chaplot 234 Nov 05, 2022
This repo is about to create the Streamlit application for given ML model.

HR-Attritiion-using-Streamlit This repo is about to create the Streamlit application for given ML model. Problem Statement: Managing peoples at workpl

Pavan Giri 0 Dec 10, 2021
An Industrial Grade Federated Learning Framework

DOC | Quick Start | 中文 FATE (Federated AI Technology Enabler) is an open-source project initiated by Webank's AI Department to provide a secure comput

Federated AI Ecosystem 4.8k Jan 09, 2023
[ICCV 2021] Target Adaptive Context Aggregation for Video Scene Graph Generation

Target Adaptive Context Aggregation for Video Scene Graph Generation This is a PyTorch implementation for Target Adaptive Context Aggregation for Vide

Multimedia Computing Group, Nanjing University 44 Dec 14, 2022
Implement Decoupled Neural Interfaces using Synthetic Gradients in Pytorch

disclaimer: this code is modified from pytorch-tutorial Image classification with synthetic gradient in Pytorch I implement the Decoupled Neural Inter

Andrew 114 Dec 22, 2022
Repository for publicly available deep learning models developed in Rosetta community

trRosetta2 This package contains deep learning models and related scripts used by Baker group in CASP14. Installation Linux/Mac clone the package git

81 Dec 29, 2022
A Partition Filter Network for Joint Entity and Relation Extraction EMNLP 2021

EMNLP 2021 - A Partition Filter Network for Joint Entity and Relation Extraction

zhy 127 Jan 04, 2023
Enhancing Column Generation by a Machine-Learning-BasedPricing Heuristic for Graph Coloring

Enhancing Column Generation by a Machine-Learning-BasedPricing Heuristic for Graph Coloring (to appear at AAAI 2022) We propose a machine-learning-bas

YunzhuangS 2 May 02, 2022