summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-05-31 18:49:15 +0200
committerDobbertin, Niclas <niclas.dobbertin@mailbox.org>2024-05-31 18:49:15 +0200
commitfbcbf9b850e372a42c43b6f769f9baa47517b85b (patch)
tree5a8ce85013ac1da294fe8f52900d44ae6dfa2f22
parent228a2ee1750b31e7045d4686473adc49ce6c4205 (diff)
progress
-rw-r--r--modeling/model_env.py22
-rw-r--r--modeling/prod_motor.py1
-rw-r--r--modeling/productions_math.py29
3 files changed, 44 insertions, 8 deletions
diff --git a/modeling/model_env.py b/modeling/model_env.py
new file mode 100644
index 0000000..e609209
--- /dev/null
+++ b/modeling/model_env.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+
+def get_env():
+ envs = []
+
+ screen = {}
+
+ # Variables
+ screen["Algen"] = {"text": "Algen", "position": (100, 100)}
+ screen["AlgenVar"] = {"text": "1", "position": (100, 200)}
+ screen["Mineralien"] = {"text": "Mineralien", "position": (200, 100)}
+ screen["MineralienVar"] = {"text": "2", "position": (200, 200)}
+
+ screen["Gifte"] = {"text": "Gifte", "position": (300, 100)}
+
+
+ screen["Sandstein"] = {"text": "Sandstein", "position": (400, 100)}
+
+ envs.append(screen)
+
+ return envs
diff --git a/modeling/prod_motor.py b/modeling/prod_motor.py
index 4ea03cf..5c483e7 100644
--- a/modeling/prod_motor.py
+++ b/modeling/prod_motor.py
@@ -74,6 +74,7 @@ def procedures(Model):
==>
=g>
isa math_goal
+ op None
+manual>
isa _manual
cmd press_key
diff --git a/modeling/productions_math.py b/modeling/productions_math.py
index b179102..580a031 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 model_env
# https://stackoverflow.com/a/39644726
@@ -15,7 +16,8 @@ def get_digit(number, n):
def init():
- Model = actr.ACTRModel()
+ env = actr.Environment()
+ Model = actr.ACTRModel(environment=env)
DM = Model.decmem
goal = Model.goal
@@ -127,7 +129,7 @@ def init():
f"plus{i}{j}", "math_op", op="add", arg1=i, arg2=j, result=i + j
)
)
- return Model, DM, goal, imaginal
+ return Model, DM, goal, imaginal, env
def add_goal(goal, op, arg1, arg2):
@@ -174,6 +176,7 @@ 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"))
@@ -182,9 +185,10 @@ def add_proc(goal, proc):
def start():
while True:
# op, arg1, arg2 = wait_input()
- Model, DM, goal, imaginal = init()
+ Model, DM, goal, imaginal, env = init()
# add_goal(goal, op, arg1, arg2)
add_proc(goal, "proc1")
+ envs = model_env.get_env()
general_prod(Model)
prod_procedure.procedures(Model)
@@ -201,9 +205,20 @@ def start():
print("goal: ", goal)
# print("imaginal: ", imaginal)
- x = Model.simulation()
- x.run(max_time=4)
+ sim = Model.simulation(
+ gui=False,
+ environment_process=env.environment_process,
+ stimuli=envs,
+ triggers="space",
+ )
+ while True:
+ sim.step()
+ if sim.current_event.action == "KEY PRESSED: SPACE":
+ break
+ # x.run(max_time=8)
+ print("Simulation time: ", sim.show_time())
print("goal: ", goal)
+ print(list(env))
# print("imaginal: ", imaginal)
# imaginal.show("hundreds_ans")
# imaginal.show("tens_ans")
@@ -222,9 +237,7 @@ 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"
- ]
+ math_goals = [sim for sim in list(DM) if sim.typename == "procedure"]
print(math_goals)