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!
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.
- Pokers delivery in random.
- Legal potions.
- Winner judgement.
(last updated: 12/12, 2020)
claim class Agent
, class HumanAgent
.
(utils.py
, play.py
用来测试HumanAgent
)
A normal AI_agent randomly puts cards
the main process to play game.
some necessary class and function of the GameState
- 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)
- dan_pai: ['a']
- two same: ['a','a']
- three same ['a','a','a']
- three_plus_one ['a','a','a','b']
- three_plus_two ['a','a','a','b','b']
- dan_lian ['a','b','c']
- er_lian ['a','a','b','b']
- san_lian ['a','a','a','b','b','b']
- bomb: ['a','a','a','a']
- king bomb: ['x','X']
- 6\7\8 are
shun_zi
, which we don't have a strict constraint, so please be nice to ai.