diff options
Diffstat (limited to 'modeling')
-rw-r--r-- | modeling/model_env.py | 2 | ||||
-rw-r--r-- | modeling/prod_subtraction.py | 600 | ||||
-rw-r--r-- | modeling/productions_math.py | 4 |
3 files changed, 604 insertions, 2 deletions
diff --git a/modeling/model_env.py b/modeling/model_env.py index ab4b219..473995e 100644 --- a/modeling/model_env.py +++ b/modeling/model_env.py @@ -8,7 +8,7 @@ def get_env(): # Variables screen["Algen"] = {"text": "Algen", "position": (100, 100)} - screen["AlgenVar"] = {"text": "1", "position": (100, 200)} + screen["AlgenVar"] = {"text": "3", "position": (100, 200)} screen["Mineralien"] = {"text": "Mineralien", "position": (200, 100)} screen["MineralienVar"] = {"text": "2", "position": (200, 200)} diff --git a/modeling/prod_subtraction.py b/modeling/prod_subtraction.py new file mode 100644 index 0000000..a0ac8b7 --- /dev/null +++ b/modeling/prod_subtraction.py @@ -0,0 +1,600 @@ +#!/usr/bin/env python3 + + +def subtraction(Model): + prods = [] + + start_sub = Model.productionstring( + name="start_sub", + string=""" + =g> + isa math_goal + op sub + arg1 =arg1 + arg2 =arg2 + ?retrieval> + state free + ==> + =g> + isa math_goal + +retrieval> + isa math_op + op sub + arg1 =arg1 + arg2 =arg2 + """, + ) + + # Can remember addition fact, addition done + sub_retrieve_success = Model.productionstring( + name="sub_retrieve_success", + string=""" + =g> + isa math_goal + op sub + arg1 =arg1 + arg2 =arg1 + =retrieval> + isa math_op + op add + arg1 =arg1 + arg2 =arg2 + result =result + ==> + =g> + isa math_goal + op done + result =result + +imaginal> + isa math_op + op sub + arg1 =arg1 + arg2 =arg2 + result =result + ~retrieval> + """, + ) + sub_retrieve_failure = Model.productionstring( + name="sub_retrieve_failure", + string=""" + =g> + isa math_goal + op sub + ones1 =num1 + ones2 =num2 + ?retrieval> + state error + ==> + =g> + isa math_goal + op sub_ones + ones_carry 0 + tens_carry 0 + +retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + """, + ) + + sub_ones_ok = Model.productionstring( + name="sub_ones_ok", + string=""" + =g> + isa math_goal + op sub_ones + ones1 =num1 + ones2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num1 + ==> + =g> + isa math_goal + op sub_ones + +retrieval> + isa math_op + op add + result =num1 + arg1 =num2 + """, + ) + + # subtrahent greater than minuent + sub_ones_too_large_start = Model.productionstring( + name="sub_ones_too_large_start", + string=""" + =g> + isa math_goal + op sub_ones + ones1 =num1 + ones2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num2 + ==> + =g> + isa math_goal + op sub_ones_large + ones_carry 1 + +retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + """, + ) + sub_ones_too_large_done = Model.productionstring( + name="sub_ones_too_large_done", + string=""" + =g> + isa math_goal + op sub_ones_large + ones1 =num1 + ones2 =num2 + ones_carry 1 + =retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + result =result + ==> + =g> + isa math_goal + op sub_ones + +retrieval> + isa math_op + op add + result =result + arg1 =num2 + """, + ) + + sub_ones_done = Model.productionstring( + name="sub_ones_done", + string=""" + =g> + isa math_goal + op sub_ones + ones2 =num2 + =retrieval> + isa math_op + op add + arg1 =num2 + arg2 =result + ==> + =g> + isa math_goal + op sub_tens + ones_ans =result + ~retrieval> + """, + ) + + sub_tens_with_carry = Model.productionstring( + name="sub_tens_with_carry", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + ones_carry 1 + ?retrieval> + state free + ==> + =g> + isa math_goal + op sub_tens + +retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + """, + ) + sub_tens_with_carry_done = Model.productionstring( + name="sub_tens_with_carry_done", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + ones_carry 1 + =retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + result ~10 + result =result + ==> + =g> + isa math_goal + op sub_tens + ones_carry 0 + tens2 =result + ~retrieval> + """, + ) + sub_tens_with_carry_done_10 = Model.productionstring( + name="sub_tens_with_carry_done_10", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + ones_carry 1 + =retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + result 10 + ==> + =g> + isa math_goal + op sub_tens + ones_carry 0 + tens_carry 1 + tens2 0 + ~retrieval> + """, + ) + + sub_tens_no_carry = Model.productionstring( + name="sub_tens_no_carry", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + ones_carry 0 + ?retrieval> + state free + ==> + =g> + isa math_goal + op sub_tens + +retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + """, + ) + sub_tens_ok = Model.productionstring( + name="sub_tens_ok", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num1 + ==> + =g> + isa math_goal + op sub_tens + +retrieval> + isa math_op + op add + result =num1 + arg1 =num2 + """, + ) + + # subtrahent greater than minuent + sub_tens_too_large_start = Model.productionstring( + name="sub_tens_too_large_start", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num2 + ==> + =g> + isa math_goal + op sub_tens + tens_carry 1 + +retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + """, + ) + sub_tens_too_large_done = Model.productionstring( + name="sub_tens_too_large_done", + string=""" + =g> + isa math_goal + op sub_tens + tens1 =num1 + tens2 =num2 + tens_carry 1 + =retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + result =result + ==> + =g> + isa math_goal + op sub_tens + +retrieval> + isa math_op + op add + result =result + arg1 =num2 + """, + ) + + sub_tens_done = Model.productionstring( + name="sub_tens_done", + string=""" + =g> + isa math_goal + op sub_tens + tens2 =num2 + =retrieval> + isa math_op + op add + arg1 =num2 + arg2 =result + ==> + =g> + isa math_goal + op sub_hundreds + tens_ans =result + ~retrieval> + """, + ) + + sub_hundreds_with_carry = Model.productionstring( + name="sub_hundreds_with_carry", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + tens_carry 1 + ?retrieval> + state free + ==> + =g> + isa math_goal + op sub_hundreds + +retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + """, + ) + sub_hundreds_with_carry_done = Model.productionstring( + name="sub_hundreds_with_carry_done", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + tens_carry 1 + =retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + result ~10 + result =result + ==> + =g> + isa math_goal + op sub_hundreds + tens_carry 0 + hundreds2 =result + ~retrieval> + """, + ) + sub_hundreds_with_carry_done_10 = Model.productionstring( + name="sub_hundreds_with_carry_done_10", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + tens_carry 1 + =retrieval> + isa math_op + op add + arg1 1 + arg2 =num2 + result 10 + ==> + =g> + isa math_goal + op sub_hundreds + tens_carry 0 + hundreds_carry 1 + hundreds2 0 + ~retrieval> + """, + ) + + sub_hundreds_no_carry = Model.productionstring( + name="sub_hundreds_no_carry", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + tens_carry 0 + ?retrieval> + state free + ==> + =g> + isa math_goal + op sub_hundreds + +retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + """, + ) + sub_hundreds_ok = Model.productionstring( + name="sub_hundreds_ok", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num1 + ==> + =g> + isa math_goal + op sub_hundreds + +retrieval> + isa math_op + op add + result =num1 + arg1 =num2 + """, + ) + + # subtrahent greater than minuent + sub_hundreds_too_large_start = Model.productionstring( + name="sub_hundreds_too_large_start", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + =retrieval> + isa math_op + op greater + arg1 =num1 + arg2 =num2 + result =num2 + ==> + =g> + isa math_goal + op sub_hundreds + hundreds_carry 1 + +retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + """, + ) + sub_hundreds_too_large_done = Model.productionstring( + name="sub_hundreds_too_large_done", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + hundreds_carry 1 + =retrieval> + isa math_op + op add + arg1 =num1 + arg2 10 + result =result + ==> + =g> + isa math_goal + op sub_hundreds + +retrieval> + isa math_op + op add + result =result + arg1 =num2 + """, + ) + + sub_hundreds_done = Model.productionstring( + name="sub_hundreds_done", + string=""" + =g> + isa math_goal + op sub_hundreds + hundreds1 =num1 + hundreds2 =num2 + =retrieval> + isa math_op + op add + arg1 =num2 + arg2 =result + ==> + =g> + isa math_goal + op sub_done + hundreds_ans =result + ~retrieval> + """, + ) + + sub_done = Model.productionstring( + name="sub_done", + string=""" + =g> + isa math_goal + op sub_done + arg1 =arg1 + arg2 =arg2 + result ~None + result =result + ==> + +imaginal> + isa math_op + op sub + arg1 =arg1 + arg2 =arg2 + result =result + =g> + isa math_goal + op done + ones_carry None + tens_carry None + ~retrieval> + """, + ) + return prods diff --git a/modeling/productions_math.py b/modeling/productions_math.py index aa06ffb..7d7a94d 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -4,6 +4,7 @@ import pyactr as actr from model_init import init import prod_addition +import prod_subtraction import prod_comp import prod_multi import prod_numbers @@ -54,13 +55,14 @@ def start(): # op, arg1, arg2 = wait_input() Model, DM, goal, imaginal, env = init() # add_goal(goal, op, arg1, arg2) - add_proc(goal, "proc3") + add_proc(goal, "proc1") envs = model_env.get_env() general_prod(Model) prod_procedure.procedures(Model) number_prods = prod_numbers.number(Model) add_prods = prod_addition.addition(Model) + sub_prods = prod_subtraction.subtraction(Model) greater_prods = prod_comp.greater_than(Model) less_prods = prod_comp.lesser_than(Model) multi_prods = prod_multi.multiplication(Model) |