예제 #1
0
 def test_player_starts_at_0(self):
     """
     Checks that the players starts in position 0
     """
     board = cs.Board()
     player = cs.Player(board)
     assert player.position == 0
예제 #2
0
 def test_standard_board_setting(self):
     """
     Tests the default bord chutes and ladders is correct
     """
     board = cs.Board()
     assert board.ladders == ([1, 40], [9, 11], [37, 53], [44, 63],
                              [50, 80], [66, 83], [69, 86])
예제 #3
0
 def test_constructor_named(self):
     """Constructor with kw args works."""
     b = cs.Board()
     s = cs.Simulation(player_field=[cs.Player, cs.Player],
                       board=b,
                       seed=123,
                       randomize_players=True)
     assert isinstance(s, cs.Simulation)
예제 #4
0
 def test_resilient_player_moves(self):
     """
     Check that the resilient player step counter works
     """
     board = cs.Board()
     player = cs.ResilientPlayer(board)
     player.move()
     player.move()
     assert player.step_counter() == 2
예제 #5
0
 def test_position_adjustment(self):
     """
     Checks that the position adjustment returns the difference between
     the chute and ladder exit/entry
     """
     board = cs.Board(ladders=([1, 21], [15, 25]),
                      chutes=([40, 10], [90, 1]))
     assert board.position_adjustment(1) == 20
     assert board.position_adjustment(90) == -89
예제 #6
0
 def test_goal_reached(self):
     """
     Tests that the goal reached method works
     """
     board = cs.Board(goal=95)
     if board.goal_reached(94):
         assert False
     if board.goal_reached(95):
         assert True
예제 #7
0
 def test_lazy_player_moves(self):
     """
     Checks that the lazy player step counter works
     """
     board = cs.Board()
     player = cs.LazyPlayer(board)
     player.move()
     player.move()
     assert player.step_counter() == 2
예제 #8
0
 def test_run_simulation(self):
     """
     Checks that the length of the list for the run simulation method is
     5 after running 5 games
     """
     game_board = cs.Board()
     sim = cs.Simulation(board=game_board)
     sim.run_simulation(5)
     assert len(sim.game_list) == 5
예제 #9
0
 def test_resilience(self):
     """
     Checks that the resilient player moves extra steps after falling
     down a chute in the next move
     """
     board = cs.Board(chutes=([6, 1], [5, 1], [4, 1], [3, 1], [2, 1]))
     player = cs.ResilientPlayer(board, extra_steps=20)
     player.move()
     player.move()
     assert player.position >= 21
     player.move()
     assert player.position >= 27
예제 #10
0
 def test_laziness(self):
     """
     Checks that the lazy player moves shorter after going up a ladder
     """
     board = cs.Board(ladders=([1, 10], [2, 10], [3, 10], [4, 10], [5, 10],
                               [6, 10]))
     player = cs.LazyPlayer(board, dropped_steps=5)
     player.move()
     player.move()
     assert player.position <= 11
     player.move()
     assert player.position >= 11
예제 #11
0
 def test_move(self):
     """ResilientPlayer can move."""
     b = cs.Board()
     p = cs.ResilientPlayer(b)
     p.move()
예제 #12
0
 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)
예제 #13
0
 def test_move(self):
     """Player has move() method."""
     b = cs.Board()
     p = cs.Player(b)
     p.move()
예제 #14
0
 def test_constructor(self):
     """Player can be constructed."""
     b = cs.Board()
     p = cs.Player(b)
     assert isinstance(p, cs.Player)
예제 #15
0
 def test_position_adjustment(self):
     """position_adjustment callable and returns number"""
     b = cs.Board()
     assert isinstance(b.position_adjustment(1), (int, float))
예제 #16
0
 def test_goal_reached(self):
     """goal_reached() callable and returns bool"""
     b = cs.Board()
     assert isinstance(b.goal_reached(1), bool)
예제 #17
0
 def test_constructor_named_args(self):
     """Constructor with kw args callable."""
     b = cs.Board(ladders=[(1, 4), (5, 16)],
                  chutes=[(9, 2), (12, 3)],
                  goal=90)
     assert isinstance(b, cs.Board)
예제 #18
0
 def test_constructor_args(self):
     """Constructor with unnamed arguments callable."""
     b = cs.Board([(1, 4), (5, 16)], [(9, 2), (12, 3)], 90)
     assert isinstance(b, cs.Board)
예제 #19
0
 def test_constructor(self):
     """LazyPlayer can be constructed."""
     b = cs.Board()
     p = cs.LazyPlayer(b, dropped_steps=3)
     assert isinstance(p, cs.LazyPlayer)
     assert isinstance(p, cs.Player)
예제 #20
0
def test_move():
    a = cs.Player(cs.Board())
    pos1 = a.position
    a.move()
    pos2 = a.position
    assert pos1 != pos2
예제 #21
0
 def test_move(self):
     """LazyPlayer can move."""
     b = cs.Board()
     p = cs.LazyPlayer(b)
     p.move()
예제 #22
0
 def test_constructor_default(self):
     """Default constructor callable."""
     b = cs.Board()
     assert isinstance(b, cs.Board)