diff options
Diffstat (limited to 'modeling/productions_math.py')
-rw-r--r-- | modeling/productions_math.py | 29 |
1 files changed, 21 insertions, 8 deletions
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) |