File size: 1,302 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 |
import pytest
from zoo.board_games.go.envs.go_env import GoEnv
@pytest.mark.envtest
class TestGoEnv:
def test_naive(self):
env = GoEnv(board_size=9, komi=7.5)
print('NOTE:actions are counted by column, such as action 9, which is the second column and the first row')
env.reset()
# env.render()
for i in range(100):
"""player 1"""
# action = env.human_to_action()
action = env.random_action()
print('player 1 (black_0): ', action)
obs, reward, done, info = env.step(action)
assert isinstance(obs, dict)
assert isinstance(done, bool)
assert isinstance(reward, float)
# env.render()
if done:
if reward > 0:
print('player 1 (black_0) win')
else:
print('draw')
break
"""player 2"""
action = env.random_action()
print('player 2 (white_0): ', action)
obs, reward, done, info = env.step(action)
# env.render()
if done:
if reward > 0:
print('player 2 (white_0) win')
else:
print('draw')
break
|