Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TutorGym
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teachable AI Lab
TutorGym
Commits
8e3ed132
Commit
8e3ed132
authored
4 years ago
by
Chris MacLellan
Browse files
Options
Downloads
Patches
Plain Diff
updated multicolumn to rename carrys to the column they align with.
parent
d7d75057
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tutorenvs/multicolumn.py
+41
-35
41 additions, 35 deletions
tutorenvs/multicolumn.py
with
41 additions
and
35 deletions
tutorenvs/multicolumn.py
+
41
−
35
View file @
8e3ed132
...
@@ -98,9 +98,9 @@ class MultiColumnAdditionSymbolic:
...
@@ -98,9 +98,9 @@ class MultiColumnAdditionSymbolic:
self
.
num_hints
=
0
self
.
num_hints
=
0
self
.
state
=
{
self
.
state
=
{
'
thousands_carry
'
:
''
,
'
hundreds_carry
'
:
''
,
'
hundreds_carry
'
:
''
,
'
tens_carry
'
:
''
,
'
tens_carry
'
:
''
,
'
ones_carry
'
:
''
,
'
upper_hundreds
'
:
upper_hundreds
,
'
upper_hundreds
'
:
upper_hundreds
,
'
upper_tens
'
:
upper_tens
,
'
upper_tens
'
:
upper_tens
,
'
upper_ones
'
:
upper_ones
,
'
upper_ones
'
:
upper_ones
,
...
@@ -115,9 +115,9 @@ class MultiColumnAdditionSymbolic:
...
@@ -115,9 +115,9 @@ class MultiColumnAdditionSymbolic:
}
}
def
get_possible_selections
(
self
):
def
get_possible_selections
(
self
):
return
[
'
hundreds_carry
'
,
return
[
'
thousands_carry
'
,
'
hundreds_carry
'
,
'
tens_carry
'
,
'
tens_carry
'
,
'
ones_carry
'
,
'
answer_thousands
'
,
'
answer_thousands
'
,
'
answer_hundreds
'
,
'
answer_hundreds
'
,
'
answer_tens
'
,
'
answer_tens
'
,
...
@@ -126,9 +126,9 @@ class MultiColumnAdditionSymbolic:
...
@@ -126,9 +126,9 @@ class MultiColumnAdditionSymbolic:
def
get_possible_args
(
self
):
def
get_possible_args
(
self
):
return
[
return
[
'
thousands_carry
'
,
'
hundreds_carry
'
,
'
hundreds_carry
'
,
'
tens_carry
'
,
'
tens_carry
'
,
'
ones_carry
'
,
'
upper_hundreds
'
,
'
upper_hundreds
'
,
'
upper_tens
'
,
'
upper_tens
'
,
'
upper_ones
'
,
'
upper_ones
'
,
...
@@ -151,9 +151,9 @@ class MultiColumnAdditionSymbolic:
...
@@ -151,9 +151,9 @@ class MultiColumnAdditionSymbolic:
self
.
state
[
attr
]
for
attr
in
self
.
state
}
self
.
state
[
attr
]
for
attr
in
self
.
state
}
output
=
"
%s%s%s
\n
%s%s%s
\n
+ %s%s%s
\n
-----
\n
%s%s%s%s
\n
"
%
(
output
=
"
%s%s%s
\n
%s%s%s
\n
+ %s%s%s
\n
-----
\n
%s%s%s%s
\n
"
%
(
state
[
"
thousands_carry
"
],
state
[
"
hundreds_carry
"
],
state
[
"
hundreds_carry
"
],
state
[
"
tens_carry
"
],
state
[
"
tens_carry
"
],
state
[
"
ones_carry
"
],
state
[
"
upper_hundreds
"
],
state
[
"
upper_hundreds
"
],
state
[
"
upper_tens
"
],
state
[
"
upper_tens
"
],
state
[
"
upper_ones
"
],
state
[
"
upper_ones
"
],
...
@@ -186,13 +186,13 @@ class MultiColumnAdditionSymbolic:
...
@@ -186,13 +186,13 @@ class MultiColumnAdditionSymbolic:
d
.
rectangle
(((
16
,
71
),
(
20
,
79
)),
fill
=
None
,
outline
=
'
black
'
)
d
.
rectangle
(((
16
,
71
),
(
20
,
79
)),
fill
=
None
,
outline
=
'
black
'
)
# ones carry
# ones carry
if
state
[
'
one
s_carry
'
]
==
"
"
:
if
state
[
'
ten
s_carry
'
]
==
"
"
:
d
.
rectangle
(((
28
,
11
),
(
32
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
d
.
rectangle
(((
28
,
11
),
(
32
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
# tens carry
# tens carry
if
state
[
'
ten
s_carry
'
]
==
"
"
:
if
state
[
'
hundred
s_carry
'
]
==
"
"
:
d
.
rectangle
(((
22
,
11
),
(
26
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
d
.
rectangle
(((
22
,
11
),
(
26
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
# hundreds carry
# hundreds carry
if
state
[
'
hundre
ds_carry
'
]
==
"
"
:
if
state
[
'
thousan
ds_carry
'
]
==
"
"
:
d
.
rectangle
(((
16
,
11
),
(
20
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
d
.
rectangle
(((
16
,
11
),
(
20
,
19
)),
fill
=
None
,
outline
=
'
black
'
)
# append correct/incorrect counts
# append correct/incorrect counts
...
@@ -213,6 +213,12 @@ class MultiColumnAdditionSymbolic:
...
@@ -213,6 +213,12 @@ class MultiColumnAdditionSymbolic:
"""
"""
state_output
=
{
attr
:
state_output
=
{
attr
:
{
'
id
'
:
attr
,
'
value
'
:
self
.
state
[
attr
],
{
'
id
'
:
attr
,
'
value
'
:
self
.
state
[
attr
],
'
column
'
:
'
thousands
'
if
'
thousands
'
in
attr
else
'
hundreds
'
if
'
hundreds
'
in
attr
else
'
tens
'
if
'
tens
'
in
attr
else
'
ones
'
,
'
row
'
:
'
answer
'
if
'
answer
'
in
attr
else
'
lower
'
if
'
lower
'
in
attr
else
'
upper
'
if
'
upper
'
in
attr
else
'
carry
'
,
'
type
'
:
'
TextField
'
,
'
type
'
:
'
TextField
'
,
'
contentEditable
'
:
self
.
state
[
attr
]
==
""
,
'
contentEditable
'
:
self
.
state
[
attr
]
==
""
,
'
dom_class
'
:
'
CTATTable--cell
'
,
'
dom_class
'
:
'
CTATTable--cell
'
,
...
@@ -302,7 +308,7 @@ class MultiColumnAdditionSymbolic:
...
@@ -302,7 +308,7 @@ class MultiColumnAdditionSymbolic:
inputs
[
'
value
'
]
==
self
.
correct_ones
):
inputs
[
'
value
'
]
==
self
.
correct_ones
):
return
1.0
return
1.0
if
(
selection
==
"
one
s_carry
"
and
if
(
selection
==
"
ten
s_carry
"
and
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
self
.
state
[
'
lower_ones
'
]))
==
2
and
self
.
state
[
'
lower_ones
'
]))
==
2
and
inputs
[
'
value
'
]
==
custom_add
(
self
.
state
[
'
upper_ones
'
],
inputs
[
'
value
'
]
==
custom_add
(
self
.
state
[
'
upper_ones
'
],
...
@@ -310,21 +316,21 @@ class MultiColumnAdditionSymbolic:
...
@@ -310,21 +316,21 @@ class MultiColumnAdditionSymbolic:
return
1.0
return
1.0
if
(
selection
==
"
answer_tens
"
and
self
.
state
[
'
answer_ones
'
]
!=
""
and
if
(
selection
==
"
answer_tens
"
and
self
.
state
[
'
answer_ones
'
]
!=
""
and
(
self
.
state
[
'
one
s_carry
'
]
!=
""
or
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
or
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
self
.
state
[
'
lower_ones
'
]))
==
1
)
and
self
.
state
[
'
lower_ones
'
]))
==
1
)
and
inputs
[
'
value
'
]
==
self
.
correct_tens
):
inputs
[
'
value
'
]
==
self
.
correct_tens
):
return
1.0
return
1.0
if
(
selection
==
"
ten
s_carry
"
and
if
(
selection
==
"
hundred
s_carry
"
and
self
.
state
[
'
answer_ones
'
]
!=
""
and
self
.
state
[
'
answer_ones
'
]
!=
""
and
(
self
.
state
[
'
one
s_carry
'
]
!=
""
or
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
or
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
self
.
state
[
'
lower_ones
'
]))
==
1
)):
self
.
state
[
'
lower_ones
'
]))
==
1
)):
if
(
self
.
state
[
'
one
s_carry
'
]
!=
""
):
if
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
):
tens_sum
=
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
tens_sum
=
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
one
s_carry
'
])
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
ten
s_carry
'
])
else
:
else
:
tens_sum
=
custom_add
(
self
.
state
[
'
upper_tens
'
],
tens_sum
=
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
])
self
.
state
[
'
lower_tens
'
])
...
@@ -335,23 +341,23 @@ class MultiColumnAdditionSymbolic:
...
@@ -335,23 +341,23 @@ class MultiColumnAdditionSymbolic:
if
(
selection
==
"
answer_hundreds
"
and
if
(
selection
==
"
answer_hundreds
"
and
self
.
state
[
'
answer_tens
'
]
!=
""
and
self
.
state
[
'
answer_tens
'
]
!=
""
and
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
or
(
self
.
state
[
'
hundred
s_carry
'
]
!=
""
or
len
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
len
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
]))
==
1
)
and
self
.
state
[
'
lower_tens
'
]))
==
1
)
and
inputs
[
'
value
'
]
==
self
.
correct_hundreds
):
inputs
[
'
value
'
]
==
self
.
correct_hundreds
):
return
1.0
return
1.0
if
(
selection
==
"
hundre
ds_carry
"
and
if
(
selection
==
"
thousan
ds_carry
"
and
self
.
state
[
'
answer_tens
'
]
!=
""
and
self
.
state
[
'
answer_tens
'
]
!=
""
and
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
or
(
self
.
state
[
'
hundred
s_carry
'
]
!=
""
or
len
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
len
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
]))
==
1
)):
self
.
state
[
'
lower_tens
'
]))
==
1
)):
if
(
self
.
state
[
'
ten
s_carry
'
]
!=
""
):
if
(
self
.
state
[
'
hundred
s_carry
'
]
!=
""
):
hundreds_sum
=
custom_add
(
custom_add
(
hundreds_sum
=
custom_add
(
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
self
.
state
[
'
upper_hundreds
'
],
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
ten
s_carry
'
])
self
.
state
[
'
hundred
s_carry
'
])
else
:
else
:
hundreds_sum
=
custom_add
(
hundreds_sum
=
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
self
.
state
[
'
upper_hundreds
'
],
...
@@ -363,7 +369,7 @@ class MultiColumnAdditionSymbolic:
...
@@ -363,7 +369,7 @@ class MultiColumnAdditionSymbolic:
if
(
selection
==
"
answer_thousands
"
and
if
(
selection
==
"
answer_thousands
"
and
self
.
state
[
'
answer_hundreds
'
]
!=
""
and
self
.
state
[
'
answer_hundreds
'
]
!=
""
and
self
.
state
[
'
hundre
ds_carry
'
]
!=
""
and
self
.
state
[
'
thousan
ds_carry
'
]
!=
""
and
inputs
[
'
value
'
]
==
self
.
correct_thousands
):
inputs
[
'
value
'
]
==
self
.
correct_thousands
):
return
1.0
return
1.0
...
@@ -393,37 +399,37 @@ class MultiColumnAdditionSymbolic:
...
@@ -393,37 +399,37 @@ class MultiColumnAdditionSymbolic:
if
self
.
state
[
'
answer_ones
'
]
==
''
:
if
self
.
state
[
'
answer_ones
'
]
==
''
:
return
(
'
answer_ones
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_ones
)})
return
(
'
answer_ones
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_ones
)})
if
(
self
.
state
[
"
one
s_carry
"
]
==
''
and
if
(
self
.
state
[
"
ten
s_carry
"
]
==
''
and
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
len
(
custom_add
(
self
.
state
[
'
upper_ones
'
],
self
.
state
[
'
lower_ones
'
]))
==
2
):
self
.
state
[
'
lower_ones
'
]))
==
2
):
return
(
'
one
s_carry
'
,
'
UpdateField
'
,
return
(
'
ten
s_carry
'
,
'
UpdateField
'
,
{
'
value
'
:
custom_add
(
self
.
state
[
'
upper_ones
'
],
{
'
value
'
:
custom_add
(
self
.
state
[
'
upper_ones
'
],
self
.
state
[
'
lower_ones
'
])[
0
]})
self
.
state
[
'
lower_ones
'
])[
0
]})
if
self
.
state
[
'
answer_tens
'
]
==
''
:
if
self
.
state
[
'
answer_tens
'
]
==
''
:
return
(
'
answer_tens
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_tens
)})
return
(
'
answer_tens
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_tens
)})
if
self
.
state
[
"
ten
s_carry
"
]
==
''
:
if
self
.
state
[
"
hundred
s_carry
"
]
==
''
:
if
(
len
(
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
if
(
len
(
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
one
s_carry
'
]))
==
2
):
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
ten
s_carry
'
]))
==
2
):
return
(
'
ten
s_carry
'
,
'
UpdateField
'
,
return
(
'
hundred
s_carry
'
,
'
UpdateField
'
,
{
'
value
'
:
{
'
value
'
:
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
custom_add
(
custom_add
(
self
.
state
[
'
upper_tens
'
],
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
lower_tens
'
]),
self
.
state
[
'
one
s_carry
'
])[
0
]})
self
.
state
[
'
ten
s_carry
'
])[
0
]})
if
self
.
state
[
'
answer_hundreds
'
]
==
''
:
if
self
.
state
[
'
answer_hundreds
'
]
==
''
:
return
(
'
answer_hundreds
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_hundreds
)})
return
(
'
answer_hundreds
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_hundreds
)})
if
self
.
state
[
"
hundre
ds_carry
"
]
==
''
:
if
self
.
state
[
"
thousan
ds_carry
"
]
==
''
:
if
(
len
(
custom_add
(
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
if
(
len
(
custom_add
(
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
ten
s_carry
'
]))
==
2
):
self
.
state
[
'
hundred
s_carry
'
]))
==
2
):
return
(
'
hundre
ds_carry
'
,
'
UpdateField
'
,
return
(
'
thousan
ds_carry
'
,
'
UpdateField
'
,
{
'
value
'
:
{
'
value
'
:
custom_add
(
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
custom_add
(
custom_add
(
self
.
state
[
'
upper_hundreds
'
],
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
lower_hundreds
'
]),
self
.
state
[
'
ten
s_carry
'
])[
0
]})
self
.
state
[
'
hundred
s_carry
'
])[
0
]})
if
self
.
state
[
'
answer_thousands
'
]
==
''
:
if
self
.
state
[
'
answer_thousands
'
]
==
''
:
return
(
'
answer_thousands
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_thousands
)})
return
(
'
answer_thousands
'
,
'
UpdateField
'
,
{
'
value
'
:
str
(
self
.
correct_thousands
)})
...
@@ -569,8 +575,8 @@ class MultiColumnAdditionPerceptEnv(gym.Env):
...
@@ -569,8 +575,8 @@ class MultiColumnAdditionPerceptEnv(gym.Env):
metadata
=
{
'
render.modes
'
:
[
'
human
'
]}
metadata
=
{
'
render.modes
'
:
[
'
human
'
]}
def
__init__
(
self
):
def
__init__
(
self
):
self
.
targets
=
[
'
answer_ones
'
,
'
one
s_carry
'
,
'
answer_tens
'
,
self
.
targets
=
[
'
answer_ones
'
,
'
ten
s_carry
'
,
'
answer_tens
'
,
'
ten
s_carry
'
,
'
answer_hundreds
'
,
'
hundre
ds_carry
'
,
'
hundred
s_carry
'
,
'
answer_hundreds
'
,
'
thousan
ds_carry
'
,
'
answer_thousands
'
]
'
answer_thousands
'
]
self
.
target_xy
=
[
self
.
target_xy
=
[
(
36
,
75
),
(
36
,
75
),
...
@@ -654,11 +660,11 @@ class MultiColumnAdditionPerceptEnv(gym.Env):
...
@@ -654,11 +660,11 @@ class MultiColumnAdditionPerceptEnv(gym.Env):
# carry fields
# carry fields
elif
self
.
x
>=
28
and
self
.
y
>=
11
and
self
.
x
<=
32
and
self
.
y
<=
19
:
elif
self
.
x
>=
28
and
self
.
y
>=
11
and
self
.
x
<=
32
and
self
.
y
<=
19
:
s
=
"
ones_carry
"
elif
self
.
x
>=
22
and
self
.
y
>=
11
and
self
.
x
<=
26
and
self
.
y
<=
19
:
s
=
"
tens_carry
"
s
=
"
tens_carry
"
elif
self
.
x
>=
16
and
self
.
y
>=
11
and
self
.
x
<=
2
0
and
self
.
y
<=
19
:
elif
self
.
x
>=
22
and
self
.
y
>=
11
and
self
.
x
<=
2
6
and
self
.
y
<=
19
:
s
=
"
hundreds_carry
"
s
=
"
hundreds_carry
"
elif
self
.
x
>=
16
and
self
.
y
>=
11
and
self
.
x
<=
20
and
self
.
y
<=
19
:
s
=
"
thousands_carry
"
a
=
'
UpdateField
'
a
=
'
UpdateField
'
i
=
{
'
value
'
:
str
(
action
-
2
)}
i
=
{
'
value
'
:
str
(
action
-
2
)}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment