summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
authorDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-03-19 12:01:27 +0100
committerDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-03-19 12:01:27 +0100
commit87ac29553b71039bb9798251873272b84d3ce345 (patch)
treedfedbe30e8a57e4b7ba58660a9c97dfd9f864127 /modeling
parentdd047713de0c721605ea84d8f915fd81dbb0808f (diff)
update
Diffstat (limited to 'modeling')
-rw-r--r--modeling/productions_math.py159
1 files changed, 110 insertions, 49 deletions
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index 475ed59..4088546 100644
--- a/modeling/productions_math.py
+++ b/modeling/productions_math.py
@@ -5,7 +5,7 @@ import pyactr as actr
Model = actr.ACTRModel()
DM = Model.decmem
-g = Model.goal
+goal = Model.goal
imaginal = Model.set_goal(name="imaginal", delay=0.2)
actr.chunktype("number", ("number", "next", "ones", "tens", "hundreds"))
@@ -30,12 +30,12 @@ actr.chunktype(
),
)
-g.add(actr.makechunk("", "math_goal", op="greater", task="calc"))
+goal.add(actr.makechunk("", "math_goal", op="greater", task="calc"))
imaginal.add(
actr.makechunk(
"",
"math_op",
- op="greater",
+ op="add",
arg1=5,
arg2=2,
ones1=5,
@@ -119,9 +119,10 @@ def unwind_prod():
name="terminate_op",
string="""
=g>
- isa math_op
+ isa math_goal
task finished_op
=imaginal>
+ isa math_op
result =answer
==>
~g>""",
@@ -164,7 +165,7 @@ def greater_than_prod():
=imaginal>
op greater
=retrieval>
- isa mat_op
+ isa math_op
op greater
result =ans
==>
@@ -177,86 +178,90 @@ def greater_than_prod():
def addition():
- Model.productionstring(
+ start_add = Model.productionstring(
name="start_add",
string="""
- =goal>
+ =goal>
isa math_goal
- =imaginal>
+ =imaginal>
+ isa math_op
op add
ones1 =num1
- ones2 =num2
- one_ans None
- ==>
- =imaginal>
+ ones2 =num2
+ ones_ans None
+ ==>
+ =imaginal>
isa math_op
- one-ans busy
- +retrieval>
+ ones_ans busy
+ +retrieval>
isa math_op
op add
arg1 =num1
arg2 =num2
""",
)
+ print(start_add)
- Model.productionstring(
+ add_ones = Model.productionstring(
name="add_ones",
string="""
- =goal>
+ =goal>
isa math_goal
- =imaginal>
+ =imaginal>
isa math_op
op add
- one-ans busy
+ ones_ans busy
ones1 =num1
ones2 =num2
- =retrieval>
+ =retrieval>
isa math_op
arg1 =num1
arg2 =num2
result =result
- ==>
- =goal>
+ ==>
+ =goal>
isa math_goal
- =imaginal>
+ =imaginal>
+ isa math_op
ones_ans =result
carry busy
- +retrieval>
+ +retrieval>
isa math_op
op add
arg1 10
result =result
""",
)
+ print(add_ones)
Model.productionstring(
name="process_carry",
string="""
- =goal>
+ =goal>
isa math_goal
- =imaginal>
+ =imaginal>
isa math_op
op add
tens1 =num1
tens2 =num2
carry busy
ones_ans =ones
- =retrieval>
+ =retrieval>
isa math_op
op add
arg1 10
result =ones
arg2 =remainder
- ==>
- =goal>
+ ==>
+ =goal>
isa math_goal
- =imaginal>
+ =imaginal>
isa math_op
op add
carry 1
tens_ans busy
- one_ans =remainder
- +retrieval>
+ ones_ans =remainder
+ +retrieval>
isa math_op
op add
arg1 =num1
@@ -265,35 +270,91 @@ def addition():
)
Model.productionstring(
- name="increment-sum",
+ name="no_carry",
string="""
- =goal>
- ISA add
- sum =sum
- count =count
- - arg2 =count
- =retrieval>
- ISA number
- number =sum
- next =newsum
- ==>
- =goal>
- ISA add
- sum =newsum
- +retrieval>
- ISA number
- number =count
+ =goal>
+ isa math_goal
+ =imaginal>
+ isa math_op
+ op add
+ tens1 =num1
+ tens2 =num2
+ ones_ans =ones
+ carry busy
+ ?retrieval>
+ buffer failure
+ ==>
+ =goal>
+ isa math_goal
+ =imaginal>
+ isa math_op
+ carry None
+ tens_ans busy
+ +retrieval>
+ isa math_op
+ arg1 =num1
+ arg2 =num2
""",
)
+ Model.productionstring(
+ name="add_tens_done",
+ string="""
+ =goal>
+ isa math_goal
+ =imaginal>
+ isa math_op
+ op add
+ tens_ans busy
+ carry None
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ ==>
+ =imaginal>
+ isa math_op
+ tens_ans =sum
+ """,
+ )
+
+ add_tens_carry = Model.productionstring(
+ name="add_tens_carry",
+ string="""
+ =goal>
+ isa math_goal
+ =imaginal>
+ isa math_op
+ op add
+ tens_ans busy
+ carry 1
+ =retrieval>
+ isa math_op
+ op add
+ result =sum
+ ==>
+ =imaginal>
+ isa math_op
+ carry None
+ +retrieval>
+ isa math_op
+ op add
+ arg1 1
+ arg2 =sum
+ """,
+ )
+
+ print("add_tens_carry: ", add_tens_carry)
+
# print(DM)
# unwind_prod()
+addition()
greater_than_prod()
# Model.goal.add(actr.makechunk("goal", "math_op", op="greater", arg1=5, arg2=9))
-print("g: ", g)
+print("goal: ", goal)
print("imaginal: ", imaginal)
x = Model.simulation()
x.run()