def test_uses_standard_board_if_not_added_resilient(self): """ Tests that ResilientPlayer can move if a board is not added """ r = cs.ResilientPlayer() r.move() assert r.position != 0
def test_start_of_chute(self): board = cs.Board() player = cs.ResilientPlayer(board) for step in range(50): player.move() assert player.position not in board.snakes_and_ladders.keys()
def test_position_not_equal_one(self): board = cs.Board() player = cs.ResilientPlayer(board) for _ in range(50): player.move() assert 1 <= player.position
def test_move(self): board = cs.Board() player = cs.ResilientPlayer(board) for _ in range(10): player.move() assert player.number_of_moves == 10
def test_position(self): board = cs.Board() player = cs.ResilientPlayer(board) start_pos = player.position player.move() end_pos = player.position assert start_pos is not end_pos
def test_move(self): """Tests that resilient player moves as it should.""" b = cs.Board() resilient_player = cs.ResilientPlayer(b, extra_steps=5) resilient_player.position = 22 random.seed(1) resilient_player.move() random.seed(1) resilient_player.move() assert resilient_player.position == 12
def test_start_of_chute(self): """Test that the players position can´t be the start point of a snake or a ladder, since the player is supposed to interact with these. """ board = cs.Board() player = cs.ResilientPlayer(board) for step in range(50): player.move() assert player.position not in board.snakes_and_ladders.keys()
def test_move_resilientplayer(self): """ Resilient player can move. """ b = cs.Board() p = cs.ResilientPlayer(b) p.move() assert p.player_position > 0 assert p.player_position not in b.chutes.keys() and b.ladders.keys() position1 = p.player_position p.move() assert p.player_position != position1
def test_resilient_player_got_chute(self): """We test here if the chute and slided in ResilientPlayer(Board()) are functioning""" chute = [5, 3, 30, 37, 27, 12, 70] got_chute, game_ended, position, slided = False, False, 0, False while not got_chute: p = cs.ResilientPlayer(cs.Board()) while not game_ended: if position in chute and slided: got_chute, game_ended = True, True else: p.move() position, slided = p.position, p.slided game_ended = p.board.goal_reached(position) game_ended = False if not got_chute else True assert position in chute assert slided
def test_move(self): """ResilientPlayer can move.""" b = cs.Board() p = cs.ResilientPlayer(b) p.move()
def test_constructor(self): """ResilientPlayer can be created.""" b = cs.Board() p = cs.ResilientPlayer(b, extra_steps=4) assert isinstance(p, cs.ResilientPlayer) assert isinstance(p, cs.Player)