summaryrefslogtreecommitdiff
path: root/modeling/prod_multi.py
diff options
context:
space:
mode:
Diffstat (limited to 'modeling/prod_multi.py')
-rw-r--r--modeling/prod_multi.py156
1 files changed, 102 insertions, 54 deletions
diff --git a/modeling/prod_multi.py b/modeling/prod_multi.py
index 4b4e7c5..9009f6b 100644
--- a/modeling/prod_multi.py
+++ b/modeling/prod_multi.py
@@ -16,15 +16,12 @@ def multiplication(Model):
# )
# prods.append(switch_mul)
- start_mul = Model.productionstring(
- name="start_mul",
+ mul_start = Model.productionstring(
+ name="mul_start",
string="""
=g>
isa math_goal
op mul
- =imaginal>
- isa math_op
- op mul
arg1 ~0
arg1 ~1
arg2 ~0
@@ -34,25 +31,14 @@ def multiplication(Model):
ones2 =ones
tens2 =tens
hundreds2 =huns
+ mul_counter None
+ ?retrieval>
+ state free
==>
- !g>
- show terminal
- +g>
+ =g>
isa math_goal
- op add
- task mul
- +imaginal>
- isa math_op
- op add
- arg1 =arg
- ones1 =ones
- tens1 =tens
- hundreds1 =huns
- arg2 =arg
- ones2 =ones
- tens2 =tens
- hundreds2 =huns
- mul_counter =mul
+ mul_counter 1
+ result =arg
+retrieval>
isa math_op
op add
@@ -60,66 +46,128 @@ def multiplication(Model):
arg2 =arg
""",
)
- prods.append(start_mul)
+ prods.append(mul_start)
- count_mul = Model.productionstring(
- name="count_mul",
+ mul_step_success = Model.productionstring(
+ name="mul_step_success",
string="""
=g>
isa math_goal
- op add_done
- task mul
- =imaginal>
+ op mul
+ arg1 =mul
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ mul_counter =mul_counter
+ result =result
+ =retrieval>
isa math_op
op add
- mul_counter =counter
+ arg1 =arg
+ arg2 =result
+ result =sum
==>
=g>
isa math_goal
- op count_done
+ result =sum
+retrieval>
isa math_op
op add
- arg1 1
- result =counter
- """
+ arg1 =mul_counter
+ arg2 1
+ """,
)
+ prods.append(mul_step_success)
- step_mul = Model.productionstring(
- name="step_mul",
+ mul_done = Model.productionstring(
+ name="mul_done",
string="""
=g>
isa math_goal
- op count_done
- task mul
- =imaginal>
+ op mul
+ arg1 =arg1
+ arg2 =arg2
+ mul_counter =mul_counter
+ =retrieval>
isa math_op
op add
- hundreds_ans =hun_ans
- tens_ans =ten_ans
- ones_ans =one_ans
- mul_counter =mul_counter
+ arg1 =mul_counter
+ arg2 1
+ result =arg1
+ ==>
+ =g>
+ isa math_goal
+ op done
+ """
+ )
+
+ mul_continue = Model.productionstring(
+ name="mul_continue",
+ string="""
+ =g>
+ isa math_goal
+ op mul
+ arg1 =arg1
+ arg2 =arg2
+ mul_counter =mul_counter
+ result =result
=retrieval>
isa math_op
op add
- result =mul_counter
- arg2 =new_counter
+ arg1 =mul_counter
+ arg2 1
+ result ~=arg1
+ result =counted
==>
=g>
isa math_goal
- op mul
- task mul
- +imaginal>
+ mul_counter =counted
+ +retrieval>
isa math_op
+ op add
+ arg1 =arg2
+ arg2 =result
+ """
+ )
+
+
+ mul_step_failure = Model.productionstring(
+ name="mul_step_failure",
+ string="""
+ =g>
+ isa math_goal
op mul
- arg1 =new_counter
- ones1 =new_counter
- hundreds2 =hun_ans
- tens2 =ten_ans
- ones2 =one_ans
- mul_counter =new_counter
+ arg1 =mul
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ mul_counter =mul_counter
+ result =result
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ nextop mul
+ op add
+ arg1 =arg2
+ arg2 =result
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =mul_counter
+ arg2 1
""",
)
- prods.append(step_mul)
+
return prods