### can solve equation now

parent c8621a3d
 ... ... @@ -3,4 +3,4 @@ For this project, we had the topic of AI and Education. We decided to create an intelligent tutor to help young children practice algebra problems. Our tutor uses equations of the form ax + b = cx + d to help the user learn how to simplify equations and solve for x. The user is prompted for input, and the tutor matches their input to a step in the expected problem solving process. If the user's input is correct, they will continue solving the problem, and if not then they will be given the correct step and asked to continue. ## Usage Instructions To use the intelligent tutor, you will need python3 and the Python ACTR library. After you have these installed, in the main project folder, simply run ```python tutor.py``` and you will be prompted for input as the user. If you would like to change the algebra problem you are working on, this variable is in the tutor.py file, near the bottom. The initialization of the user state and tutor state takes an equation as an input and will need to be edited accordinly. \ No newline at end of file To use the intelligent tutor, you will need python3 and the Python ACTR library. After you have these installed, in the main project folder, simply run ```python tutor.py``` and you will be prompted for input as the user. If you would like to change the algebra problem you are working on, this variable is in the tutor.py file, near the bottom. The initialization of the user state and tutor state takes an equation as an input and will need to be edited accordingly. \ No newline at end of file
No preview for this file type
 ... ... @@ -34,6 +34,19 @@ class EquationTree: self.output += str(node.value) self.inorder(node.right) def solve(self): # solves equation assuming there are only a variable node and num node left if isinstance(self.root.left, VariableNode): # variablenode is on left of equation sol = self.root.right.eval() / self.root.left.eval() self.root.left = VariableNode('x') self.root.right = NumNode(int(sol)) else: sol = self.root.left.eval() / self.root.right.eval() self.root.right = VariableNode('x') self.root.left = NumNode(int(sol)) return self.get_expression() def evaluate(self, parent, left): # can simplify this to call helper function if left: ... ...
 ... ... @@ -195,7 +195,13 @@ class UserState(ccm.Model): elif oldConstantCount != self.constantCount or oldConstantCount != self.constantCount: if oldConstantCount > self.constantCount: self.state = "add_constants 1" else: self.state = "add_constants 0" else: print("nothing triggered") elif ((self.constantCount == 1 and self.constantCount == 1) or (self.constantCount == 1 and self.constantCount == 1)) and (self.sides == 'x' or self.sides == 'x'): # case where simplifying to solve for x self.state = "solve_for_x" else: print("nothing triggered") self.state = "invalid_state nothing" return self.state class IntelligentTutor(ACTR): ... ... @@ -213,27 +219,36 @@ class IntelligentTutor(ACTR): def moved_constants(goal="move_constants ?left"): #true if moving constants left tutorEq = tutor.move_values(bool(int(left)), True) print("user equation ",user.equation) goal.set("check_state " + tutorEq) goal.set("check_state " + tutorEq + " 0") def add_constants(goal= "add_constants ?left"): tutorEq = tutor.combine_like_terms(bool(int(left))) print("user equation ",user.equation) goal.set("check_state " + tutorEq) goal.set("check_state " + tutorEq + " 0") def moved_variables(goal="move_variables ?left"): tutorEq = tutor.move_values(bool(int(left)), False) print("user equation ",user.equation) goal.set("check_state " + tutorEq) goal.set("check_state " + tutorEq + " 0") def add_variables(goal = "add_variables ?left"): tutorEq = tutor.combine_like_terms(bool(int(left))) print("user equation", user.equation) goal.set("check_state " + tutorEq) goal.set("check_state " + tutorEq + " 0") def check_state(goal = "check_state ?tutorEq"): def solve(goal = "solve_for_x"): tutorEq = tutor.tree.solve() goal.set("check_state " + tutorEq + " 1") def check_state(goal = "check_state ?tutorEq ?solved"): print("checking state") if tutor.compare_Equations(tutorEq, user.equation): user.get_input() goal.set(user.state) if bool(int(solved)): print("You have solved the equation by isolating x.") goal.set("end_process") else: user.get_input() goal.set(user.state) else: goal.set("invalid_state " + tutorEq) ... ... @@ -254,7 +269,7 @@ def main(): env_name = EmptyEnvironment() agent_name = IntelligentTutor() env_name.agent = agent_name #ccm.log_everything(env_name) # log statement, uncomment if you want to log information ccm.log_everything(env_name) # log statement, uncomment if you want to log information env_name.run() main() \ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!