From 76ef769e1770ab0510845f7ffcc0299f0c165d4f Mon Sep 17 00:00:00 2001 From: "Dobbertin, Niclas" Date: Fri, 7 Jun 2024 18:42:14 +0200 Subject: visual bbbbroken --- modeling/model_env.py | 9 +++ modeling/prod_procedure.py | 164 ++++++++++++++++++++++++++++++++++++++++--- modeling/prod_vis.py | 46 ++++++++++++ modeling/productions_math.py | 37 +++++----- 4 files changed, 225 insertions(+), 31 deletions(-) create mode 100644 modeling/prod_vis.py (limited to 'modeling') diff --git a/modeling/model_env.py b/modeling/model_env.py index e609209..1565cf4 100644 --- a/modeling/model_env.py +++ b/modeling/model_env.py @@ -13,9 +13,18 @@ def get_env(): screen["MineralienVar"] = {"text": "2", "position": (200, 200)} screen["Gifte"] = {"text": "Gifte", "position": (300, 100)} + screen["GifteVar1"] = {"text": "3", "position": (300, 200)} + screen["GifteVar2"] = {"text": "4", "position": (300, 300)} + screen["GifteVar3"] = {"text": "5", "position": (300, 400)} + screen["GifteVar4"] = {"text": "6", "position": (300, 500)} screen["Sandstein"] = {"text": "Sandstein", "position": (400, 100)} + screen["SandsteinVar1"] = {"text": "3", "position": (400, 200)} + screen["SandsteinVar2"] = {"text": "4", "position": (400, 300)} + screen["SandsteinVar3"] = {"text": "5", "position": (400, 400)} + screen["SandsteinVar4"] = {"text": "6", "position": (400, 500)} + envs.append(screen) diff --git a/modeling/prod_procedure.py b/modeling/prod_procedure.py index de8039f..a40326d 100644 --- a/modeling/prod_procedure.py +++ b/modeling/prod_procedure.py @@ -19,7 +19,7 @@ def procedures(Model): ==> =g> isa math_goal - op retr_task + op retrieve_task +retrieval> isa procedure proc =proc @@ -34,7 +34,7 @@ def procedures(Model): =g> isa math_goal proc =proc - op retr_task + op retrieve_task nextop None result1 None =retrieval> @@ -43,6 +43,8 @@ def procedures(Model): op1 =op arg1_1 =arg1 arg1_2 =arg2 + arg1_1_idx =arg1_idx + arg1_2_idx =arg2_idx ==> =g> isa math_goal @@ -51,6 +53,8 @@ def procedures(Model): op =op arg1 =arg1 arg2 =arg2 + arg1_idx =arg1_idx + arg2_idx =arg2_idx result None expand_slot None hundreds1 None @@ -69,6 +73,118 @@ def procedures(Model): ) prods.append(proc_start_task1) + proc_check_substitute_var1 = Model.productionstring( + name="proc_substitute_var1", + string=""" + =g> + isa math_goal + arg1 ~None + arg1 =arg1 + op =op + nextop None + ==> + +retrieval> + isa number + number =arg1 + =g> + isa math_goal + op check_if_number_arg1 + nextop =op + """ + ) + + proc_check_substitute_var1_number = Model.productionstring( + name="proc_substitute_var1_number", + string=""" + =g> + isa math_goal + arg1 =arg1 + op check_if_number_arg1 + nextop =op + =retrieval> + isa number + number =arg1 + ==> + =g> + isa math_goal + op =op + nextop None + """ + ) + + proc_check_substitute_var1_error = Model.productionstring( + name="proc_substitute_var1_error", + string=""" + =g> + isa math_goal + arg1 =arg1 + op check_if_number_arg1 + nextop =op + ?retrieval> + state error + ==> + =g> + isa math_goal + op vis_find_arg1 + """ + ) + + proc_check_substitute_var2 = Model.productionstring( + name="proc_substitute_var2", + string=""" + =g> + isa math_goal + arg2 ~None + arg2 =arg2 + op =op + nextop None + ==> + +retrieval> + isa number + number =arg2 + =g> + isa math_goal + op check_if_number_arg2 + nextop =op + """ + ) + + proc_check_substitute_var2_number = Model.productionstring( + name="proc_substitute_var2_number", + string=""" + =g> + isa math_goal + arg2 =arg2 + op check_if_number_arg2 + nextop =op + =retrieval> + isa number + number =arg2 + ==> + =g> + isa math_goal + op =op + nextop None + """ + ) + + proc_check_substitute_var2_error = Model.productionstring( + name="proc_substitute_var2_error", + string=""" + =g> + isa math_goal + arg2 =arg2 + op check_if_number_arg2 + nextop =op + ?retrieval> + state error + ==> + =g> + isa math_goal + op vis_find_arg2 + """ + ) + proc_harvest_task1 = Model.productionstring( name="proc_harvest_task1", string=""" @@ -109,11 +225,7 @@ def procedures(Model): isa procedure proc =proc op1 =op1 - arg1_1 =arg1_1 - arg1_2 =arg1_2 op2 =op2 - arg2_1 =arg2_1 - arg2_2 =arg2_2 ==> =g> isa math_goal @@ -123,20 +235,46 @@ def procedures(Model): result1 =result1 result2 =result2 ~retrieval> - +manual> - isa _manual - cmd press_key - key 1 """, ) + proc_substitute_result1_left = Model.productionstring( + name="proc_substitute_result1_left", + string=""" + =g> + isa math_goal + arg1 result1 + result1 ~None + result1 =result1 + ==> + =g> + isa math_goal + arg1 =result1 + """ + ) + + proc_substitute_result1_right = Model.productionstring( + name="proc_substitute_result1_right", + string=""" + =g> + isa math_goal + arg2 result1 + result1 ~None + result1 =result1 + ==> + =g> + isa math_goal + arg2 =result1 + """ + ) + proc_start_task2 = Model.productionstring( name="proc_start_task2", string=""" =g> isa math_goal proc =proc - op retr_task + op retrieve_task nextop None result1 ~None result2 None @@ -146,6 +284,8 @@ def procedures(Model): op2 =op arg2_1 =arg1 arg2_2 =arg2 + arg2_1_idx =arg1_idx + arg2_2_idx =arg2_idx ==> =g> isa math_goal @@ -154,6 +294,8 @@ def procedures(Model): op =op arg1 =arg1 arg2 =arg2 + arg1_idx =arg1_idx + arg2_idx =arg2_idx result None expand_slot None hundreds1 None diff --git a/modeling/prod_vis.py b/modeling/prod_vis.py new file mode 100644 index 0000000..893c588 --- /dev/null +++ b/modeling/prod_vis.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +def procedures(Model): + prods = [] + + vis_find_arg1_header = Model.productionstring( + name = "vis_find_arg1_header", + string=""" + =g> + isa math_goal + op vis_find_arg1 + arg1 =var + ==> + =g> + isa math_goal + op find_arg1_header + +visual_location> + isa _visuallocation + value =var + """ + ) + + # vis_find_arg1_header_done = Model.productionstring( + # name = "vis_find_arg1_header_done", + # string=""" + # =g> + # isa math_goal + # op find_arg1_header + # arg1 =var + # arg1_idx =idx + # =visual> + # isa _visual + # screen_y =vis_y + # ==> + # =g> + # isa math_goal + # op search_arg1_idx + # +visual> + # isa _visual + # cmd move_attention + # screen_x current + # screen_y nearest + # """ + # ) + + return prods diff --git a/modeling/productions_math.py b/modeling/productions_math.py index 580a031..120dddf 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -7,6 +7,7 @@ import prod_multi import prod_numbers import prod_procedure import prod_motor +import prod_vis import model_env @@ -30,10 +31,14 @@ def init(): "proc", "op1", "arg1_1", + "arg1_1_idx" "arg1_2", + "arg1_2_idx" "op2", "arg2_1", + "arg2_1_idx" "arg2_2", + "arg2_2_idx" ), ) actr.chunktype( @@ -45,7 +50,9 @@ def init(): "op", "nextop", "arg1", + "arg1_idx" "arg2", + "arg2_idx" "result", "expand_slot", "hundreds1", @@ -79,11 +86,15 @@ def init(): "procedure", proc="proc1", op1="add", - arg1_1=99, - arg1_2=211, + arg1_1="Algen", + arg1_1_idx=1, + arg1_2="Mineralien", + arg1_2_idx=1, op2="greater", - arg2_1=10, - arg2_2=2, + arg2_1="result1", + arg2_1_idx=0, + arg2_2="Algen", + arg2_2_idx=1, ) ) @@ -135,21 +146,6 @@ def init(): def add_goal(goal, op, arg1, arg2): 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): @@ -198,6 +194,7 @@ def start(): less_prods = prod_comp.less_than(Model) multi_prods = prod_multi.multiplication(Model) motor_prods = prod_motor.procedures(Model) + visual_prods = prod_vis.procedures(Model) # for prod in multi_prods: # print(prod) @@ -218,7 +215,7 @@ def start(): # x.run(max_time=8) print("Simulation time: ", sim.show_time()) print("goal: ", goal) - print(list(env)) + # print(list(env)) # print("imaginal: ", imaginal) # imaginal.show("hundreds_ans") # imaginal.show("tens_ans") -- cgit v1.2.3