def test_from_file_should_pass(self): puzzles_to_test: List[XPuzzle] = XPuzzle.from_file( r"./samplePuzzles.txt") self.assertEqual(3, len(puzzles_to_test), "There should be 3 puzzles") self.assertTrue( np.array_equal(np.array([[3, 0, 1, 4], [2, 6, 5, 7]]), puzzles_to_test[0].state), "Should be True", ) self.assertEqual((2, 4), puzzles_to_test[0].shape, "should be equivalent") self.assertTrue( np.array_equal(np.array([[6, 3, 4, 7], [1, 2, 5, 0]]), puzzles_to_test[1].state), "Should be True", ) self.assertEqual((2, 4), puzzles_to_test[1].shape, "should be equivalent") self.assertTrue( np.array_equal(np.array([[1, 0, 3, 6], [5, 2, 7, 4]]), puzzles_to_test[2].state), "Should be equivalent", ) self.assertEqual((2, 4), puzzles_to_test[2].shape, "should be equivalent")
default=r"samplePuzzles.txt", type=str) parser.add_argument('-s', '--shape', dest='shape', default=(2, 4), nargs=2, type=int) parser.add_argument('-astar', '--astar', dest='astar', action='store_true') parser.add_argument('-gbf', '--greedy', dest='gbf', action='store_true') parser.add_argument('-ucs', '--uniform', dest='ucs', action='store_true') args = parser.parse_args() shape: Tuple[int, int] = tuple(args.shape) #type: ignore puzzles = XPuzzle.from_file(args.filename, shape) output_dir = "results/{}".format(args.filename[:-4]) if not os.path.isdir(output_dir): os.mkdir(output_dir) astar: bool = args.astar gbf: bool = args.gbf ucs: bool = args.ucs if not gbf + ucs + astar == 1: sys.exit("Invalid search type") filename = 'astar' search_func = a_star.a_star