summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
Diffstat (limited to 'modeling')
-rw-r--r--modeling/prod_addition.py44
-rw-r--r--modeling/prod_multi.py92
-rw-r--r--modeling/productions_math.py2
3 files changed, 127 insertions, 11 deletions
diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py
index 7ba7c22..3c7e888 100644
--- a/modeling/prod_addition.py
+++ b/modeling/prod_addition.py
@@ -116,6 +116,7 @@ def addition(Model):
isa math_op
carry_ones None
tens_ans busy
+ ~retrieval>
+retrieval>
isa math_op
arg1 =num1
@@ -310,16 +311,37 @@ def addition(Model):
)
prods.append(add_hundreds_carry)
- # addition_done = Model.productionstring(
- # name="addition_done",
- # string="""
- # =g>
- # isa math_goal
- # task done
- # ==>
- # ?g>
- # """
- # )
- # prods.append(addition_done)
+ addition_done = Model.productionstring(
+ name="addition_done",
+ string="""
+ =g>
+ isa math_goal
+ task done
+ =imaginal>
+ isa math_op
+ op add
+ arg1 =arg1
+ ones1 =ones1
+ tens1 =tens1
+ hundreds1 =huns1
+ arg2 =arg2
+ ones2 =ones2
+ tens2 =tens2
+ hundreds2 =huns2
+ ==>
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =arg1
+ ones1 =ones1
+ tens1 =tens1
+ hundreds1 =huns1
+ arg2 =arg2
+ ones2 =ones2
+ tens2 =tens2
+ hundreds2 =huns2
+ """
+ )
+ prods.append(addition_done)
return prods
diff --git a/modeling/prod_multi.py b/modeling/prod_multi.py
new file mode 100644
index 0000000..667241e
--- /dev/null
+++ b/modeling/prod_multi.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+
+
+def multiplication(Model):
+ prods = []
+
+ # TODO: switch operands so less steps are needed
+ # switch_mul = Model.productionstring(
+ # name="switch_mul",
+ # string="""
+ # =g>
+ # =imaginal>
+ # ==>
+ # =imaginal>
+ # """,
+ # )
+ # prods.append(switch_mul)
+
+ start_mul = Model.productionstring(
+ name="start_mul",
+ string="""
+ =g>
+ isa math_goal
+ op mul
+ task calc
+ =imaginal>
+ isa math_op
+ op mul
+ arg1 ~0
+ arg1 ~1
+ arg2 ~0
+ arg1 ~1
+ arg1 =mul
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ ==>
+ !g>
+ show terminal
+ +g>
+ isa math_goal
+ op add
+ task calc
+ +imaginal>
+ isa math_op
+ op add
+ arg1 =arg
+ ones1 =ones
+ tens1 =tens
+ hundreds1 =huns
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =arg
+ arg2 =arg
+ """,
+ )
+ prods.append(start_mul)
+
+
+ step_mul = Model.productionstring(
+ name="step_mul",
+ string="""
+ =g>
+ isa math_goal
+ op mul
+ task calc
+ =imaginal>
+ isa math_op
+ op mul
+ arg2 =arg
+ =retrieval>
+ isa math_op
+ op add
+ arg1 =arg
+ arg2 =arg
+ result =sum
+ ==>
+ =g>
+ isa math_goal
+ op mul
+ one_ans =sum
+ """,
+ )
+ prods.append(step_mul)
+
+ return prods
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index 40c400f..182a208 100644
--- a/modeling/productions_math.py
+++ b/modeling/productions_math.py
@@ -3,6 +3,7 @@
import pyactr as actr
import prod_addition
import prod_comp
+import prod_multi
# https://stackoverflow.com/a/39644726
@@ -154,6 +155,7 @@ def start():
add_prods = prod_addition.addition(Model)
greater_prods = prod_comp.greater_than(Model)
less_prods = prod_comp.less_than(Model)
+ multi_prods = prod_multi.multiplication(Model)
for prod in add_prods:
print(prod)