def main(): cube = Cube() print '=========== initial ============' cube.show() print cube.calculate_feature_string() print cube.check() print '' command = raw_input("Command: ").upper() while command != 'Q': if command not in command_map: print("Invalid input. Input again.") continue cube.transform(command_map[command]) print '=========== %s ============' % command print '' cube.show() print '' command = raw_input("Command: ").upper()
def test_transform(): result_file = 'tmp_result.txt' benchmark_file = 'ut_result.txt' cube = Cube() with open(result_file, 'w') as result_fp: cube.show(result_fp) for command in command_list: for i in range(0, 4): result_fp.write('=========== %s ============\n' % command) cube.transform(command_list[command]) cube.show(result_fp) benchmark = open(result_file, 'U').readlines() result = open(benchmark_file, 'U').readlines() diff = unified_diff(benchmark, result, benchmark_file, result_file) print 'Diff between benchmark and result.\n' stdout.writelines(diff) print '\nTest transform done.'
def test_shuffle(): cube = Cube() game = Game(cube) game.shuffle() step = len(game.shuffle_full_steps) print '=========== initialized with %s-step shuffle ============' % step cube.show() print '' print 'Feature string is ', cube.calculate_feature_string() print 'Is standard? ', cube.check() command = raw_input("Command: ").upper() while command != 'Q': if command not in command_map: print("Invalid input. Input again.") continue cube.transform(command_map[command]) print '=========== %s ============' % command print '' cube.show() print '' command = raw_input("Command: ").upper()
def test_bayesian(): cube = Cube() cube.transform(F) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[-F + DIRECTION_OFFSET]) cube.transform(B) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[-B + DIRECTION_OFFSET]) cube.transform(-B) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[B + DIRECTION_OFFSET]) cube.transform(R) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[-R + DIRECTION_OFFSET]) cube.transform(L) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[-L + DIRECTION_OFFSET]) cube.transform(B) bayesian.add_feature_and_decision(cube.feature_string, DIRECTIONS[-B + DIRECTION_OFFSET]) print_possibility() bayesian.export('bayesiantest.yaml') bayesian.load('bayesiantest.yaml') print_possibility()