summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
authorDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-04-13 14:02:38 +0200
committerDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-04-13 14:02:38 +0200
commit9faaf8757a88de6593a0e800909b3164689c32a9 (patch)
treedb8a083fa28f4589ed954854fbe000d57def0a4e /modeling
parented52f56d1097000e5e37010d88bf2a4cde643811 (diff)
old addition
Diffstat (limited to 'modeling')
-rw-r--r--modeling/productions_math.py110
1 files changed, 73 insertions, 37 deletions
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index def6fe2..5e490a3 100644
--- a/modeling/productions_math.py
+++ b/modeling/productions_math.py
@@ -6,7 +6,7 @@ Model = actr.ACTRModel()
DM = Model.decmem
goal = Model.goal
-imaginal = Model.set_goal(name="imaginal", delay=0.2)
+imaginal = Model.set_goal(name="imaginal", delay=0)
actr.chunktype("number", ("number", "next", "ones", "tens", "hundreds"))
actr.chunktype("math_goal", ("op", "task"))
@@ -26,7 +26,8 @@ actr.chunktype(
"hundreds_ans",
"tens_ans",
"ones_ans",
- "carry",
+ "carry_ones",
+ "carry_tens",
),
)
@@ -36,13 +37,13 @@ imaginal.add(
"",
"math_op",
op="add",
- arg1=5,
- arg2=2,
- ones1=5,
- tens1=0,
+ arg1=39,
+ arg2=59,
+ ones1=9,
+ tens1=3,
hundreds1=0,
- ones2=2,
- tens2=0,
+ ones2=9,
+ tens2=5,
hundreds2=0,
)
)
@@ -68,8 +69,8 @@ for i in range(0, 1000):
)
# Add comparison relations to single digit numbers
-for i in range(0, 10):
- for j in range(0, 10):
+for i in range(0, 11):
+ for j in range(0, 11):
DM.add(
actr.makechunk(
f"greater{i}{j}",
@@ -178,21 +179,24 @@ def greater_than_prod():
def addition():
+ prods = []
+
start_add = Model.productionstring(
name="start_add",
string="""
- =goal>
+ =g>
isa math_goal
+ op add
task calc
=imaginal>
- isa math_op
+ isa math_op
op add
ones1 =num1
ones2 =num2
ones_ans None
==>
=imaginal>
- isa math_op
+ isa math_op
ones_ans busy
+retrieval>
isa math_op
@@ -201,12 +205,12 @@ def addition():
arg2 =num2
""",
)
- print("start_add: ", start_add)
+ prods.append(start_add)
add_ones = Model.productionstring(
name="add_ones",
string="""
- =goal>
+ =g>
isa math_goal
task calc
=imaginal>
@@ -224,7 +228,7 @@ def addition():
=imaginal>
isa math_op
ones_ans =result
- carry busy
+ carry_ones busy
+retrieval>
isa math_op
op add
@@ -232,12 +236,12 @@ def addition():
result =result
""",
)
- print(add_ones)
+ prods.append(add_ones)
- Model.productionstring(
- name="process_carry",
+ process_carry_ones = Model.productionstring(
+ name="process_carry_ones",
string="""
- =goal>
+ =g>
isa math_goal
task calc
=imaginal>
@@ -245,7 +249,7 @@ def addition():
op add
tens1 =num1
tens2 =num2
- carry busy
+ carry_ones busy
ones_ans =ones
=retrieval>
isa math_op
@@ -257,7 +261,7 @@ def addition():
=imaginal>
isa math_op
op add
- carry 1
+ carry_ones 1
tens_ans busy
ones_ans =remainder
+retrieval>
@@ -267,11 +271,12 @@ def addition():
arg2 =num2
""",
)
+ prods.append(process_carry_ones)
- Model.productionstring(
- name="no_carry",
+ no_carry_ones = Model.productionstring(
+ name="no_carry_ones",
string="""
- =goal>
+ =g>
isa math_goal
task calc
=imaginal>
@@ -280,13 +285,13 @@ def addition():
tens1 =num1
tens2 =num2
ones_ans =ones
- carry busy
+ carry_ones busy
?retrieval>
- buffer failure
+ state error
==>
=imaginal>
isa math_op
- carry None
+ carry_ones None
tens_ans busy
+retrieval>
isa math_op
@@ -294,48 +299,58 @@ def addition():
arg2 =num2
""",
)
+ prods.append(no_carry_ones)
- Model.productionstring(
+ add_tens_done = Model.productionstring(
name="add_tens_done",
string="""
- =goal>
+ =g>
isa math_goal
task calc
=imaginal>
isa math_op
op add
tens_ans busy
- carry None
+ 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="""
- =goal>
+ =g>
isa math_goal
task calc
=imaginal>
isa math_op
op add
tens_ans busy
- carry 1
+ tens1 =num1
+ tens2 =num2
+ carry_ones 1
=retrieval>
isa math_op
op add
result =sum
+ arg1 =num1
+ arg2 =num2
==>
=imaginal>
isa math_op
- carry None
+ carry_ones None
+ ~retrieval>
+retrieval>
isa math_op
op add
@@ -344,20 +359,41 @@ def addition():
""",
)
- print("add_tens_carry: ", add_tens_carry)
+ prods.append(add_tens_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()
-addition()
-greater_than_prod()
+add_prods = addition()
+# greater_than_prod()
+
+for prod in add_prods:
+ print(prod)
+ print("\n")
# Model.goal.add(actr.makechunk("goal", "math_op", op="greater", arg1=5, arg2=9))
print("goal: ", goal)
print("imaginal: ", imaginal)
x = Model.simulation()
x.run()
+print("goal: ", goal)
+print("imaginal: ", imaginal)
# print(list(DM))
numbers = [x for x in list(DM) if x.typename != "number" and x.typename != "math_op"]
+numbers = [x for x in list(DM) if x.typename != "number" and x.typename == "math_op"]
# print(numbers)