Skip to content

Commit 187e683

Browse files
committed
fix testing
1 parent 6de975c commit 187e683

File tree

8 files changed

+41
-62
lines changed

8 files changed

+41
-62
lines changed

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# RLCard: A Toolkit for Reinforcement Learning in Card Games
22
<img width="500" src="https://dczha.com/files/rlcard/logo.jpg" alt="Logo" />
33

4-
[![Build Status](https://travis-ci.org/datamllab/RLCard.svg?branch=master)](https://travis-ci.org/datamllab/RLCard)
5-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/248eb15c086748a4bcc830755f1bd798)](https://www.codacy.com/manual/daochenzha/rlcard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=datamllab/rlcard&amp;utm_campaign=Badge_Grade)
4+
[![Testing](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml/badge.svg)](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml)
5+
[![PyPI version](https://badge.fury.io/py/rlcard.svg)](https://badge.fury.io/py/rlcard)
66
[![Coverage Status](https://coveralls.io/repos/github/datamllab/rlcard/badge.svg)](https://coveralls.io/github/datamllab/rlcard?branch=master)
77
[![Downloads](https://pepy.tech/badge/rlcard)](https://pepy.tech/project/rlcard)
88
[![Downloads](https://pepy.tech/badge/rlcard/month)](https://pepy.tech/project/rlcard)
9+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
910

1011
[中文文档](README.zh-CN.md)
1112

@@ -24,8 +25,7 @@ RLCard is a toolkit for Reinforcement Learning (RL) in card games. It supports m
2425
* **QQ Group**: Join our QQ group 665647450. Password: rlcardqqgroup
2526

2627
**News:**
27-
* All the algorithms can suppport [PettingZoo](https://github.com/PettingZoo-Team/PettingZoo) now. Please check [here](examples/pettingzoo). Thanks the contribtuion from [
28-
Yifei Cheng](https://github.com/ycheng517).
28+
* All the algorithms can suppport [PettingZoo](https://github.com/PettingZoo-Team/PettingZoo) now. Please check [here](examples/pettingzoo). Thanks the contribtuion from [Yifei Cheng](https://github.com/ycheng517).
2929
* Please follow [DouZero](https://github.com/kwai/DouZero), a strong Dou Dizhu AI and the [ICML 2021 paper](https://arxiv.org/abs/2106.06135). An online demo is available [here](https://douzero.org/). The algorithm is also integrated in RLCard. See [Training DMC on Dou Dizhu](docs/toy-examples.md#training-dmc-on-dou-dizhu).
3030
* Our package is used in [PettingZoo](https://github.com/PettingZoo-Team/PettingZoo). Please check it out!
3131
* We have released RLCard-Showdown, GUI demo for RLCard. Please check out [here](https://github.com/datamllab/rlcard-showdown)!

README.zh-CN.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# RLCard: 卡牌游戏强化学习工具包
22
<img width="500" src="https://dczha.com/files/rlcard/logo.jpg" alt="Logo" />
33

4-
[![Build Status](https://travis-ci.org/datamllab/RLCard.svg?branch=master)](https://travis-ci.org/datamllab/RLCard)
5-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/248eb15c086748a4bcc830755f1bd798)](https://www.codacy.com/manual/daochenzha/rlcard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=datamllab/rlcard&amp;utm_campaign=Badge_Grade)
4+
[![Testing](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml/badge.svg)](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml)
5+
[![PyPI version](https://badge.fury.io/py/rlcard.svg)](https://badge.fury.io/py/rlcard)
66
[![Coverage Status](https://coveralls.io/repos/github/datamllab/rlcard/badge.svg)](https://coveralls.io/github/datamllab/rlcard?branch=master)
77
[![Downloads](https://pepy.tech/badge/rlcard)](https://pepy.tech/project/rlcard)
88
[![Downloads](https://pepy.tech/badge/rlcard/month)](https://pepy.tech/project/rlcard)
9+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
910

1011
[English README](README.md)
1112

@@ -24,6 +25,7 @@ RLCard是一款卡牌游戏强化学习 (Reinforcement Learning, RL) 的工具
2425
* **QQ群**: 加入我们的QQ群665647450. 密码:rlcardqqgroup
2526

2627
**新闻:**
28+
* 所有的算法都已支持[PettingZoo](https://github.com/PettingZoo-Team/PettingZoo)接口. 请点击[这里](examples/pettingzoo). 感谢[Yifei Cheng](https://github.com/ycheng517)的贡献。
2729
* 请关注[DouZero](https://github.com/kwai/DouZero), 一个强大的斗地主AI,以及[ICML 2021论文](https://arxiv.org/abs/2106.06135)。点击[此处](https://douzero.org/)进入在线演示。该算法同样集成到了RLCard中,详见[在斗地主中训练DMC](docs/toy-examples.md#training-dmc-on-dou-dizhu)
2830
* 我们的项目被用在[PettingZoo](https://github.com/PettingZoo-Team/PettingZoo)中,去看看吧!
2931
* 我们发布了RLCard的可视化演示项目:RLCard-Showdown。请点击[此处](https://github.com/datamllab/rlcard-showdown)查看详情!
@@ -111,6 +113,7 @@ RLCard可以灵活地连接各种算法,参考以下例子:
111113
* [与预训练Leduc模型游玩](docs/toy-examples.md#having-fun-with-pretrained-leduc-model)
112114
* [在斗地主上训练DMC](docs/toy-examples.md#training-dmc-on-dou-dizhu)
113115
* [评估智能体](docs/toy-examples.md#evaluating-agents)
116+
* [在PettingZoo上训练](examples/pettingzoo)
114117

115118
## 演示
116119

rlcard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name = "rlcard"
2-
__version__ = "1.0.5"
2+
__version__ = "1.0.6"
33

44
from rlcard.envs import make

rlcard/games/blackjack/dealer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def deal_card(self, player):
2929
Args:
3030
player_id (int): the target player's id
3131
'''
32-
idx = np.random.choice(len(self.deck))
32+
idx = self.np_random.choice(len(self.deck))
3333
card = self.deck[idx]
3434
if self.num_decks != 0: # If infinite decks, do not pop card from deck
3535
self.deck.pop(idx)

tests/envs/test_nolimitholdem_env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_decode_action(self):
3535

3636
env.step(0)
3737
decoded = env._decode_action(1)
38-
self.assertEqual(decoded, Action.CHECK)
38+
self.assertEqual(decoded, Action.CHECK_CALL)
3939

4040
def test_step(self):
4141
env = rlcard.make('no-limit-holdem')
@@ -79,13 +79,13 @@ def test_multiplayers(self):
7979
self.assertEqual(num_players, 5)
8080

8181
def test_config_chips(self):
82-
env = rlcard.make('no-limit-holdem', config={'game_num_players':5, 'chips_for_each':[100, 200, 400, 600, 900]})
82+
env = rlcard.make('no-limit-holdem', config={'game_num_players':5, 'chips_for_each':100})
8383
env.game.init_game()
8484
players = env.game.players
8585
chips = []
8686
for i in range(5):
8787
chips.append(players[i].remained_chips + players[i].in_chips)
88-
self.assertEqual(chips, [100, 200, 400, 600, 900])
88+
self.assertEqual(chips, [100, 100, 100, 100, 100])
8989

9090
if __name__ == '__main__':
9191
unittest.main()

tests/games/test_nolimitholdem_game.py

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_step(self):
2222
# test call
2323
game.init_game()
2424
init_not_raise_num = game.round.not_raise_num
25-
game.step(Action.CALL)
25+
game.step(Action.CHECK_CALL)
2626
step_not_raise_num = game.round.not_raise_num
2727
self.assertEqual(init_not_raise_num + 1, step_not_raise_num)
2828

@@ -34,9 +34,7 @@ def test_step(self):
3434

3535
# test check
3636
game.init_game()
37-
game.step(Action.CALL)
38-
game.step(Action.CHECK)
39-
self.assertEqual(game.round_counter, 1)
37+
game.step(Action.CHECK_CALL)
4038

4139
def test_bet_more_than_chips(self):
4240
game = Game()
@@ -57,17 +55,17 @@ def test_step_2(self):
5755
# test check
5856
game.init_game()
5957
self.assertEqual(Stage.PREFLOP, game.stage)
60-
game.step(Action.CALL)
58+
game.step(Action.CHECK_CALL)
6159
game.step(Action.RAISE_POT)
62-
game.step(Action.CALL)
60+
game.step(Action.CHECK_CALL)
6361

6462
self.assertEqual(Stage.FLOP, game.stage)
65-
game.step(Action.CHECK)
66-
game.step(Action.CHECK)
63+
game.step(Action.CHECK_CALL)
64+
game.step(Action.CHECK_CALL)
6765

6866
self.assertEqual(Stage.TURN, game.stage)
69-
game.step(Action.CHECK)
70-
game.step(Action.CHECK)
67+
game.step(Action.CHECK_CALL)
68+
game.step(Action.CHECK_CALL)
7169

7270
self.assertEqual(Stage.RIVER, game.stage)
7371

@@ -77,22 +75,22 @@ def test_step_3_players(self):
7775
# test check
7876
_, first_player_id = game.init_game()
7977
self.assertEqual(Stage.PREFLOP, game.stage)
80-
game.step(Action.CALL)
81-
game.step(Action.CALL)
78+
game.step(Action.CHECK_CALL)
79+
game.step(Action.CHECK_CALL)
8280
game.step(Action.RAISE_POT)
8381
game.step(Action.FOLD)
84-
game.step(Action.CALL)
82+
game.step(Action.CHECK_CALL)
8583

8684
self.assertEqual(Stage.FLOP, game.stage)
8785
self.assertEqual((first_player_id - 2) % 3, game.round.game_pointer)
88-
game.step(Action.CHECK)
86+
game.step(Action.CHECK_CALL)
8987
game.step(Action.RAISE_POT)
90-
game.step(Action.CALL)
88+
game.step(Action.CHECK_CALL)
9189

9290
self.assertEqual(Stage.TURN, game.stage)
9391
self.assertEqual((first_player_id - 2) % 3, game.round.game_pointer)
94-
game.step(Action.CHECK)
95-
game.step(Action.CHECK)
92+
game.step(Action.CHECK_CALL)
93+
game.step(Action.CHECK_CALL)
9694

9795
self.assertEqual(Stage.RIVER, game.stage)
9896

@@ -102,7 +100,7 @@ def test_auto_step(self):
102100
game.init_game()
103101
self.assertEqual(Stage.PREFLOP, game.stage)
104102
game.step(Action.ALL_IN)
105-
game.step(Action.CALL)
103+
game.step(Action.CHECK_CALL)
106104

107105
self.assertEqual(Stage.RIVER, game.stage)
108106

@@ -120,24 +118,17 @@ def test_all_in_rounds(self):
120118
game = Game()
121119

122120
game.init_game()
123-
game.step(Action.CALL)
124-
game.step(Action.CHECK)
121+
game.step(Action.CHECK_CALL)
122+
game.step(Action.CHECK_CALL)
125123
self.assertEqual(game.round_counter, 1)
126-
self.assertTrue(Action.CALL not in game.get_legal_actions())
127124

128-
game.step(Action.CHECK)
125+
game.step(Action.CHECK_CALL)
129126
game.step(Action.ALL_IN)
130-
self.assertListEqual([Action.FOLD, Action.CALL], game.get_legal_actions())
131-
game.step(Action.CALL)
127+
self.assertListEqual([Action.FOLD, Action.CHECK_CALL], game.get_legal_actions())
128+
game.step(Action.CHECK_CALL)
132129
self.assertEqual(game.round_counter, 4)
133130
self.assertEqual(200, game.dealer.pot)
134131

135-
def test_wrong_steps(self):
136-
game = Game()
137-
138-
game.init_game()
139-
self.assertRaises(Exception, game.step, Action.CHECK)
140-
141132
def test_raise_pot(self):
142133
game = Game()
143134

@@ -156,7 +147,7 @@ def test_raise_pot(self):
156147
step_raised = game.round.raised[player_id]
157148
self.assertEqual(16, step_raised)
158149

159-
game.step(Action.CALL)
150+
game.step(Action.CHECK_CALL)
160151
player_id = game.round.game_pointer
161152
game.step(Action.RAISE_POT)
162153
step_raised = game.round.raised[player_id]
@@ -167,7 +158,7 @@ def test_raise_half_pot(self):
167158

168159
_, player_id = game.init_game()
169160
self.assertNotIn(Action.RAISE_HALF_POT, game.get_legal_actions()) # Half pot equals call
170-
game.step(Action.CALL)
161+
game.step(Action.CHECK_CALL)
171162
step_raised = game.round.raised[player_id]
172163
self.assertEqual(2, step_raised)
173164

@@ -184,7 +175,7 @@ def test_raise_half_pot(self):
184175
def test_payoffs_1(self):
185176
game = Game()
186177
game.init_game()
187-
game.step(Action.CALL)
178+
game.step(Action.CHECK_CALL)
188179
game.step(Action.RAISE_HALF_POT)
189180
game.step(Action.FOLD)
190181
self.assertTrue(game.is_over())
@@ -195,7 +186,7 @@ def test_payoffs_2(self):
195186
game = Game()
196187
np.random.seed(0)
197188
game.init_game()
198-
game.step(Action.CALL)
189+
game.step(Action.CHECK_CALL)
199190
game.step(Action.RAISE_POT)
200191
game.step(Action.ALL_IN)
201192
game.step(Action.FOLD)
@@ -208,9 +199,9 @@ def test_all_in_to_call(self):
208199
game.init_chips = [50, 100]
209200
game.dealer_id = 0
210201
game.init_game()
211-
game.step(Action.CALL)
202+
game.step(Action.CHECK_CALL)
212203
game.step(Action.ALL_IN)
213-
game.step(Action.CALL)
204+
game.step(Action.CHECK_CALL)
214205
self.assertTrue(game.is_over())
215206

216207

tests/utils/test_logger.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def test_log(self):
1515
logger.log_performance(1, 1)
1616
logger.log_performance(2, 2)
1717
logger.log_performance(3, 3)
18-
logger.plot('aaa')
1918

2019
if __name__ == '__main__':
2120
unittest.main()

0 commit comments

Comments
 (0)