Skip to content

Traditional Chinese card game with 3 AI agents. Implemented in Python and structured in the way like the Berkely Pacman.

Notifications You must be signed in to change notification settings

20CS181/LandlordOff

Repository files navigation

Landlord Off

This project is the final for the CS181: Artificial Intelligence @Shanghaitech, completely from scratch.

Landlord Off, or Dou Di Zhu(斗地主), is a popular card game in China, especially during the Chinese Lunar New Year. We implemented the card game interactions with three computer agents, including a random agent and two AI agent, and one human agent, through which one could play with a computer agent or a human as well. The improved AI agent turned out to achieve an outcome of 18% rise in the winning rate. You could access our Documents here, containing a final report and presentation slides.

The code structure referred to our homework, the Pacman Games borrowed from the CS188 course at UC Berkeley. It turned out so simple and elegant with OOP game developing with Python and we love it!

References:

As a start, we read docs linked below for refrences, but didn't copy any. The final version borrows some scoring strategies from an old Chinese card book.

Plan before 1st pre

  1. Pokers delivery in random.
  2. Legal potions.
  3. Winner judgement.

Agents

(last updated: 12/12, 2020)

in HumanAgent.py:

claim class Agent, class HumanAgent. (utils.py, play.py用来测试HumanAgent)

in AIagent.py:

A normal AI_agent randomly puts cards

Game playing

in main.py:

the main process to play game.

in game.py:

some necessary class and function of the GameState

Play the Game

  • To play the game, run main.py.
  • For the rules, there are 10 legal card types:('a''b' in range(3, 10), 'x''X' are two kings, no joker)
  1. dan_pai: ['a']
  2. two same: ['a','a']
  3. three same ['a','a','a']
  4. three_plus_one ['a','a','a','b']
  5. three_plus_two ['a','a','a','b','b']
  6. dan_lian ['a','b','c']
  7. er_lian ['a','a','b','b']
  8. san_lian ['a','a','a','b','b','b']
  9. bomb: ['a','a','a','a']
  10. king bomb: ['x','X']
  • 6\7\8 are shun_zi, which we don't have a strict constraint, so please be nice to ai.

About

Traditional Chinese card game with 3 AI agents. Implemented in Python and structured in the way like the Berkely Pacman.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages