diff options
author | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-08-07 07:52:12 +0200 |
---|---|---|
committer | Dobbertin, Niclas <niclas.dobbertin@mailbox.org> | 2024-08-07 07:52:12 +0200 |
commit | 347d3c943462a73c35c9d246c4970833d96180bf (patch) | |
tree | f3507e40a3a76b07b507fb294871ad777a3a27d6 /modeling/productions_math.py | |
parent | d3a81759c311a9ccfc4d17d2cb9347b9367cb7d1 (diff) |
full experiment, fixed and random
Diffstat (limited to 'modeling/productions_math.py')
-rw-r--r-- | modeling/productions_math.py | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/modeling/productions_math.py b/modeling/productions_math.py index f824466..e740ae3 100644 --- a/modeling/productions_math.py +++ b/modeling/productions_math.py @@ -20,8 +20,6 @@ def add_goal(goal, op, arg1, arg2): goal.add(actr.makechunk("", "math_goal", op=op, task=op, arg1=arg1, arg2=arg2)) - - def wait_input(): op = input("op\n") arg1 = input("arg1\n") @@ -35,13 +33,29 @@ def add_proc(goal, proc): def start(): - condition = "fixed" + condition = "random" + training_N = 5 + test_N = 5 + + stimuli = model_env.Stimuli(condition, training_N=training_N, test_N=test_N) + + pprint(stimuli.training_order) + pprint(stimuli.test_order) + + stimuli.generate_stimuli() + + pprint(stimuli.training_stimuli) + pprint(stimuli.test_stimuli) + + stimulus = stimuli.next_stimulus() # op, arg1, arg2 = wait_input() Model, DM, goal, imaginal, env = init() + # Model.model_parameters["subsymbolic"] = True + # Model.model_parameters["production_compilation"] = True + # Model.model_parameters["utility_learning"] = True # add_goal(goal, op, arg1, arg2) - add_proc(goal, "proc1") - envs = model_env.generate_environments() + add_proc(goal, "next_proc") prod_procedure.procedures(Model) number_prods = prod_numbers.number(Model) @@ -58,48 +72,64 @@ def start(): sim = Model.simulation( gui=False, environment_process=env.environment_process, - stimuli=envs, + stimuli=stimulus, + realtime=False, # triggers="space", triggers="b", ) i = 1 - userinput = "" + j = 1 + phase = "training" + userinput = {"training": {}, "test": {}} while True: + if j > training_N: + phase = "test" sim.step() - if sim.current_event.time >= 50: + if sim.current_event.time >= 900: 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 not stimuli.current_stimulus_id in userinput[phase]: + userinput[phase][stimuli.current_stimulus_id] = {} + if not str(i) in userinput[phase][stimuli.current_stimulus_id]: + userinput[phase][stimuli.current_stimulus_id][str(i)] = [] + userinput[phase][stimuli.current_stimulus_id][str(i)].append( + sim.current_event.action.split(":")[1].strip() + ) + if sim.current_event.action == "NO RULE FOUND": + print(goal) if sim.current_event.action == "KEY PRESSED: SPACE": - sim._Simulation__env.stimulus["Answer5"]["text"] = "99" + sim._Simulation__env.stimulus = stimuli.update_current_stimulus( + f"Answer{i}", + int("".join(userinput[phase][stimuli.current_stimulus_id][str(i)][:-1])), + ) i += 1 - print(userinput) - print("NEW PROC") + pprint(userinput) + pprint("NEW PROC") if i <= 6: goal.add( - actr.makechunk( - "", "math_goal", proc=f"proc{i}", ones_carry="hello" - ) + actr.makechunk("", "math_goal", proc="next_proc", ones_carry="") ) - elif i == 7: + elif i >= 7 and j < training_N+test_N: + print("Stimulus Done, next stimulus") + sim._Simulation__env.stimulus = stimuli.next_stimulus() goal.add( - actr.makechunk( - "", "math_goal", proc="proc_overall", ones_carry="hello" - ) + actr.makechunk("", "math_goal", proc="next_proc", ones_carry="") ) - elif i > 7: + i = 1 + j += 1 + elif i >= 7 and j >= training_N+test_N: print("DONE") break # sim.run(max_time=25) - print(userinput) + print("training order: ", stimuli.training_order_list) + print("test order: ", stimuli.test_order_list) + pprint(userinput) print("Simulation time: ", sim.show_time()) print("goal: ", goal) print(sim.current_event) - pprint(vars(sim)) + # pprint(vars(sim)) pprint(vars(sim._Simulation__env)) # print(sim.__env) # sim.__printenv__() @@ -107,6 +137,7 @@ def start(): # print("imaginal: ", imaginal) math_goals = [sim for sim in list(DM) if sim.typename == "procedure"] # print(math_goals) + # pprint(Model.productions) if __name__ == "__main__": |