diff options
Diffstat (limited to 'modeling/productions_math.py')
-rw-r--r-- | modeling/productions_math.py | 77 |
1 files changed, 57 insertions, 20 deletions
diff --git a/modeling/productions_math.py b/modeling/productions_math.py index 635efff..9e0911a 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -4,6 +4,8 @@ import pyactr as actr import prod_addition import prod_comp import prod_multi +import prod_numbers +import prod_procedure # https://stackoverflow.com/a/39644726 @@ -19,7 +21,20 @@ def init(): imaginal = Model.set_goal(name="imaginal", delay=0.2) actr.chunktype("number", ("number", "next", "ones", "tens", "hundreds")) - actr.chunktype("procedure", ("proc", "op1", "arg1_1", "arg1_2")) + actr.chunktype( + "procedure", + ( + "proc", + "op1", + "arg1_1", + "arg1_2", + "result1", + "op2", + "arg2_1", + "arg2_2", + "result2", + ), + ) actr.chunktype( "math_goal", ( @@ -30,7 +45,6 @@ def init(): "arg2", "result", "expand_slot", - "contract_slot", "hundreds1", "tens1", "ones1", @@ -41,7 +55,8 @@ def init(): "tens_ans", "ones_ans", "mul_counter", - "carry", + "ones_carry", + "tens_carry", ), ) actr.chunktype( @@ -54,6 +69,21 @@ def init(): ), ) + # Add procedures + DM.add( + actr.makechunk( + "procedure1", + "procedure", + proc="proc1", + op1="add", + arg1_1=9, + arg1_2=2, + op2="greater", + arg2_1=100, + arg2_2=200, + ) + ) + # Add numbers 0-999 to decmem for i in range(0, 1000): DM.add( @@ -116,7 +146,7 @@ def add_goal(goal, op, arg1, arg2): # tens2=get_digit(arg2, 1), # hundreds2=get_digit(arg2, 2), # ) - #) + # ) def general_prod(Model): @@ -143,14 +173,21 @@ def wait_input(): arg2 = input("arg2\n") return op, int(arg1), int(arg2) +def add_proc(goal, proc): + input() + goal.add(actr.makechunk("", "math_goal", proc=proc, ones_carry="hello")) + def start(): while True: - op, arg1, arg2 = wait_input() + # op, arg1, arg2 = wait_input() Model, DM, goal, imaginal = init() - add_goal(goal, op, arg1, arg2) + # add_goal(goal, op, arg1, arg2) + add_proc(goal, "proc1") general_prod(Model) + prod_procedure.procedures(Model) + number_prods = prod_numbers.number(Model) add_prods = prod_addition.addition(Model) greater_prods = prod_comp.greater_than(Model) less_prods = prod_comp.less_than(Model) @@ -161,27 +198,27 @@ def start(): # print("\n") print("goal: ", goal) - print("imaginal: ", imaginal) + # print("imaginal: ", imaginal) x = Model.simulation() - x.run() + x.run(max_time=3) print("goal: ", goal) - print("imaginal: ", imaginal) + # print("imaginal: ", imaginal) # imaginal.show("hundreds_ans") # imaginal.show("tens_ans") # imaginal.show("ones_ans") - result_ones = str(getattr(imaginal._data.copy().pop(), "ones_ans")) - result_tens = str(getattr(imaginal._data.copy().pop(), "tens_ans")) - result_huns = str(getattr(imaginal._data.copy().pop(), "hundreds_ans")) + # result_ones = str(getattr(imaginal._data.copy().pop(), "ones_ans")) + # result_tens = str(getattr(imaginal._data.copy().pop(), "tens_ans")) + # result_huns = str(getattr(imaginal._data.copy().pop(), "hundreds_ans")) - result_num = result_huns + result_tens + result_ones - print(result_num) + # 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) |