Created
April 18, 2021 19:23
-
-
Save drussellmrichie/c76fcb860c8c9e00d85647d1a34be14e to your computer and use it in GitHub Desktop.
lexical decision model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words = [{1: {'text': 'elephant', 'position': (320, 180)}}, | |
{2: {'text': 'wug', 'position': (220, 140)}}, | |
{3: {'text': 'dog', 'position': (320, 180)}}] | |
import pyactr as actr | |
environment = actr.Environment(focus_position=(0,0)) | |
lex_decision = actr.ACTRModel( | |
environment=environment, | |
automatic_visual_search=False, | |
motor_prepared=True | |
) | |
actr.chunktype("goal", "state") | |
actr.chunktype("word", "form") | |
dm = lex_decision.decmem | |
for string in {"elephant", "dog", "crocodile"}: | |
dm.add(actr.makechunk(typename="word", form=string)) | |
g = lex_decision.goal | |
g.add(actr.makechunk(nameofchunk="beginning", | |
typename="goal", | |
state="start")) | |
lex_decision.productionstring(name="find word", string=""" | |
=g> | |
isa goal | |
state start | |
?visual_location> | |
buffer empty | |
==> | |
=g> | |
isa goal | |
state attend | |
+visual_location> | |
isa _visuallocation | |
screen_x closest | |
""") | |
lex_decision.productionstring(name="attend word", string=""" | |
=g> | |
isa goal | |
state attend | |
=visual_location> | |
isa _visuallocation | |
?visual> | |
state free | |
==> | |
=g> | |
isa goal | |
state retrieving | |
+visual> | |
isa _visual | |
cmd move_attention | |
screen_pos =visual_location | |
~visual_location> | |
""") | |
lex_decision.productionstring(name="retrieving", string=""" | |
=g> | |
isa goal | |
state retrieving | |
=visual> | |
isa _visual | |
value =val | |
==> | |
=g> | |
isa goal | |
state retrieval_done | |
+retrieval> | |
isa word | |
form =val | |
""") | |
lex_decision.productionstring(name="lexeme retrieved", string=""" | |
=g> | |
isa goal | |
state retrieval_done | |
?retrieval> | |
buffer full | |
state free | |
==> | |
=g> | |
isa goal | |
state waiting | |
+manual> | |
isa _manual | |
cmd press_key | |
key J | |
""") | |
lex_decision.productionstring(name="no lexeme found", string=""" | |
=g> | |
isa goal | |
state retrieval_done | |
?retrieval> | |
buffer empty | |
state error | |
==> | |
=g> | |
isa goal | |
state waiting | |
+manual> | |
isa _manual | |
cmd press_key | |
key F | |
"""); | |
lex_decision.productionstring(name="button finished", string=""" | |
=g> | |
isa goal | |
state waiting | |
?manual> | |
state free | |
==> | |
=g> | |
isa goal | |
state start | |
"""); | |
lex_dec_sim = lex_decision.simulation( | |
realtime=False, | |
gui=False, | |
environment_process=environment.environment_process, | |
stimuli=words, | |
triggers=['J','F'], | |
times=1) | |
lex_dec_sim.run(max_time=3) | |
# produces error "ACTRError: In environment, stimuli must be the same length as triggers or one of the two must be of length 1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment