summaryrefslogtreecommitdiff
path: root/master_thesis/pyactr_tut.py
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-11-03 08:29:49 +0100
committerNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-11-03 08:29:49 +0100
commitd94e638f98c599b7c151927d504a474705ae9bca (patch)
tree128765ac1e9cd9413323820f596ced3730091dea /master_thesis/pyactr_tut.py
parentc05a2a127449595f1e62b99adb7aa3a0ded8ec27 (diff)
parent4c71eec3cd5f5f36c1cdc6d2284f6dd93facc193 (diff)
Merge branch 'master' into 1920x1080
Diffstat (limited to 'master_thesis/pyactr_tut.py')
-rw-r--r--master_thesis/pyactr_tut.py512
1 files changed, 0 insertions, 512 deletions
diff --git a/master_thesis/pyactr_tut.py b/master_thesis/pyactr_tut.py
deleted file mode 100644
index a44209e..0000000
--- a/master_thesis/pyactr_tut.py
+++ /dev/null
@@ -1,512 +0,0 @@
-#!/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()