datamllab / rlcard

Reinforcement Learning / AI Bots in Card (Poker) Games - Blackjack, Leduc, Texas, DouDizhu, Mahjong, UNO.
http://www.rlcard.org
MIT License
2.87k stars 619 forks source link

Uno game: fix wild card color assignment; fix typos #278

Closed kaiks closed 1 year ago

kaiks commented 1 year ago

Right now the wild card color gets assigned randomly when it gets drawn from the deck:

        # draw a wild card
        if card.type == 'wild':
            card.color = self.np_random.choice(UnoCard.info['color'])

and the player is then able to pick any wild card color:

                        if wild_flag == 0:
                            wild_flag = 1
                            legal_actions.extend(WILD)

however, whatever color the player picks, the original random card color gets played. This PR fixes the problem by changing the card color during action execution.

This also makes the dqn training more effective against the random agent. Previous results:

0 experiments/uno_dqn_result/model.pth 0.0174
1 random -0.0174

After the change:

--> Running on the CPU
0 experiments/uno_dqn_result/model.pth 0.0294
1 random -0.0294
daochenzha commented 1 year ago

@kaiks LGTM! Thank you for the fix!