summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md0
-rw-r--r--master_thesis/__init__.py1
-rw-r--r--master_thesis/elio_procedures.py24
-rw-r--r--master_thesis/frensch_task.py113
-rw-r--r--master_thesis/pyactr_tut.py512
-rw-r--r--psychopy-env.yml15
6 files changed, 665 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README.md
diff --git a/master_thesis/__init__.py b/master_thesis/__init__.py
new file mode 100644
index 0000000..548fbdf
--- /dev/null
+++ b/master_thesis/__init__.py
@@ -0,0 +1 @@
+print("hello world!!")
diff --git a/master_thesis/elio_procedures.py b/master_thesis/elio_procedures.py
new file mode 100644
index 0000000..cd4848e
--- /dev/null
+++ b/master_thesis/elio_procedures.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+
+class Procedure:
+ pass
+
+
+class Variable:
+ def __init__(self, name: str, subscript: int = 0):
+ self.name = name
+ self.subscript = subscript
+
+
+ def __str__(self):
+ return f"{self.name}_{self.subscript}"
+
+ def get_result(self, Variables: dict):
+ if not self.subscript:
+ return Variables[self.name]
+ else:
+ return Variables
+
+x = Variable("solid", 2)
+print(x)
diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py
new file mode 100644
index 0000000..0c66254
--- /dev/null
+++ b/master_thesis/frensch_task.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+from __future__ import annotations
+
+from psychopy import constants, core, event, gui, visual
+from collections import namedtuple
+
+
+DisplayVariable = namedtuple("DisplayVariable", ["name", "values"])
+DisplayProcedure = namedtuple("DisplayProcedure", ["procedure", "solution"])
+
+
+def experiment_shutdown():
+ WIN.close()
+ core.quit()
+
+
+WIN = visual.Window((800, 600), fullscr=True, units="pix")
+MONITOR_FPS = 60
+
+# Cancel experiment anytime with Esc
+event.globalKeys.add(key="escape", func=experiment_shutdown, name="shutdown")
+
+
+def generate_variable_display(varx: list[DisplayVariable], x_positions: list[int]):
+ assert len(varx) == len(x_positions)
+
+ stims = []
+
+ def gen_value_stims(values, x, y, offset):
+ for value in values:
+ y -= offset
+ value_stim = visual.TextBox2(
+ WIN,
+ pos=(x, y),
+ text=value,
+ # size=200,
+ letterHeight=100,
+ alignment="center",
+ )
+ stims.append(value_stim)
+
+ y = 400
+ offset = 100
+
+ for var, x_pos in zip(varx, x_positions):
+ stim_var = visual.TextBox2(
+ WIN,
+ pos=[x_pos, y],
+ text=var.name,
+ # size=[1000, 1000],
+ letterHeight=50,
+ alignment="center",
+ )
+ stims.append(stim_var)
+
+ gen_value_stims(var.values, x_pos, y, offset)
+
+ return stims
+
+
+def generate_procedure_display(procedure: DisplayProcedure):
+ stim_procedure = visual.TextBox2(
+ WIN,
+ pos=[-600, -200],
+ text=procedure.procedure,
+ # size=[1000, 1000],
+ letterHeight=50,
+ alignment="center",
+ )
+ return stim_procedure
+
+
+solid = DisplayVariable("SOLID", [6])
+algae = DisplayVariable("ALGAE", [8])
+lime = DisplayVariable("LIME", [3, 5, 1, 9])
+toxin = DisplayVariable("TOXIN", [4, 8, 7, 2])
+x_positions = [-600, -300, 0, 300]
+# x_positions = [-600, -300]
+
+stims = generate_variable_display([solid, algae, lime, toxin], x_positions)
+
+p1 = DisplayProcedure("Index 1 = Solid * (Lime_4 - Lime_2) = ", 1)
+p1 = generate_procedure_display(p1)
+stims.append(p1)
+
+stim_answer_box = visual.TextBox2(
+ WIN,
+ "",
+ letterHeight=50,
+ pos=(0, -200),
+ size=[150, 70],
+ editable=True,
+ fillColor="white",
+ color="black",
+ alignment="center",
+)
+stims.append(stim_answer_box)
+
+not_finished = True
+answer = "not answered"
+while not_finished:
+ stim_answer_box.hasFocus = True
+ for stim in stims:
+ stim.draw()
+ WIN.flip()
+ answer = stim_answer_box.text
+ if "\n" in stim_answer_box.text:
+ not_finished = False
+
+
+event.waitKeys(keyList=["space"])
+
+print(f"Answer: {answer}")
diff --git a/master_thesis/pyactr_tut.py b/master_thesis/pyactr_tut.py
new file mode 100644
index 0000000..a44209e
--- /dev/null
+++ b/master_thesis/pyactr_tut.py
@@ -0,0 +1,512 @@
+#!/usr/bin/env python3
+
+import pyactr as actr
+
+
+def memory_motor():
+ playing_memory = actr.ACTRModel()
+
+ actr.chunktype("playgame", "game, activity")
+
+ initial_chunk = actr.makechunk(typename="playgame", game="memory")
+
+ goal = playing_memory.set_goal("goal")
+
+ playing_memory.productionstring(
+ name="startplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ ?manual>
+ state free
+ ==>
+ =goal>
+ isa playgame
+ activity presskey
+ """,
+ )
+
+ playing_memory.productionstring(
+ name="presskey",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity presskey
+ ==>
+ +manual>
+ isa _manual
+ cmd press_key
+ key 1
+ =goal>
+ isa playgame
+ activity None
+ """,
+ )
+
+ simulation_game = playing_memory.simulation()
+ simulation_game.run()
+
+
+def memory_vision():
+ environment = actr.Environment()
+ playing_memory = actr.ACTRModel(environment=environment)
+
+ memory = [{}, {"A": {"text": "A", "position": (100, 100)}}]
+
+ goal = playing_memory.set_goal("goal")
+ actr.chunktype("playgame", "game, activity, key, object")
+ initial_chunk = actr.makechunk(typename="playgame", game="memory", key="1")
+ goal.add(initial_chunk)
+
+ playing_memory.productionstring(
+ name="startplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ ==>
+ =goal>
+ isa playgame
+ activity presskey""",
+ )
+
+ playing_memory.productionstring(
+ name="presskey",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity presskey
+ key =k
+ ==>
+ +manual>
+ isa _manual
+ cmd press_key
+ key =k
+ =goal>
+ isa playgame
+ activity attend""",
+ )
+
+ playing_memory.productionstring(
+ name="attendobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity attend
+ =visual_location>
+ isa _visuallocation
+ ?manual>
+ state free
+ ==>
+ =goal>
+ isa playgame
+ activity storeobject
+ +visual>
+ isa _visual
+ cmd move_attention
+ screen_pos =visual_location""",
+ )
+
+ playing_memory.productionstring(
+ name="storeobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity storeobject
+ =visual>
+ isa _visual
+ value =v
+ ==>
+ =goal>
+ isa playgame
+ activity None
+ object =v""",
+ )
+
+ simulation = playing_memory.simulation(
+ gui=False,
+ environment_process=environment.environment_process,
+ stimuli=memory,
+ triggers="1",
+ )
+ simulation.run()
+
+ print(goal)
+
+
+def memory_memory():
+ environment = actr.Environment()
+ playing_memory = actr.ACTRModel(environment=environment)
+
+ memory = [
+ {},
+ {"A": {"text": "A", "position": (100, 100)}},
+ {"A": {"text": "A", "position": (100, 100)}},
+ ]
+
+ goal = playing_memory.set_goal("goal")
+ actr.chunktype("playgame", "game, activity, key, object")
+ initial_chunk = actr.makechunk(typename="playgame", game="memory", key="1")
+ goal.add(initial_chunk)
+
+ playing_memory.productionstring(
+ name="startplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ object None
+ ==>
+ =goal>
+ isa playgame
+ activity presskey""",
+ )
+
+ playing_memory.productionstring(
+ name="continueplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ object ~None
+ ==>
+ =goal>
+ isa playgame
+ game memory
+ activity recall""",
+ )
+
+ playing_memory.productionstring(
+ name="recallvalue",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity recall
+ object =val
+ ==>
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ +retrieval>
+ isa playgame
+ object =val""",
+ )
+
+ playing_memory.productionstring(
+ name="recallsuccessful",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ object =val
+ ?retrieval>
+ buffer full
+ =retrieval>
+ isa playgame
+ key =k
+ ==>
+ =goal>
+ isa playgame
+ key =k
+ activity done""",
+ )
+
+ playing_memory.productionstring(
+ name="recallfailed",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ key 1
+ object =val
+ ?retrieval>
+ state error
+ ==>
+ ~goal>
+ +goal>
+ isa playgame
+ game memory
+ activity presskey
+ key 2""",
+ )
+
+ playing_memory.productionstring(
+ name="presskey",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity presskey
+ key =k
+ ==>
+ +manual>
+ isa _manual
+ cmd press_key
+ key =k
+ =goal>
+ isa playgame
+ activity attend""",
+ )
+
+ playing_memory.productionstring(
+ name="attendobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity attend
+ =visual_location>
+ isa _visuallocation
+ ?manual>
+ state free
+ ==>
+ =goal>
+ isa playgame
+ activity storeobject
+ +visual>
+ isa _visual
+ cmd move_attention
+ screen_pos =visual_location""",
+ )
+
+ playing_memory.productionstring(
+ name="storeobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity storeobject
+ =visual>
+ isa _visual
+ value =v
+ ==>
+ =goal>
+ isa playgame
+ activity None
+ object =v""",
+ )
+
+ simulation = playing_memory.simulation(
+ gui=False,
+ environment_process=environment.environment_process,
+ stimuli=memory,
+ triggers="1",
+ )
+ simulation.run(max_time=2)
+
+ print(goal)
+ print(playing_memory.decmem)
+
+
+def memory_memory_loop():
+ environment = actr.Environment()
+ playing_memory = actr.ACTRModel(environment=environment)
+
+ goal = playing_memory.set_goal("goal")
+ actr.chunktype("playgame", "game, activity, key, object")
+ initial_chunk = actr.makechunk(typename="playgame", game="memory", key="1")
+
+ memory = [{}] + [{i: {"text": i, "position": (100, 100)}} for i in "BCDEFGHDIJ"]
+ goal.add(initial_chunk)
+
+ playing_memory.productionstring(
+ name="startplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ object None
+ ==>
+ =goal>
+ isa playgame
+ activity presskey""",
+ )
+
+ playing_memory.productionstring(
+ name="continueplaying",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity None
+ object ~None
+ ==>
+ =goal>
+ isa playgame
+ game memory
+ activity recall""",
+ )
+
+ playing_memory.productionstring(
+ name="recallvalue",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity recall
+ object =val
+ ==>
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ +retrieval>
+ isa playgame
+ object =val""",
+ )
+
+ playing_memory.productionstring(
+ name="recallsuccessful",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ object =val
+ ?retrieval>
+ buffer full
+ =retrieval>
+ isa playgame
+ key =k
+ ==>
+ =goal>
+ isa playgame
+ key =k
+ activity done""",
+ )
+
+ for i in range(1, 9):
+ playing_memory.productionstring(
+ name="recallfailed" + str(i),
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ key """
+ + str(i)
+ + """
+ object =val
+ ?retrieval>
+ state error
+ ==>
+ ~goal>
+ +goal>
+ isa playgame
+ game memory
+ activity presskey
+ key """
+ + str((i + 1) % 10),
+ )
+
+ playing_memory.productionstring(
+ name="recallfailed9",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity checkrecalled
+ key 0
+ object =val
+ ?retrieval>
+ state error
+ ==>
+ ~goal>""",
+ )
+
+ playing_memory.productionstring(
+ name="presskey",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity presskey
+ key =k
+ ==>
+ +manual>
+ isa _manual
+ cmd press_key
+ key =k
+ =goal>
+ isa playgame
+ activity attend""",
+ )
+
+ playing_memory.productionstring(
+ name="attendobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity attend
+ =visual_location>
+ isa _visuallocation
+ ?manual>
+ state free
+ ==>
+ =goal>
+ isa playgame
+ activity storeobject
+ +visual>
+ isa _visual
+ cmd move_attention
+ screen_pos =visual_location""",
+ )
+
+ playing_memory.productionstring(
+ name="storeobject",
+ string="""
+ =goal>
+ isa playgame
+ game memory
+ activity storeobject
+ =visual>
+ isa _visual
+ value =v
+ ==>
+ =goal>
+ isa playgame
+ activity None
+ object =v""",
+ )
+ playing_memory.model_parameters["subsymbolic"] = True
+
+ goal.add(initial_chunk)
+ # playing_memory.retrieval.pop()
+ # for i in playing_memory.decmem.copy():
+ # playing_memory.decmem.pop(i)
+ simulation = playing_memory.simulation(
+ gui=False,
+ environment_process=environment.environment_process,
+ stimuli=memory,
+ triggers=[str(i % 10) for i in range(1, 11)] + ["0"],
+ )
+
+ while True:
+ simulation.step()
+ if simulation.current_event.action == "RULE FIRED: recallsuccessful":
+ break
+ if simulation.show_time() > 10:
+ print("Nothing found, breaking")
+ break
+
+ print(goal)
+ print(simulation.show_time())
+ print(playing_memory.decmem)
+
+
+memory_memory_loop()
diff --git a/psychopy-env.yml b/psychopy-env.yml
new file mode 100644
index 0000000..48e480e
--- /dev/null
+++ b/psychopy-env.yml
@@ -0,0 +1,15 @@
+name: master
+channels:
+- conda-forge
+dependencies:
+- python=3.8
+- psychopy
+- pip
+- sympy
+- pip:
+ - psychtoolbox
+ - pygame
+ - pyo
+ - pyparallel; platform_system != "Windows"
+ - SoundFile; platform_system == "Windows"
+ - websocket_client