From 6cb9ee72ba1b2dffcbe418129a110c1d0bbcc0b3 Mon Sep 17 00:00:00 2001 From: "Dobbertin, Niclas" Date: Fri, 10 May 2024 09:08:22 +0200 Subject: progress --- modeling/productions_math.py | 113 ++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 55 deletions(-) (limited to 'modeling/productions_math.py') diff --git a/modeling/productions_math.py b/modeling/productions_math.py index 182a208..635efff 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -16,17 +16,21 @@ def init(): DM = Model.decmem goal = Model.goal - imaginal = Model.set_goal(name="imaginal", delay=0) + imaginal = Model.set_goal(name="imaginal", delay=0.2) actr.chunktype("number", ("number", "next", "ones", "tens", "hundreds")) - actr.chunktype("math_goal", ("op", "task")) + actr.chunktype("procedure", ("proc", "op1", "arg1_1", "arg1_2")) actr.chunktype( - "math_op", + "math_goal", ( + "task", "op", + "nextop", "arg1", "arg2", "result", + "expand_slot", + "contract_slot", "hundreds1", "tens1", "ones1", @@ -36,11 +40,19 @@ def init(): "hundreds_ans", "tens_ans", "ones_ans", - "carry_ones", - "carry_tens", + "mul_counter", + "carry", + ), + ) + actr.chunktype( + "math_op", + ( + "op", + "arg1", + "arg2", + "result", ), ) - # Add numbers 0-999 to decmem for i in range(0, 1000): @@ -86,55 +98,42 @@ def init(): ) return Model, DM, goal, imaginal -def add_goal(goal, imaginal, op, arg1, arg2): - - goal.add(actr.makechunk("", "math_goal", op=op, task="calc")) - imaginal.add( - actr.makechunk( - "", - "math_op", - op=op, - arg1=arg1, - arg2=arg2, - ones1=get_digit(arg1, 0), - tens1=get_digit(arg1, 1), - hundreds1=get_digit(arg1, 2), - ones2=get_digit(arg2, 0), - tens2=get_digit(arg2, 1), - hundreds2=get_digit(arg2, 2), - ) - ) +def add_goal(goal, op, arg1, arg2): -def unwind_prod(): - # Model.productionstring( - # name="init_math_op", - # string=""" - # =g> - # isa math_op - # task None - # arg1 =num1 - # arg2 =num2 - # ==> - # +retrieval> - # isa number - # number =num1 - # =g> - # task unwind_left - # """, - # ) + goal.add(actr.makechunk("", "math_goal", op=op, task=op, arg1=arg1, arg2=arg2)) + # imaginal.add( + # actr.makechunk( + # "", + # "math_op", + # op=op, + # arg1=arg1, + # arg2=arg2, + # ones1=get_digit(arg1, 0), + # tens1=get_digit(arg1, 1), + # hundreds1=get_digit(arg1, 2), + # ones2=get_digit(arg2, 0), + # tens2=get_digit(arg2, 1), + # hundreds2=get_digit(arg2, 2), + # ) + #) + + +def general_prod(Model): Model.productionstring( - name="terminate_op", + name="continue_with_next_op", string=""" =g> isa math_goal - task finished_op - =imaginal> - isa math_op - result =answer + op done + nextop ~None + nextop =nextop ==> - ~g>""", + =g> + isa math_goal + op =nextop + """, ) @@ -146,20 +145,20 @@ def wait_input(): def start(): - while(True): + while True: op, arg1, arg2 = wait_input() Model, DM, goal, imaginal = init() - add_goal(goal, imaginal, op, arg1, arg2) + add_goal(goal, op, arg1, arg2) - # unwind_prod() + general_prod(Model) add_prods = prod_addition.addition(Model) greater_prods = prod_comp.greater_than(Model) less_prods = prod_comp.less_than(Model) multi_prods = prod_multi.multiplication(Model) - for prod in add_prods: - print(prod) - print("\n") + # for prod in multi_prods: + # print(prod) + # print("\n") print("goal: ", goal) print("imaginal: ", imaginal) @@ -177,8 +176,12 @@ def start(): result_num = result_huns + result_tens + result_ones print(result_num) # 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"] + 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) -- cgit v1.2.3