基于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)
利用python脚本实现微信、支付宝账单的合并,并保存到excel文件实现自动记账,可查看可视化图表。

KeepAccounts_v2.0 KeepAccounts.exe和其配套表格能够实现微信、支付宝官方导出账单的读取合并,为每笔帐标记类型,并按月份和类型生成可视化图表。再也不用消费一笔记一笔,每月仅需10分钟,记好所有的帐。 作者: MickLife Bilibili: https://spac

159 Jan 01, 2023
Direct Multi-view Multi-person 3D Human Pose Estimation

Implementation of NeurIPS-2021 paper: Direct Multi-view Multi-person 3D Human Pose Estimation [paper] [video-YouTube, video-Bilibili] [slides] This is

Sea AI Lab 251 Dec 30, 2022
Modular Probabilistic Programming on MXNet

MXFusion | | | | Tutorials | Documentation | Contribution Guide MXFusion is a modular deep probabilistic programming library. With MXFusion Modules yo

Amazon 100 Dec 10, 2022
This repository provides a PyTorch implementation and model weights for HCSC (Hierarchical Contrastive Selective Coding)

HCSC: Hierarchical Contrastive Selective Coding This repository provides a PyTorch implementation and model weights for HCSC (Hierarchical Contrastive

YUANFAN GUO 111 Dec 20, 2022
A motion detection system with RaspberryPi, OpenCV, Python

Human Detection System using Raspberry Pi Functionality Activates a relay on detecting motion. You may need following components to get the expected R

Omal Perera 55 Dec 04, 2022
Node for thenewboston digital currency network.

Project setup For project setup see INSTALL.rst Community Join the community to stay updated on the most recent developments, project roadmaps, and ra

thenewboston 27 Jul 08, 2022
Meta Learning for Semi-Supervised Few-Shot Classification

few-shot-ssl-public Code for paper Meta-Learning for Semi-Supervised Few-Shot Classification. [arxiv] Dependencies cv2 numpy pandas python 2.7 / 3.5+

Mengye Ren 501 Jan 08, 2023
Storchastic is a PyTorch library for stochastic gradient estimation in Deep Learning

Storchastic is a PyTorch library for stochastic gradient estimation in Deep Learning

Emile van Krieken 140 Dec 30, 2022
Code repository of the paper Neural circuit policies enabling auditable autonomy published in Nature Machine Intelligence

Neural Circuit Policies Enabling Auditable Autonomy Online access via SharedIt Neural Circuit Policies (NCPs) are designed sparse recurrent neural net

8 Jan 07, 2023
Few-shot NLP benchmark for unified, rigorous eval

FLEX FLEX is a benchmark and framework for unified, rigorous few-shot NLP evaluation. FLEX enables: First-class NLP support Support for meta-training

AI2 85 Dec 03, 2022
Image-based Navigation in Real-World Environments via Multiple Mid-level Representations: Fusion Models Benchmark and Efficient Evaluation

Image-based Navigation in Real-World Environments via Multiple Mid-level Representations: Fusion Models Benchmark and Efficient Evaluation This reposi

First Person Vision @ Image Processing Laboratory - University of Catania 1 Aug 21, 2022
PyTorch IPFS Dataset

PyTorch IPFS Dataset IPFSDataset(Dataset) See the jupyter notepad to see how it works and how it interacts with a standard pytorch DataLoader You need

Jake Kalstad 2 Apr 13, 2022
SOTA easy to use PyTorch-based DL training library

Easily train or fine-tune SOTA computer vision models from one training repository. SuperGradients Introduction Welcome to SuperGradients, a free open

619 Jan 03, 2023
Patch-Based Deep Autoencoder for Point Cloud Geometry Compression

Patch-Based Deep Autoencoder for Point Cloud Geometry Compression Overview The ever-increasing 3D application makes the point cloud compression unprec

17 Dec 05, 2022
BERT model training impelmentation using 1024 A100 GPUs for MLPerf Training v1.1

Pre-trained checkpoint and bert config json file Location of checkpoint and bert config json file This MLCommons members Google Drive location contain

SAIT (Samsung Advanced Institute of Technology) 12 Apr 27, 2022
Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow.

Denoised-Smoothing-TF Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow. Denoised Smoothing is

Sayak Paul 19 Dec 11, 2022
Code for ACM MM 2020 paper "NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination"

NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination The offical implementation for the "NOH-NMS: Improving Pedestrian Detection by

Tencent YouTu Research 64 Nov 11, 2022
Team Enigma at ArgMining 2021 Shared Task: Leveraging Pretrained Language Models for Key Point Matching

Team Enigma at ArgMining 2021 Shared Task: Leveraging Pretrained Language Models for Key Point Matching This is our attempt of the shared task on Quan

Manav Nitin Kapadnis 12 Jul 08, 2022
Code base for reproducing results of I.Schubert, D.Driess, O.Oguz, and M.Toussaint: Learning to Execute: Efficient Learning of Universal Plan-Conditioned Policies in Robotics. NeurIPS (2021)

Learning to Execute (L2E) Official code base for completely reproducing all results reported in I.Schubert, D.Driess, O.Oguz, and M.Toussaint: Learnin

3 May 18, 2022
Minimal deep learning library written from scratch in Python, using NumPy/CuPy.

SmallPebble Project status: experimental, unstable. SmallPebble is a minimal/toy automatic differentiation/deep learning library written from scratch

Sidney Radcliffe 92 Dec 30, 2022