summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
authorDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-09-02 08:12:53 +0200
committerDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-09-02 08:12:53 +0200
commitbe9aa2cc897ce4ff8a42617f9707c179e0eeddbd (patch)
treeced84404b1b0838081664fab0c5ce8a12c7432bd /modeling
parent7c1d45b574de33dafcd93b251fc089acff313292 (diff)
update
Diffstat (limited to 'modeling')
-rw-r--r--modeling/model_init.py5
-rw-r--r--modeling/prod_addition.py1
-rw-r--r--modeling/prod_motor.py17
-rw-r--r--modeling/prod_multi.py6
-rw-r--r--modeling/prod_numbers.py44
-rw-r--r--modeling/prod_procedure.py25
-rw-r--r--modeling/prod_subtraction.py15
-rw-r--r--modeling/prod_vis.py52
-rw-r--r--modeling/productions_math.py24
9 files changed, 138 insertions, 51 deletions
diff --git a/modeling/model_init.py b/modeling/model_init.py
index 1231dc6..b476c71 100644
--- a/modeling/model_init.py
+++ b/modeling/model_init.py
@@ -42,6 +42,7 @@ def init():
"result2",
"op",
"nextop",
+ "nextnextop",
"arg1",
"arg1_idx",
"arg2",
@@ -250,11 +251,13 @@ def init():
op done
nextop ~None
nextop =nextop
+ nextnextop =nextnextop
==>
=g>
isa math_goal
op =nextop
- nextop None
+ nextop =nextnextop
+ nextnextop None
""",
)
diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py
index 12473d3..af848a4 100644
--- a/modeling/prod_addition.py
+++ b/modeling/prod_addition.py
@@ -84,7 +84,6 @@ def addition(Model):
op add
arg1 =num1
arg2 =num2
-
""",
)
prods.append(add_retrieve_failure)
diff --git a/modeling/prod_motor.py b/modeling/prod_motor.py
index 5c483e7..a13e64a 100644
--- a/modeling/prod_motor.py
+++ b/modeling/prod_motor.py
@@ -14,10 +14,11 @@ def procedures(Model):
==>
=g>
isa math_goal
- op press_tens
- arg1 =result
- ones1 None
- tens1 None
+ op expand
+ nextop press_tens
+ arg2 =result
+ ones2 None
+ tens2 None
"""
)
@@ -27,8 +28,8 @@ def procedures(Model):
=g>
isa math_goal
op press_tens
- tens1 ~None
- tens1 =key
+ tens2 ~None
+ tens2 =key
?manual>
state free
==>
@@ -48,8 +49,8 @@ def procedures(Model):
=g>
isa math_goal
op press_ones
- ones1 ~None
- ones1 =key
+ ones2 ~None
+ ones2 =key
?manual>
state free
==>
diff --git a/modeling/prod_multi.py b/modeling/prod_multi.py
index 9fd088d..811e418 100644
--- a/modeling/prod_multi.py
+++ b/modeling/prod_multi.py
@@ -195,6 +195,7 @@ def multiplication(Model):
arg1 =arg1
arg2 =arg2
result =result
+ ~retrieval>
""",
)
@@ -246,8 +247,9 @@ def multiplication(Model):
==>
=g>
isa math_goal
- nextop mul_fail
- op add
+ nextnextop mul_fail
+ nextop add
+ op expand
arg1 =arg
arg2 =result
mem_arg1 =mul
diff --git a/modeling/prod_numbers.py b/modeling/prod_numbers.py
index b914b73..cbc87e7 100644
--- a/modeling/prod_numbers.py
+++ b/modeling/prod_numbers.py
@@ -8,6 +8,7 @@ def number(Model):
string="""
=g>
isa math_goal
+ op expand
arg1 =num
ones1 None
expand_slot None
@@ -30,6 +31,7 @@ def number(Model):
string="""
=g>
isa math_goal
+ op expand
expand_slot arg1
arg1 =num
=retrieval>
@@ -50,13 +52,34 @@ def number(Model):
)
prods.append(number_expand_arg1_done)
+ number_expand_arg1_fail = Model.productionstring(
+ name="number_expand_arg1_fail",
+ string="""
+ =g>
+ isa math_goal
+ op expand
+ ones1 None
+ expand_slot arg1
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ expand_slot None
+ ~retrieval>
+ """
+ )
+ prods.append(number_expand_arg1_fail)
+
number_expand_arg2 = Model.productionstring(
name="number_expand_arg2",
string="""
=g>
isa math_goal
+ op expand
arg2 =num
+ ones1 ~None
ones2 None
expand_slot None
?retrieval>
@@ -73,11 +96,31 @@ def number(Model):
)
prods.append(number_expand_arg2)
+ number_expand_arg2_fail = Model.productionstring(
+ name="number_expand_arg2_fail",
+ string="""
+ =g>
+ isa math_goal
+ op expand
+ ones2 None
+ expand_slot arg2
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ expand_slot None
+ ~retrieval>
+ """
+ )
+ prods.append(number_expand_arg2_fail)
+
number_expand_arg2_done = Model.productionstring(
name="number_expand_arg2_done",
string="""
=g>
isa math_goal
+ op expand
expand_slot arg2
arg2 =num
=retrieval>
@@ -89,6 +132,7 @@ def number(Model):
==>
=g>
isa math_goal
+ op done
expand_slot None
ones2 =one
tens2 =ten
diff --git a/modeling/prod_procedure.py b/modeling/prod_procedure.py
index f9e2d7f..19e5b8a 100644
--- a/modeling/prod_procedure.py
+++ b/modeling/prod_procedure.py
@@ -39,11 +39,28 @@ def procedures(Model):
+retrieval>
isa procedure
proc =proc
-
""",
)
prods.append(proc_start)
+ proc_start_retry = Model.productionstring(
+ name="proc_start_retry",
+ string="""
+ =g>
+ isa math_goal
+ op retrieve_task
+ ?retrieval>
+ state error
+ ?imaginal>
+ state free
+ ==>
+ =g>
+ isa math_goal
+ op None
+ ~retrieval>
+ """,
+ )
+
proc_start_task1 = Model.productionstring(
name="proc_start_task1",
string="""
@@ -86,6 +103,7 @@ def procedures(Model):
mul_counter None
ones_carry None
tens_carry None
+ ~retrieval>
""",
)
prods.append(proc_start_task1)
@@ -189,15 +207,13 @@ def procedures(Model):
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
+ op expand
~retrieval>
"""
)
@@ -233,6 +249,7 @@ def procedures(Model):
isa math_op
?retrieval>
state free
+ buffer empty
==>
=g>
isa math_goal
diff --git a/modeling/prod_subtraction.py b/modeling/prod_subtraction.py
index 1d1f73e..b952dd9 100644
--- a/modeling/prod_subtraction.py
+++ b/modeling/prod_subtraction.py
@@ -80,6 +80,21 @@ def subtraction(Model):
arg2 =num2
""",
)
+ sub_ones_retry = Model.productionstring(
+ name="sub_ones_retry",
+ string="""
+ =g>
+ isa math_goal
+ op sub_ones
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ op sub_retrieve
+ ~retrieval>
+ """,
+ )
sub_ones_ok = Model.productionstring(
name="sub_ones_ok",
diff --git a/modeling/prod_vis.py b/modeling/prod_vis.py
index c3c113d..c997e1f 100644
--- a/modeling/prod_vis.py
+++ b/modeling/prod_vis.py
@@ -281,9 +281,6 @@ def procedures(Model):
isa _visuallocation
screen_x =screen_x
screen_y 200
- +retrieval>
- isa number
- number 1
""",
)
@@ -304,22 +301,15 @@ def procedures(Model):
screen_y =screen_y
?visual>
state free
- =retrieval>
- isa number
- number =vis_counter
- next =next
==>
=g>
isa math_goal
op search_arg1_idx
- vis_counter =next
+ vis_counter 2
+visual_location>
isa _visuallocation
screen_x =screen_x
screen_y 300
- +retrieval>
- isa number
- number =next
""",
)
@@ -340,22 +330,15 @@ def procedures(Model):
screen_y =screen_y
?visual>
state free
- =retrieval>
- isa number
- number =vis_counter
- next =next
==>
=g>
isa math_goal
op search_arg1_idx
- vis_counter =next
+ vis_counter 3
+visual_location>
isa _visuallocation
screen_x =screen_x
screen_y 400
- +retrieval>
- isa number
- number =next
""",
)
@@ -376,22 +359,15 @@ def procedures(Model):
screen_y =screen_y
?visual>
state free
- =retrieval>
- isa number
- number =vis_counter
- next =next
==>
=g>
isa math_goal
op search_arg1_idx
- vis_counter =next
+ vis_counter 4
+visual_location>
isa _visuallocation
screen_x =screen_x
screen_y 500
- +retrieval>
- isa number
- number =next
""",
)
@@ -567,6 +543,20 @@ def procedures(Model):
arg2 =value
""",
)
+ vis_max_arg1_search_check_retry = Model.productionstring(
+ name="vis_max_arg1_search_check_retry",
+ string="""
+ =g>
+ isa math_goal
+ op max_arg1_encode
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ op max_arg1_check
+ """
+ )
vis_max_arg1_search_step2_encode = Model.productionstring(
name="vis_max_arg1_search_step2_encode",
string="""
@@ -1240,7 +1230,7 @@ def procedures(Model):
==>
=g>
isa math_goal
- op done
+ op expand
arg2 =arg2
vis_counter None
expand_slot None
@@ -1539,7 +1529,7 @@ def procedures(Model):
==>
=g>
isa math_goal
- op done
+ op expand
arg2 =result
vis_counter None
expand_slot None
@@ -1837,7 +1827,7 @@ def procedures(Model):
==>
=g>
isa math_goal
- op done
+ op expand
arg2 =result
vis_counter None
expand_slot None
@@ -2183,7 +2173,7 @@ def procedures(Model):
==>
=g>
isa math_goal
- op done
+ op expand
arg2 =result
vis_counter None
expand_slot None
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index 07609bf..326b9c4 100644
--- a/modeling/productions_math.py
+++ b/modeling/productions_math.py
@@ -34,8 +34,8 @@ def add_proc(goal, proc):
def start():
condition = "fixed"
- training_N = 2
- test_N = 2
+ training_N = 1
+ test_N = 1
stimuli = model_env.Stimuli(condition, training_N=training_N, test_N=test_N)
@@ -54,6 +54,7 @@ def start():
# Model.model_parameters["subsymbolic"] = True
# Model.model_parameters["partial_matching"] = True
Model.model_parameters["activation_trace"] = True
+ Model.model_parameters["instantaneous_noise"] = .2
Model.model_parameters["utility_alpha"] = 0.5
Model.model_parameters["utility_noise"] = 0.5
Model.model_parameters["production_compilation"] = True
@@ -84,6 +85,8 @@ def start():
# triggers="space",
triggers="b",
)
+ # pprint(sim._Simulation__pr.rules)
+ # pprint(sim._Simulation__pr.ordered_rulenames)
i = 1
j = 1
phase = "training"
@@ -92,9 +95,9 @@ def start():
if j > training_N:
phase = "test"
sim.step()
- print(goal)
+ # print(goal)
if sim.current_event.time >= 900:
- print(sim.current_event)
+ pprint(sim.current_event)
break
if "KEY PRESSED" in sim.current_event.action:
if not stimuli.current_stimulus_id in userinput[phase]:
@@ -104,6 +107,10 @@ def start():
userinput[phase][stimuli.current_stimulus_id][str(i)].append(
sim.current_event.action.split(":")[1].strip()
)
+ if "RULE FIRED:" in sim.current_event.action and " and " in sim.current_event.action:
+ print("FIRED COMPILED RULE!!!!")
+ print(Model.productions[sim.current_event.action[12:]])
+ # break
if sim.current_event.action == "NO RULE FOUND":
print(goal)
if sim.current_event.action == "KEY PRESSED: SPACE":
@@ -147,6 +154,15 @@ def start():
# print(math_goals)
# pprint(Model.productions)
+ # for p in Model.productions:
+ # print(p)
+ # print(Model.productions[p])#.__setitem__("utility", 1)
+ # print("\n")
+ # print("#######used prods########")
+ # print(sim.ordered_rulenames)
+
+ pprint(sim._Simulation__pr.rules)
+ pprint(sim._Simulation__pr.ordered_rulenames)
if __name__ == "__main__":
start()