def test_history_correctly_represents_history_after_one_move(): env = Environment(2, 2, 2) action = 0 start_state = env.get_state() reward = env.take_action(action) assert env.history == [(start_state, action, reward)]
def test_history_correctly_represents_history_after_several_moves(): env = Environment(2, 2, 2) # make some moves env.take_action(0) env.take_action(1) # make one more move action = 0 most_recent_state = env.get_state() reward = env.take_action(action) # check that history correctly appended to last_move = env.history[-1] assert last_move == (most_recent_state, action, reward)
def test_get_state_red_replaced_with_M(): ''' The position R E R B should be represented as Y E Y M when playing as black (M=mine, Y=yours) ''' env = Environment(2, 2, 2) env.cur_player = Cell.RED env.take_action(0) # red moves env.take_action(1) # black moves env.take_action(0) # red moves result = env.get_state() expected = 'YYEM' # what black sees assert result == expected