diff options
author | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-04-16 03:35:18 +0200 |
---|---|---|
committer | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-04-16 03:35:18 +0200 |
commit | 4411e6c43e26cd2979691fff8e0e3822f0aa291f (patch) | |
tree | b34520d68668b8ed0296d28ad9d14df2beea192f /modeling/prod_addition.py | |
parent | 1f851a832a8ff6993369056490658d2fd6d67460 (diff) |
working column addition
Diffstat (limited to 'modeling/prod_addition.py')
-rw-r--r-- | modeling/prod_addition.py | 325 |
1 files changed, 325 insertions, 0 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 |