def test_read_configuration(self): configuration = Configuration() # (width=6, length=5, p_walk=0.8, p_run=0.6, reward_walk=-0.3, reward_run=-0.2, wall_list=[(1, 1), (4, 3)], # discount=0.7, exit_list=[((0, 2), 10), ((2, 4), 5)], e=1e-4) width, length, p_walk, p_run, r_walk, r_run, discount, wall_list, exit_list = configuration.read_file( "input1.txt") self.assertEqual(width, 6) self.assertEqual(length, 5) self.assertEqual(0.8, p_walk) self.assertEqual(0.6, p_run) self.assertEqual(-0.3, r_walk) self.assertEqual(-0.2, r_run) self.assertListEqual([(1, 1), (4, 3)], wall_list) self.assertEqual(0.7, discount) self.assertListEqual([((0, 2), 10), ((2, 4), 5)], exit_list)
def test_case_11_discount_0(self): configuration = Configuration() width, length, p_walk, p_run, r_walk, r_run, discount, wall_list, exit_list = configuration.read_file( "input11.txt") mdp = MDP(width=width, length=length, p_walk=p_walk, p_run=p_run, reward_walk=r_walk, reward_run=r_run, wall_list=wall_list, discount=discount, exit_list=exit_list, e=1e-80) mdp.value_iteration() str = mdp.out_put() with open("my_output11.txt", 'w') as f: f.write(str)
def test_big_accurate(self): configuration = Configuration() width, length, p_walk, p_run, r_walk, r_run, discount, wall_list, exit_list = configuration.read_file( "input5.txt") mdp = MDP(width=width, length=length, p_walk=p_walk, p_run=p_run, reward_walk=r_walk, reward_run=r_run, wall_list=wall_list, discount=discount, exit_list=exit_list, e=1e-80) mdp.value_iteration() str = mdp.out_put() with open("my_output5.txt", 'w') as f: f.write(str) with open("output_shun.txt", "r") as f: data = f.read() self.assertEqual(data, str)