From 228a2ee1750b31e7045d4686473adc49ce6c4205 Mon Sep 17 00:00:00 2001 From: "Dobbertin, Niclas" Date: Wed, 22 May 2024 22:15:36 +0200 Subject: update --- modeling/prod_motor.py | 84 +++++++++++++++++++++++++++ modeling/prod_procedure.py | 133 ++++++++++++++++++++++++++++++++++++++++--- modeling/productions_math.py | 20 ++++--- 3 files changed, 223 insertions(+), 14 deletions(-) create mode 100644 modeling/prod_motor.py (limited to 'modeling') diff --git a/modeling/prod_motor.py b/modeling/prod_motor.py new file mode 100644 index 0000000..4ea03cf --- /dev/null +++ b/modeling/prod_motor.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 + +def procedures(Model): + prods = [] + + motor_press_result = Model.productionstring( + name = "motor_press_result", + string=""" + =g> + isa math_goal + op type_ans + result2 ~None + result2 =result + ==> + =g> + isa math_goal + op press_tens + arg1 =result + ones1 None + tens1 None + """ + ) + + motor_press_tens = Model.productionstring( + name = "motor_press_tens", + string=""" + =g> + isa math_goal + op press_tens + tens1 ~None + tens1 =key + ?manual> + state free + ==> + =g> + isa math_goal + op press_ones + +manual> + isa _manual + cmd press_key + key =key + """ + ) + + motor_press_ones = Model.productionstring( + name = "motor_press_ones", + string=""" + =g> + isa math_goal + op press_ones + ones1 ~None + ones1 =key + ?manual> + state free + ==> + =g> + isa math_goal + op press_continue + +manual> + isa _manual + cmd press_key + key =key + """ + ) + + motor_press_continue = Model.productionstring( + name = "motor_press_continue", + string=""" + =g> + isa math_goal + op press_continue + ?manual> + state free + ==> + =g> + isa math_goal + +manual> + isa _manual + cmd press_key + key 'space' + """ + ) + + return prods diff --git a/modeling/prod_procedure.py b/modeling/prod_procedure.py index 9b1cbaf..de8039f 100644 --- a/modeling/prod_procedure.py +++ b/modeling/prod_procedure.py @@ -14,7 +14,12 @@ def procedures(Model): nextop None ?retrieval> state free + ?imaginal> + state free ==> + =g> + isa math_goal + op retr_task +retrieval> isa procedure proc =proc @@ -29,23 +34,37 @@ def procedures(Model): =g> isa math_goal proc =proc - op None + op retr_task nextop None + result1 None =retrieval> isa procedure proc =proc - result1 None op1 =op arg1_1 =arg1 arg1_2 =arg2 ==> - +g> + =g> isa math_goal proc =proc task 1 op =op arg1 =arg1 arg2 =arg2 + result None + expand_slot None + hundreds1 None + tens1 None + ones1 None + hundreds2 None + tens2 None + ones2 None + hundreds_ans None + tens_ans None + ones_ans None + mul_counter None + ones_carry None + tens_carry None """, ) prods.append(proc_start_task1) @@ -64,6 +83,9 @@ def procedures(Model): ?retrieval> state free ==> + =g> + isa math_goal + op harvest1 +retrieval> isa procedure proc =proc @@ -77,8 +99,9 @@ def procedures(Model): isa math_goal proc =proc task 1 - op done + op harvest1 nextop None + result2 =result2 =imaginal> isa math_op result =result1 @@ -91,21 +114,117 @@ def procedures(Model): op2 =op2 arg2_1 =arg2_1 arg2_2 =arg2_2 + ==> + =g> + isa math_goal + proc =proc + op None + nextop None + result1 =result1 result2 =result2 + ~retrieval> + +manual> + isa _manual + cmd press_key + key 1 + """, + ) + + proc_start_task2 = Model.productionstring( + name="proc_start_task2", + string=""" + =g> + isa math_goal + proc =proc + op retr_task + nextop None + result1 ~None + result2 None + =retrieval> + isa procedure + proc =proc + op2 =op + arg2_1 =arg1 + arg2_2 =arg2 ==> - +g> + =g> isa math_goal proc =proc - +imaginal> + task 2 + op =op + arg1 =arg1 + arg2 =arg2 + result None + expand_slot None + hundreds1 None + tens1 None + ones1 None + hundreds2 None + tens2 None + ones2 None + hundreds_ans None + tens_ans None + ones_ans None + mul_counter None + ones_carry None + tens_carry None + """, + ) + prods.append(proc_start_task2) + + proc_harvest_task2 = Model.productionstring( + name="proc_harvest_task2", + string=""" + =g> + isa math_goal + proc =proc + task 2 + op done + nextop None + =imaginal> + isa math_op + ?retrieval> + state free + ==> + =g> + isa math_goal + op harvest2 + +retrieval> + isa procedure + proc =proc + """, + ) + + proc_harvest_task2_done = Model.productionstring( + name="proc_harvest_task2_done", + string=""" + =g> + isa math_goal + proc =proc + task 2 + op harvest2 + nextop None + result1 =result1 + =imaginal> + isa math_op + result =result2 + =retrieval> isa procedure proc =proc op1 =op1 arg1_1 =arg1_1 arg1_2 =arg1_2 - result1 =result1 op2 =op2 arg2_1 =arg2_1 arg2_2 =arg2_2 + ==> + =g> + isa math_goal + proc =proc + op type_ans + nextop None + result1 =result1 result2 =result2 + ~retrieval> """, ) diff --git a/modeling/productions_math.py b/modeling/productions_math.py index 9e0911a..b179102 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -6,6 +6,7 @@ import prod_comp import prod_multi import prod_numbers import prod_procedure +import prod_motor # https://stackoverflow.com/a/39644726 @@ -28,17 +29,17 @@ def init(): "op1", "arg1_1", "arg1_2", - "result1", "op2", "arg2_1", "arg2_2", - "result2", ), ) actr.chunktype( "math_goal", ( "task", + "result1", + "result2", "op", "nextop", "arg1", @@ -76,11 +77,11 @@ def init(): "procedure", proc="proc1", op1="add", - arg1_1=9, - arg1_2=2, + arg1_1=99, + arg1_2=211, op2="greater", - arg2_1=100, - arg2_2=200, + arg2_1=10, + arg2_2=2, ) ) @@ -192,6 +193,7 @@ def start(): greater_prods = prod_comp.greater_than(Model) less_prods = prod_comp.less_than(Model) multi_prods = prod_multi.multiplication(Model) + motor_prods = prod_motor.procedures(Model) # for prod in multi_prods: # print(prod) @@ -200,7 +202,7 @@ def start(): print("goal: ", goal) # print("imaginal: ", imaginal) x = Model.simulation() - x.run(max_time=3) + x.run(max_time=4) print("goal: ", goal) # print("imaginal: ", imaginal) # imaginal.show("hundreds_ans") @@ -220,6 +222,10 @@ def start(): # x for x in list(DM) if x.typename != "number" and x.typename == "math_op" # ] # print(numbers) + math_goals = [ + x for x in list(DM) if x.typename == "procedure" + ] + print(math_goals) if __name__ == "__main__": -- cgit v1.2.3