summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
Diffstat (limited to 'modeling')
-rw-r--r--modeling/prod_addition.py325
-rw-r--r--modeling/productions_math.py323
2 files changed, 328 insertions, 320 deletions
diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py
new file mode 100644
index 0000000..7ba7c22
--- /dev/null
+++ b/modeling/prod_addition.py
@@ -0,0 +1,325 @@
+#!/usr/bin/env python3
+
+
+def addition(Model):
+ prods = []
+
+ start_add = Model.productionstring(
+ name="start_add",
+ string="""
+ =g>
+ isa math_goal
+ op add
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ ones1 =num1
+ ones2 =num2
+ ones_ans None
+ ==>
+ =imaginal>
+ isa math_op
+ ones_ans busy
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =num1
+ arg2 =num2
+ """,
+ )
+ prods.append(start_add)
+
+ add_ones = Model.productionstring(
+ name="add_ones",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ ones_ans busy
+ ones1 =num1
+ ones2 =num2
+ =retrieval>
+ isa math_op
+ arg1 =num1
+ arg2 =num2
+ result =result
+ ==>
+ =imaginal>
+ isa math_op
+ ones_ans =result
+ carry_ones busy
+ +retrieval>
+ isa math_op
+ op add
+ arg1 10
+ result =result
+ """,
+ )
+ prods.append(add_ones)
+
+ process_carry_ones = Model.productionstring(
+ name="process_carry_ones",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ tens1 =num1
+ tens2 =num2
+ carry_ones busy
+ ones_ans =ones
+ =retrieval>
+ isa math_op
+ op add
+ arg1 10
+ result =ones
+ arg2 =remainder
+ ==>
+ =imaginal>
+ isa math_op
+ op add
+ carry_ones 1
+ tens_ans busy
+ ones_ans =remainder
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =num1
+ arg2 =num2
+ """,
+ )
+ prods.append(process_carry_ones)
+
+ no_carry_ones = Model.productionstring(
+ name="no_carry_ones",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ tens1 =num1
+ tens2 =num2
+ ones_ans =ones
+ carry_ones busy
+ ?retrieval>
+ state error
+ ==>
+ =imaginal>
+ isa math_op
+ carry_ones None
+ tens_ans busy
+ +retrieval>
+ isa math_op
+ arg1 =num1
+ arg2 =num2
+ """,
+ )
+ prods.append(no_carry_ones)
+
+ add_tens_done = Model.productionstring(
+ name="add_tens_done",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ tens_ans busy
+ carry_ones None
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ ==>
+ =imaginal>
+ isa math_op
+ tens_ans =sum
+ carry_tens busy
+ +retrieval>
+ isa math_op
+ op add
+ arg1 10
+ result =sum
+ """,
+ )
+ prods.append(add_tens_done)
+
+ add_tens_carry = Model.productionstring(
+ name="add_tens_carry",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ tens_ans busy
+ tens1 =num1
+ tens2 =num2
+ carry_ones 1
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ arg1 =num1
+ arg2 =num2
+ ==>
+ =imaginal>
+ isa math_op
+ carry_ones None
+ ~retrieval>
+ +retrieval>
+ isa math_op
+ op add
+ arg1 1
+ arg2 =sum
+ """,
+ )
+ prods.append(add_tens_carry)
+
+
+ process_carry_tens = Model.productionstring(
+ name="process_carry_tens",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ hundreds1 =num1
+ hundreds2 =num2
+ carry_tens busy
+ tens_ans =tens
+ =retrieval>
+ isa math_op
+ op add
+ arg1 10
+ result =tens
+ arg2 =remainder
+ ==>
+ =imaginal>
+ isa math_op
+ op add
+ carry_tens 1
+ hundreds_ans busy
+ tens_ans =remainder
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =num1
+ arg2 =num2
+ """,
+ )
+ prods.append(process_carry_tens)
+
+ no_carry_tens = Model.productionstring(
+ name="no_carry_tens",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ hundreds1 =num1
+ hundreds2 =num2
+ tens_ans =tens
+ carry_tens busy
+ ?retrieval>
+ state error
+ ==>
+ =imaginal>
+ isa math_op
+ carry_tens None
+ hundreds_ans busy
+ ~retrieval>
+ +retrieval>
+ isa math_op
+ arg1 =num1
+ arg2 =num2
+ """,
+ )
+ prods.append(no_carry_tens)
+
+ add_hundreds_done = Model.productionstring(
+ name="add_hundreds_done",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ hundreds_ans busy
+ carry_tens None
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ ==>
+ =g>
+ isa math_goal
+ task done
+ =imaginal>
+ isa math_op
+ hundreds_ans =sum
+ """,
+ )
+ prods.append(add_hundreds_done)
+
+ add_hundreds_carry = Model.productionstring(
+ name="add_hundreds_carry",
+ string="""
+ =g>
+ isa math_goal
+ task calc
+ =imaginal>
+ isa math_op
+ op add
+ hundreds_ans busy
+ hundreds1 =num1
+ hundreds2 =num2
+ carry_tens 1
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ arg1 =num1
+ arg2 =num2
+ ==>
+ =imaginal>
+ isa math_op
+ carry_tens None
+ ~retrieval>
+ +retrieval>
+ isa math_op
+ op add
+ arg1 1
+ arg2 =sum
+ """,
+ )
+ prods.append(add_hundreds_carry)
+
+ # addition_done = Model.productionstring(
+ # name="addition_done",
+ # string="""
+ # =g>
+ # isa math_goal
+ # task done
+ # ==>
+ # ?g>
+ # """
+ # )
+ # prods.append(addition_done)
+
+ return prods
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index b1c131b..c8dfc8e 100644
--- a/modeling/productions_math.py
+++ b/modeling/productions_math.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import pyactr as actr
+import prod_addition
Model = actr.ACTRModel()
@@ -40,7 +41,7 @@ imaginal.add(
arg1=249,
arg2=159,
ones1=9,
- tens1=3,
+ tens1=4,
hundreds1=2,
ones2=9,
tens2=5,
@@ -178,329 +179,11 @@ def greater_than_prod():
)
-def addition():
- prods = []
-
- start_add = Model.productionstring(
- name="start_add",
- string="""
- =g>
- isa math_goal
- op add
- task calc
- =imaginal>
- isa math_op
- op add
- ones1 =num1
- ones2 =num2
- ones_ans None
- ==>
- =imaginal>
- isa math_op
- ones_ans busy
- +retrieval>
- isa math_op
- op add
- arg1 =num1
- arg2 =num2
- """,
- )
- prods.append(start_add)
-
- add_ones = Model.productionstring(
- name="add_ones",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- ones_ans busy
- ones1 =num1
- ones2 =num2
- =retrieval>
- isa math_op
- arg1 =num1
- arg2 =num2
- result =result
- ==>
- =imaginal>
- isa math_op
- ones_ans =result
- carry_ones busy
- +retrieval>
- isa math_op
- op add
- arg1 10
- result =result
- """,
- )
- prods.append(add_ones)
-
- process_carry_ones = Model.productionstring(
- name="process_carry_ones",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- tens1 =num1
- tens2 =num2
- carry_ones busy
- ones_ans =ones
- =retrieval>
- isa math_op
- op add
- arg1 10
- result =ones
- arg2 =remainder
- ==>
- =imaginal>
- isa math_op
- op add
- carry_ones 1
- tens_ans busy
- ones_ans =remainder
- +retrieval>
- isa math_op
- op add
- arg1 =num1
- arg2 =num2
- """,
- )
- prods.append(process_carry_ones)
-
- no_carry_ones = Model.productionstring(
- name="no_carry_ones",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- tens1 =num1
- tens2 =num2
- ones_ans =ones
- carry_ones busy
- ?retrieval>
- state error
- ==>
- =imaginal>
- isa math_op
- carry_ones None
- tens_ans busy
- +retrieval>
- isa math_op
- arg1 =num1
- arg2 =num2
- """,
- )
- prods.append(no_carry_ones)
-
- add_tens_done = Model.productionstring(
- name="add_tens_done",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- tens_ans busy
- carry_ones None
- =retrieval>
- isa math_op
- op add
- result =sum
- ==>
- =g>
- isa math_goal
- task done
- =imaginal>
- isa math_op
- tens_ans =sum
- """,
- )
- prods.append(add_tens_done)
-
- add_tens_carry = Model.productionstring(
- name="add_tens_carry",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- tens_ans busy
- tens1 =num1
- tens2 =num2
- carry_ones 1
- =retrieval>
- isa math_op
- op add
- result =sum
- arg1 =num1
- arg2 =num2
- ==>
- =imaginal>
- isa math_op
- carry_ones None
- ~retrieval>
- +retrieval>
- isa math_op
- op add
- arg1 1
- arg2 =sum
- """,
- )
- prods.append(add_tens_carry)
-
-
- process_carry_tens = Model.productionstring(
- name="process_carry_tens",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- hundreds1 =num1
- hundreds2 =num2
- carry_tens busy
- tens_ans =tens
- =retrieval>
- isa math_op
- op add
- arg1 10
- result =tens
- arg2 =remainder
- ==>
- =imaginal>
- isa math_op
- op add
- carry_tens 1
- hundreds_ans busy
- tens_ans =remainder
- +retrieval>
- isa math_op
- op add
- arg1 =num1
- arg2 =num2
- """,
- )
- prods.append(process_carry_tens)
-
- no_carry_tens = Model.productionstring(
- name="no_carry_tens",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- hundreds1 =num1
- hundreds2 =num2
- tens_ans =tens
- carry_tens busy
- ?retrieval>
- state error
- ==>
- =imaginal>
- isa math_op
- carry_tens None
- hundreds_ans busy
- +retrieval>
- isa math_op
- arg1 =num1
- arg2 =num2
- """,
- )
- prods.append(no_carry_tens)
-
- add_hundreds_done = Model.productionstring(
- name="add_tens_done",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- hundreds_ans busy
- carry_tens None
- =retrieval>
- isa math_op
- op add
- result =sum
- ==>
- =g>
- isa math_goal
- task done
- =imaginal>
- isa math_op
- hundreds_ans =sum
- """,
- )
- prods.append(add_hundreds_done)
-
- add_hundreds_carry = Model.productionstring(
- name="add_hundreds_carry",
- string="""
- =g>
- isa math_goal
- task calc
- =imaginal>
- isa math_op
- op add
- hundreds_ans busy
- hundreds1 =num1
- hundreds2 =num2
- carry_tens 1
- =retrieval>
- isa math_op
- op add
- result =sum
- arg1 =num1
- arg2 =num2
- ==>
- =imaginal>
- isa math_op
- carry_tens None
- ~retrieval>
- +retrieval>
- isa math_op
- op add
- arg1 1
- arg2 =sum
- """,
- )
- prods.append(add_hundreds_carry)
- # addition_done = Model.productionstring(
- # name="addition_done",
- # string="""
- # =g>
- # isa math_goal
- # task done
- # ==>
- # ?g>
- # """
- # )
- # prods.append(addition_done)
-
- return prods
-
# print(DM)
# unwind_prod()
-add_prods = addition()
+add_prods = prod_addition.addition(Model)
# greater_than_prod()
for prod in add_prods: