An agent for the game "FightTheLandlord" (a.k.a. Doudizhu) implemented with Recursive Hand Cards Partition algorithm and Reinforcement Learning improvements. This is written by Songchen Tan, Shang Liu and Keer Zhang to participate in the 13th Peking University Game Contest. See an introduction of this game at http://www.botzone.org/games#FightThelandlord2.
- Clone this repository;
- Make sure you have
cmake >= 3.20installed; - Build with
mkdir build && cd build && cmake .. && cmake --build ., and depending on your compiler choice, you may need option likecmake .. -D CMAKE_CXX_COMPILER=g++; - Run tests with
ctest; - Run main program with
./main.
base.handbase.cppcontains definitions of basic data structures likeCard,CounterandHand;strategy.handstrategy.cppcontains the core workflow of the RHCP (Recursive Hand Card Partitioning) algorithm, in terms of functionsattack,defendandevaluate;- To make developing and testing convenient, the
attack(actively playing cards with no prior hands) as well as thedefend(passively playing cards with prior hands) are divided in to several stages; - In each stage, a selector tries to find an optimal hand that is of some particular category; if it cannot find such a hand, it raises
not_foundand the algorithm moves to the next stage; - For example, in the
defendfunction, one may first try to beat the previous hand with a bigger hand of the same category; if not found, then try to beat the previous hand with Bomb or Rocker; if not found, then pass. - The selectors share the same interface, namely
AttackingSelectorandDefendingSelector, and several possible selectors are implemented in thestrategysubfolder.
- To make developing and testing convenient, the
environment.handenvironment.cppcontains the game playing environment, and they are mostly copied from BotZone; as a result, they are not advised to be modified;main.cppspecifies the strategy with global pointers and launch the game.
base.cppcontains basic tests for definitions insrc/base.h;main.cppserves as the entry point forCatch2and launch all tests.