File size: 1,265 Bytes
079c32c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import pytest
from zoo.board_games.chess.envs.chess_env import ChessEnv
@pytest.mark.envtest
class TestChessEnv:
def test_naive(self):
env = ChessEnv()
env.reset()
print('init board state: ')
env.render()
for i in range(100):
"""player 1"""
# action = env.human_to_action()
action = env.random_action()
print('player 1: ', action)
obs, reward, done, info = env.step(action)
assert isinstance(obs, dict)
assert isinstance(done, bool)
assert isinstance(reward, int)
# env.render()
if done:
if done:
if reward > 0:
print('player 1 (human player) win')
else:
print('draw')
break
"""player 2"""
action = env.random_action()
print('player 2 (computer player): ', action)
obs, reward, done, info = env.step(action)
# env.render()
if done:
if reward > 0:
print('player 2 (computer player) win')
else:
print('draw')
break
|