基于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)
ML models implementation practice

Let's implement various ML algorithms with numpy/tf Vanilla Neural Network https://towardsdatascience.com/lets-code-a-neural-network-in-plain-numpy-ae

Jinsoo Heo 4 Jul 04, 2021
PyTorch - Python + Nim

Master Release Pytorch - Py + Nim A Nim frontend for pytorch, aiming to be mostly auto-generated and internally using ATen. Because Nim compiles to C+

Giovanni Petrantoni 425 Dec 22, 2022
Implement slightly different caffe-segnet in tensorflow

Tensorflow-SegNet Implement slightly different (see below for detail) SegNet in tensorflow, successfully trained segnet-basic in CamVid dataset. Due t

Tseng Kuan Lun 364 Oct 27, 2022
A collection of models for image<->text generation in ACM MM 2021.

Bi-directional Image and Text Generation UMT-BITG (image & text generator) Unifying Multimodal Transformer for Bi-directional Image and Text Generatio

Multimedia Research 63 Oct 30, 2022
The-Secret-Sharing-Schemes - This interactive script demonstrates the Secret Sharing Schemes algorithm

The-Secret-Sharing-Schemes This interactive script demonstrates the Secret Shari

Nishaant Goswamy 1 Jan 02, 2022
Label Hallucination for Few-Shot Classification

Label Hallucination for Few-Shot Classification This repo covers the implementation of the following paper: Label Hallucination for Few-Shot Classific

Yiren Jian 13 Nov 13, 2022
Code associated with the paper "Deep Optics for Single-shot High-dynamic-range Imaging"

Deep Optics for Single-shot High-dynamic-range Imaging Code associated with the paper "Deep Optics for Single-shot High-dynamic-range Imaging" CVPR, 2

Stanford Computational Imaging Lab 40 Dec 12, 2022
The repository is for safe reinforcement learning baselines.

Safe-Reinforcement-Learning-Baseline The repository is for Safe Reinforcement Learning (RL) research, in which we investigate various safe RL baseline

172 Dec 19, 2022
An automated facial recognition based attendance system (desktop application)

Facial_Recognition_based_Attendance_System An automated facial recognition based attendance system (desktop application) Made using Python, Tkinter an

1 Jun 21, 2022
A new benchmark for Icon Question Answering (IconQA) and a large-scale icon dataset Icon645.

IconQA About IconQA is a new diverse abstract visual question answering dataset that highlights the importance of abstract diagram understanding and c

Pan Lu 24 Dec 30, 2022
Doubly Robust Off-Policy Evaluation for Ranking Policies under the Cascade Behavior Model

Doubly Robust Off-Policy Evaluation for Ranking Policies under the Cascade Behavior Model About This repository contains the code to replicate the syn

Haruka Kiyohara 12 Dec 07, 2022
Implementation of the Point Transformer layer, in Pytorch

Point Transformer - Pytorch Implementation of the Point Transformer self-attention layer, in Pytorch. The simple circuit above seemed to have allowed

Phil Wang 501 Jan 03, 2023
Notspot robot simulation - Python version

Notspot robot simulation - Python version This repository contains all the files and code needed to simulate the notspot quadrupedal robot using Gazeb

50 Sep 26, 2022
Baseline for the Spoofing-aware Speaker Verification Challenge 2022

Introduction This repository contains several materials that supplements the Spoofing-Aware Speaker Verification (SASV) Challenge 2022 including: calc

40 Dec 28, 2022
CoTr: Efficiently Bridging CNN and Transformer for 3D Medical Image Segmentation

CoTr: Efficient 3D Medical Image Segmentation by bridging CNN and Transformer This is the official pytorch implementation of the CoTr: Paper: CoTr: Ef

218 Dec 25, 2022
Monify: an Expense tracker Program implemented in a Graphical User Interface that allows users to keep track of their expenses

💳 MONIFY (EXPENSE TRACKER PRO) 💳 Description Monify is an Expense tracker Program implemented in a Graphical User Interface allows users to add inco

Moyosore Weke 1 Dec 14, 2021
A way to store images in YAML.

YAMLImg A way to store images in YAML. I made this after seeing Roadcrosser's JSON-G because it was too inspiring to ignore this opportunity. Installa

5 Mar 14, 2022
Multi-Scale Geometric Consistency Guided Multi-View Stereo

ACMM [News] The code for ACMH is released!!! [News] The code for ACMP is released!!! About ACMM is a multi-scale geometric consistency guided multi-vi

Qingshan Xu 118 Jan 04, 2023
Code for the paper One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation, CVPR 2021.

One Thing One Click One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation (CVPR2021) Code for the paper One Thi

44 Dec 12, 2022
A simple root calculater for python

Root A simple root calculater Usage/Examples python3 root.py 9 3 4 # Order: number - grid - number of decimals # Output: 2.08

Reza Hosseinzadeh 5 Feb 10, 2022