foil = "x - 4 * x + 3" linear = "27 = 3*x + 15 " sine = "sin(y + 3*s + 15)" cosi = "cos(z + 1 - 16)" tang = "tan(q + 4)" sinesq = "sin(y * pi)^2" cosisq = "cos(z - 16)^2" tangsq = "tan(d + 5)^2" logr = "log(a+b+c)" inv = "inv(a-x+b)" test_expressions = [quad1, quad2,quad3,foil, linear, sine, cosi, tang, sinesq, cosisq, tangsq, logr, inv] for test1 in test_expressions: print("Testing: " + str(test1)) match_array = expr.look_for_match(test1) print("Possible Matches: "+str(match_array)) print for test2 in test_expressions: print("Testing: " + str(test2)) change_array = expr.find_changes(test2) print("Possible Changes: "+str(change_array)) print for test3 in test_expressions: print("Testing: " + str(test3)) expr.find_parts(test3) print print(test_expressions[6])
#jumble = math.associative_jumble(str(tree)) #print("jumble: " + str(jumble)) return tree #print(changes[0]) #print("change being made: " + str(changes[0][1])) replacement = do_math(changes[0]) #print("replacement: " + str(replacement)) simplified = simplified.replace(changes[0][1][0], replacement) #print("current: "+str(simplified)) new_tree = eqsim.reparse(simplified) return simplify_expression(new_tree) tree = eqsim.parse() possible_matches = expr.look_for_match(str(tree)) possible_changes = expr.find_changes(str(tree)) #print("possible matches: " + str(possible_matches)) #BFSarray = BFS(tree) #DFSarray = DFS(tree) #print("BFS: " + str(BFSarray)) #print("DFS: " + str(DFSarray)) #changeA = valid_changes(DFSarray) #changeB = valid_changes(BFSarray) #print("A: " + str(changeA)) #print("B: " + str(changeB)) #valid_moves = []
if len(changes) == 0: #jumble = math.associative_jumble(str(tree)) #print("jumble: " + str(jumble)) return tree #print(changes[0]) #print("change being made: " + str(changes[0][1])) replacement = do_math(changes[0]) #print("replacement: " + str(replacement)) simplified = simplified.replace(changes[0][1][0],replacement) #print("current: "+str(simplified)) new_tree = eqsim.reparse(simplified) return simplify_expression(new_tree) tree = eqsim.parse() possible_matches = expr.look_for_match(str(tree)) possible_changes = expr.find_changes(str(tree)) #print("possible matches: " + str(possible_matches)) #BFSarray = BFS(tree) #DFSarray = DFS(tree) #print("BFS: " + str(BFSarray)) #print("DFS: " + str(DFSarray)) #changeA = valid_changes(DFSarray) #changeB = valid_changes(BFSarray) #print("A: " + str(changeA)) #print("B: " + str(changeB))