Skip to content

Commit

Permalink
Add additional test for corner cases in "bounce"
Browse files Browse the repository at this point in the history
  • Loading branch information
jojolebarjos committed May 11, 2024
1 parent 37205cd commit 6372d79
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/test_bounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,69 @@ def test_sequence():
assert len(state.actions) == 0
assert state.winner == 0
assert state.reward.tolist() == [1, -1]


def test_larger_values():
state, action = assert_state(
"""
[*]
1 . . * . *
. . * . * .
. * . * . *
* . * . * .
. * . * . *
* . * . * .
. . . .[7].
.
""",
)
state = action.sample_next_state()

assert state.has_ended
assert len(state.actions) == 0
assert state.winner == 0
assert state.reward.tolist() == [1, -1]


def test_block_victory():
state, action = assert_state(
"""
.
1 . * .[2].
. . . * . *
2 2 2 2[*]2
3 . 3 . 3 .
. . . . . .
. . . . . .
. . . . . .
.
""",
)
state = action.sample_next_state()

assert state.has_ended
assert len(state.actions) == 0
assert state.winner == 1
assert state.reward.tolist() == [-1, 1]


def test_draw():
state, action = assert_state(
"""
.
. . . . . .
2 2 2 2 2 2
3 3 3 3 3 3
3 .[*]. 3 .
. * . * . .
* . * . * .
. .[3]. . *
.
""",
)
state = action.sample_next_state()

assert state.has_ended
assert len(state.actions) == 0
assert state.winner is None
assert state.reward.tolist() == [0, 0]

0 comments on commit 6372d79

Please sign in to comment.