kubn cfr:0
This commit is contained in:
51
tests/test_game.py
Normal file
51
tests/test_game.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from src.game.kuhn_poker import KuhnPoker
|
||||
|
||||
def test_game():
|
||||
game = KuhnPoker()
|
||||
test_histories = ['', '0', '1', '00', '10', '01', '011', '010', '11']
|
||||
for his in test_histories:
|
||||
terminal = game.is_terminal(his)
|
||||
player = game.get_cur_player(his)
|
||||
print(f"'{his}' - teminal: {terminal}, player: {player}")
|
||||
|
||||
test_cases = [
|
||||
(['K', 'J'], '00', 0),
|
||||
(['J', 'K'], '00', 0),
|
||||
(['Q', 'J'], '10', 0),
|
||||
(['J', 'Q'], '010', 0),
|
||||
(['K', 'J'], '11', 0),
|
||||
(['J', 'Q'], '11', 0),
|
||||
(['Q', 'K'], '011', 1),
|
||||
]
|
||||
for cards, his, player in test_cases:
|
||||
profit = game.get_profit(cards, his, player)
|
||||
print(f"player{player}profit: {profit}")
|
||||
|
||||
info_cases = [
|
||||
('K', '0', 0),
|
||||
('J', '01', 1),
|
||||
('Q', '', 0),
|
||||
]
|
||||
|
||||
for card, his, player in info_cases:
|
||||
info_set = game.get_Info_set(card, his, player)
|
||||
print(f"card:{card}, his:'{his}', palyer{player} -> infoset: '{info_set}'")
|
||||
|
||||
print(f"valid act: {game.get_valid_act('00')}")
|
||||
|
||||
test_seq = ['00', '10', '01', '010', '011', '11']
|
||||
|
||||
for seq in test_seq:
|
||||
terminal = game.is_terminal(seq)
|
||||
if terminal:
|
||||
print(f" '{seq}' terminal")
|
||||
else:
|
||||
current_player = game.get_cur_player(seq)
|
||||
print(f" '{seq}' not terminal, cur player: {current_player}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_game()
|
||||
Reference in New Issue
Block a user