diff options
author | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-04-16 11:40:09 +0200 |
---|---|---|
committer | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-04-16 11:40:09 +0200 |
commit | ee5e4fbb8c211beb8e643116ee62b2592c6b3150 (patch) | |
tree | 0b5e4e9936f575b1f0f73ce599af7d10fc5a0c6a /modeling/prod_multi.py | |
parent | 9f5afe40e26ec2995bf19b86efb73a212abab12e (diff) |
start prod mul
Diffstat (limited to 'modeling/prod_multi.py')
-rw-r--r-- | modeling/prod_multi.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/modeling/prod_multi.py b/modeling/prod_multi.py new file mode 100644 index 0000000..667241e --- /dev/null +++ b/modeling/prod_multi.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + + +def multiplication(Model): + prods = [] + + # TODO: switch operands so less steps are needed + # switch_mul = Model.productionstring( + # name="switch_mul", + # string=""" + # =g> + # =imaginal> + # ==> + # =imaginal> + # """, + # ) + # prods.append(switch_mul) + + start_mul = Model.productionstring( + name="start_mul", + string=""" + =g> + isa math_goal + op mul + task calc + =imaginal> + isa math_op + op mul + arg1 ~0 + arg1 ~1 + arg2 ~0 + arg1 ~1 + arg1 =mul + arg2 =arg + ones2 =ones + tens2 =tens + hundreds2 =huns + ==> + !g> + show terminal + +g> + isa math_goal + op add + task calc + +imaginal> + isa math_op + op add + arg1 =arg + ones1 =ones + tens1 =tens + hundreds1 =huns + arg2 =arg + ones2 =ones + tens2 =tens + hundreds2 =huns + +retrieval> + isa math_op + op add + arg1 =arg + arg2 =arg + """, + ) + prods.append(start_mul) + + + step_mul = Model.productionstring( + name="step_mul", + string=""" + =g> + isa math_goal + op mul + task calc + =imaginal> + isa math_op + op mul + arg2 =arg + =retrieval> + isa math_op + op add + arg1 =arg + arg2 =arg + result =sum + ==> + =g> + isa math_goal + op mul + one_ans =sum + """, + ) + prods.append(step_mul) + + return prods |