Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AICogSciFinalProject
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mrk022
AICogSciFinalProject
Commits
061ab694
Commit
061ab694
authored
Dec 08, 2019
by
mrk022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed print statements
parent
0a1b62a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
19 deletions
+10
-19
__pycache__/tree.cpython-35.pyc
__pycache__/tree.cpython-35.pyc
+0
-0
tree.py
tree.py
+5
-13
tutor.py
tutor.py
+5
-6
No files found.
__pycache__/tree.cpython-35.pyc
View file @
061ab694
No preview for this file type
tree.py
View file @
061ab694
...
...
@@ -20,12 +20,12 @@ class EquationTree:
def
updateNode
(
self
,
parent
,
left
,
newNode
):
if
left
:
parent
.
left
=
newNode
else
:
parent
.
right
=
newNode
self
.
printTree
()
#
self.printTree()
def
get_expression
(
self
):
self
.
output
=
""
self
.
inorder
(
self
.
root
)
print
(
"output is: "
,
self
.
output
)
#
print("output is: ", self.output)
return
self
.
output
def
inorder
(
self
,
node
):
...
...
@@ -51,15 +51,9 @@ class EquationTree:
# can simplify this to call helper function
if
left
:
if
parent
.
left
.
canEval
():
print
(
"parent.left.left is "
,
parent
.
left
.
left
.
value
)
print
(
"parent.left.right is "
,
parent
.
left
.
right
)
if
isinstance
(
parent
.
left
.
left
,
NumNode
):
print
(
"num node"
)
print
(
"evaluating"
,
parent
.
left
.
eval
())
newNode
=
NumNode
(
parent
.
left
.
eval
())
else
:
print
(
"variable node"
)
print
(
"evaluating"
,
parent
.
left
.
eval
())
newNode
=
VariableNode
(
str
(
parent
.
left
.
eval
())
+
"x"
)
parent
.
left
=
newNode
elif
parent
.
left
.
left
!=
None
and
parent
.
left
.
left
.
canEval
():
...
...
@@ -69,10 +63,8 @@ class EquationTree:
else
:
if
parent
.
right
.
canEval
():
if
isinstance
(
parent
.
right
.
left
,
NumNode
):
print
(
"evaluating"
,
parent
.
right
.
eval
())
newNode
=
NumNode
(
parent
.
right
.
eval
())
else
:
print
(
"evaluating"
,
parent
.
right
.
eval
())
else
:
newNode
=
VariableNode
(
str
(
parent
.
right
.
eval
())
+
"x"
)
parent
.
right
=
newNode
elif
parent
.
right
.
left
!=
None
and
parent
.
right
.
left
.
canEval
():
...
...
@@ -226,7 +218,7 @@ def infix_to_prefix(formula):
a
=
exp_stack
.
pop
()
b
=
exp_stack
.
pop
()
exp_stack
.
append
(
op
+
" "
+
b
+
" "
+
a
)
print
(
exp_stack
[
-
1
])
#
print(exp_stack[-1])
return
exp_stack
[
-
1
]
def
add_to_tree
(
q
,
root
,
left
):
...
...
@@ -279,5 +271,5 @@ def generate_tree(equation):
q2
.
enqueue
(
token
)
add_to_tree
(
q2
,
t
.
root
,
False
)
# add expression tree to right side of equation tree
t
.
printTree
()
#
t.printTree()
return
t
\ No newline at end of file
tutor.py
View file @
061ab694
...
...
@@ -213,27 +213,27 @@ class IntelligentTutor(ACTR):
def
init
():
user
.
get_input
()
print
(
"USER STATE IS "
,
user
.
state
)
# need to get user input to translate to state
#
print("USER STATE IS ", user.state) # need to get user input to translate to state
goal
.
set
(
user
.
state
)
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
)
#
print("user equation ",user.equation)
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
)
#
print("user equation ",user.equation)
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
)
#
print("user equation ",user.equation)
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
)
#
print("user equation", user.equation)
goal
.
set
(
"check_state "
+
tutorEq
+
" 0"
)
def
solve
(
goal
=
"solve_for_x"
):
...
...
@@ -241,7 +241,6 @@ class IntelligentTutor(ACTR):
goal
.
set
(
"check_state "
+
tutorEq
+
" 1"
)
def
check_state
(
goal
=
"check_state ?tutorEq ?solved"
):
print
(
"checking state"
)
if
tutor
.
compare_Equations
(
tutorEq
,
user
.
equation
):
if
bool
(
int
(
solved
)):
print
(
"You have solved the equation by isolating x."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment