#!/usr/bin/env python3 import pyactr as actr from pprint import pprint from model_init import init import prod_addition import prod_subtraction import prod_comp import prod_multi import prod_numbers import prod_procedure import prod_motor import prod_vis import model_env def add_goal(goal, op, arg1, arg2): goal.add(actr.makechunk("", "math_goal", op=op, task=op, arg1=arg1, arg2=arg2)) def general_prod(Model): Model.productionstring( name="continue_with_next_op", string=""" =g> isa math_goal op done nextop ~None nextop =nextop ==> =g> isa math_goal op =nextop nextop None """, ) def wait_input(): op = input("op\n") arg1 = input("arg1\n") 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")) def start(): while True: # op, arg1, arg2 = wait_input() Model, DM, goal, imaginal, env = init() # add_goal(goal, op, arg1, arg2) add_proc(goal, "proc1") envs = model_env.generate_environments() general_prod(Model) prod_procedure.procedures(Model) number_prods = prod_numbers.number(Model) add_prods = prod_addition.addition(Model) sub_prods = prod_subtraction.subtraction(Model) greater_prods = prod_comp.greater_than(Model) less_prods = prod_comp.lesser_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) # print("\n") print("goal: ", goal) # print("imaginal: ", imaginal) sim = Model.simulation( gui=False, environment_process=env.environment_process, stimuli=envs, # triggers="space", triggers="b", ) i = 1 userinput = "" while True: sim.step() if sim.current_event.time >= 50: print(sim.current_event) break if "KEY PRESSED" in sim.current_event.action: userinput = userinput + sim.current_event.action.split(":")[1] # if sim.current_event.action == "NO RULE FOUND": # print(goal) if sim.current_event.action == "KEY PRESSED: SPACE": sim._Simulation__env.stimulus["Answer1"]["text"] = "99" i += 1 print(userinput) print("NEW PROC") if i <= 6: goal.add( actr.makechunk( "", "math_goal", proc=f"proc{i}", ones_carry="hello" ) ) elif i == 7: goal.add( actr.makechunk( "", "math_goal", proc="proc_overall", ones_carry="hello" ) ) elif i > 7: print("DONE") break # sim.run(max_time=25) print(userinput) print("Simulation time: ", sim.show_time()) print("goal: ", goal) print(sim.current_event) pprint(vars(sim)) pprint(vars(sim._Simulation__env)) # print(sim.__env) # sim.__printenv__() # print(envs.stimulus) # print("imaginal: ", imaginal) math_goals = [sim for sim in list(DM) if sim.typename == "procedure"] # print(math_goals) if __name__ == "__main__": start()