-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraining_instructions_german.m
1695 lines (1289 loc) · 54.3 KB
/
training_instructions_german.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% TRAINING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Prepare Matlab for experiment
sca;
close all;
clear all;
% Here we call some default settings for setting up Psychtoolbox
PsychDefaultSetup(2);
PsychTweak('UseGPUIndex', 0);
%% Load everything needed for the experiment
load('experimental_variables_new.mat')
%makes screen transparent for debugging
%PsychDebugWindowConfiguration();
Screen('Preference', 'SkipSyncTests', 1);
screen_number = max(Screen('Screens'));
% Hide mouse cursor during the experiment
HideCursor;
% Define black and white (white will be 1 and black 0). This is because
% in general luminace values are defined between 0 and 1 with 255 steps in
% between. All values in Psychtoolbox are defined between 0 and 1
white = WhiteIndex(screen_number);
% Set a blakish background
blackish = white / 20;
% Open an on screen window using PsychImaging and color it grey.
[window, windowRect] = PsychImaging('OpenWindow', screen_number, blackish);
% Get the size of the on screen window
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
% Query the frame duration
ifi = Screen('GetFlipInterval', window);
% Here we use to a waitframes number greater then 1 to flip at a rate not
% equal to the monitors refreash rate. For this example, once per second,
% to the nearest frame
flipSecs = 1;
waitframes = round(flipSecs / ifi);
% Setup the text type for the window
Screen('TextFont', window, 'Ariel');
Screen('TextSize', window, 26);
% Set up alpha-blending for smooth (anti-aliased) lines
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
% Get the centre coordinate of the window
[xCenter, yCenter] = RectCenter(windowRect);
imagePos = [[xCenter-500, yCenter];
[xCenter-200, yCenter-250];
[xCenter+200, yCenter-250];
[xCenter+500, yCenter];
[xCenter+200, yCenter+250];
[xCenter-200, yCenter+250]];
jumps = [5 4 5 6 2 2];
md = .5; %movement duration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% INSTRUCTIONS START FROM HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Introductory text
text = ['Hallo Abenteurer!' ...
'\n\n\n\n Willkommen im Trainingslager'...
'\n\n\n\n Heute haben Sie die Gelegenheit an einer Reise durch den Weltraum teilzunehmen.'...
'\n\n\n\n Um möglichst viele Punkte zu sammeln, ist es wichtig, dass Sie Ihre Reisen immer im Voraus planen.'...
'\n\n\n\n Bevor es losgeht, zeige ich Ihnen jedoch, wie Sie im Weltraum überleben können.'];
% Draw all the text in one go
DrawFormattedText(window, text, 'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%% INSTRUCTIONS 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%text
text = ['Sie werden durch viele verschiedene Planetensysteme reisen.' ...
'\n\n\n\n Jedes dieser Systeme besteht aus 6 Planeten.' ...
'\n\n\n\n Drücken Sie eine Taste, um fortzufahren.'];
% Draw all the text in one go
DrawFormattedText(window, text, 'center', screenYpixels * 0.25, white);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%% SHOW PLANETSYSTEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
planets_img_location = ['planet_1.png'; 'planet_2.png'; 'planet_3.png'; ...
'planet_4.png'; 'planet_5.png'];
PlanetsTexture = NaN(1,5);
for i=1:5
[planet, ~, palpha] = imread(planets_img_location(i, :));
% Add transparency to the background
planet(:,:,4) = palpha;
% Make the planets into a texture
PlanetsTexture(i) = Screen('MakeTexture', window, planet);
end
% Get the size of the planet image
[p1, p2, p3] = size(planet);
planetRect = [0 0 p2 p1];
%generate planet locations
planetsPos = NaN(4, 6);
for i=1:6
planetsPos(:,i) = CenterRectOnPointd(planetRect, ...
imagePos(i,1), imagePos(i,2));
end
% plot planets for the given mini block
planetList = [1, 3, 2, 2, 4, 5];
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
Screen('flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%
%
% %%%%%%%%%%%% INSTRUCTIONS 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Ein Raumschiff zeigt Ihnen zu jedem Zeitpunkt Ihre aktuelle Position an.'];
% Draw all the text in one go
DrawFormattedText(window, text,...
'center', screenYpixels * 0.1, white);
%%%%%%%%%%%% SHOW PLANETSYSTEM + ROCKET %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
draw_planets(planetList, window, PlanetsTexture, planetsPos);
rocket_img_location = 'rocket.png';
[rocket, ~, ralpha] = imread(rocket_img_location);
% Add transparency to the background
rocket(:,:,4) = ralpha;
% Get the size of the rocket image
[s1, s2, ~] = size(rocket);
rocketRect = [0 0 s2 s1];
%generate rocket locations
rocketPos = NaN(4, 6);
for i=1:6
rocketPos(:,i) = CenterRectOnPointd(rocketRect, ...
imagePos(i,1), imagePos(i,2));
end
% Make the rocket into a texture
RocketTexture = Screen('MakeTexture', window, rocket);
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,1)');
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
Screen('flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%% INSTRUCTIONS 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Kurz gesagt:'...
'\n\n Um im Weltraum zu überleben, müssen Sie möglichst viel Treibstoff sammeln, indem Sie von Planet zu Planet reisen.' ...
'\n\n\n\n Sie bereisen Planeten, indem Sie immer zwischen den Kommandos RECHTE PFEILTASTE und (S)prung wählen.'...
'\n\n\n\n Planen Sie die Reisen sorgfältig im Voraus, um Treibstoff zu sparen und zu überleben.',...
'\n\n\n\n RECHTE PFEILTASTE kostet Sie dabei immer 2 Treibstoffeinheiten, während (S)prung 5 Treibstoffeinheiten verbraucht.'...
'\n\n\n\n Je nachdem auf welchem Planeten Sie landen, gewinnen oder verlieren Sie Treibstoff.',...
'\n\n\n\n Im Folgenden werde ich Ihnen alles genauer erklären.'];
% Draw all the text in one go
DrawFormattedText(window, text,...
'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%%% INTRODUCE FUEL TANK %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% INSTRUCTIONS 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% text
text = ['Damit Sie nicht den Überblick über die Menge des verfügbaren Treibstoffes verlieren,'...
'\n\n zeigt der Balken am oberen Bildschirmrand Ihren aktuellen Treibstofflevel an.'...
'\n\n\n Wenn Ihr Treibstofflevel gefährlich absinkt, färbt sich der Balken rot.'];
% Draw all the text in one go
DrawFormattedText(window, text,...
'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.8);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%% Bar in the middle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
planets = Practise;
% Initial point and planet specific rewards
points = 1000;
% points bar
bar = [0, 0, 100, 1000];
% draw point bar
draw_point_bar(points, window, xCenter, screenYpixels);
% Draw planets
draw_planets(planets, window, PlanetsTexture, planetsPos);
start = 1;
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
vbl = Screen('flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
% %%%%%%%%%%%% PRACTISE JUMPING LEFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Jetzt zeige ich Ihnen, wie man Planeten bereist und erkläre dabei die Kommandos.',...
'\n\n\n\n Zuerst schauen wir uns an, was passiert, wenn Sie die RECHTE PFEILTASTE wählen.' ...
'\n\n\n\n Die RECHTE PFEILTASTE ermöglicht es Ihnen, im Uhrzeigersinn zum nächsten' ...
'\n\n benachbarten Planeten zu reisen.' ...
'\n\n\n\n Sie können dies nun ein paar Mal ausprobieren.'];
% Draw all the text in one go
DrawFormattedText(window, text,...
'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
NoMiniBlocks = 1;
NoTrials = 12; %change to 12
points = 1000;
start = 1;
for t = 1:NoTrials
while(true)
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
draw_planets(Practise, window, PlanetsTexture, planetsPos);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
vbl = Screen('flip', window);
% Wait for a key press
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
elseif strcmp(Key, 'RightArrow')
p = state_transition_matrix(1, start, :);
next = find(cumsum(p)>=rand,1);
% move the rocket
time = 0;
locStart = imagePos(start, :);
locEnd = imagePos(next, :);
points = points + actionCost(1);
while time < md
% Position of the square on this frame
xpos = locStart(1) + time/md*(locEnd(1) - locStart(1));
ypos = locStart(2) + time/md*(locEnd(2) - locStart(2));
% Center the rectangle on the centre of the screen
cRect = CenterRectOnPointd(rocketRect, xpos, ypos);
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% draw planets
draw_planets(Practise, window, PlanetsTexture, planetsPos);
Screen('DrawTexture', window, RocketTexture, [], cRect);
DrawFormattedText(window, '-2', 'center', yCenter-100, white);
% Flip to the screen
vbl = Screen('Flip', window, vbl + 0.5*ifi);
% Increment the time
time = time + ifi;
end
% Position of the square on this frame
xpos = locEnd(1);
ypos = locEnd(2);
% Center the rectangle on the centre of the screen
cRect = CenterRectOnPointd(rocketRect, xpos, ypos);
% set start to a new location
start = next;
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% draw planets
draw_planets(Practise, window, PlanetsTexture, planetsPos);
% draw_buttons(window, ButtonsTexture, buttonsPos);
Screen('DrawTexture', window, RocketTexture, [], cRect);
Screen('Flip', window);
break;
else
DrawFormattedText(window, 'Bitte RECHTS drücken',...
'center', 'center', white);
Screen('Flip', window);
WaitSecs(1.);
end
end
end
WaitSecs(1.)
%%%%%%% SHORT BREAK%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Haben Sie bemerkt, wie der Treibstofflevel abgesunken ist?',...
'\n\n\n\n Als nächstes zeige ich Ihnen was beim Kommando (S)prung passiert.'];
DrawFormattedText(window, text, 'center', screenYpixels * 0.5, white);
% DrawFormattedText(window, 'Als nächstes zeige ich Dir was beim Kommando (S)prung passiert.',...
% 'center', 'center', white);
Screen('flip', window);
WaitSecs(4.);
% %%%%%%%%%%%% PRACTISE JUMPING Right %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = [' Wenn Sie (S)prung wählen, reist Ihr Raumschiff zu einem nicht benachbarten Planeten.' ...
'\n\n\n\n Als nächstes können Sie ausprobieren, was an jeder Planetenposition passiert,'...
'\n\n wenn Sie (S)prung wählen.'...
'\n\n\n\n Es ist wichtig, dass Sie sich das gezeigte Flugmuster gut einprägen.'];
% Draw all the text in one go
DrawFormattedText(window, text,'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
points = 1000;
for n = 1:NoMiniBlocks
for t = 1:NoTrials
while(true)
if t < 7
start = t;
else
start = t-6;
end
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
planetList = Practise;
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
vbl = Screen('flip', window);
% Wait for a key press
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
elseif strcmp(Key, 's')
p = state_transition_matrix(2, start, :);
next = find(cumsum(p)>=rand,1);
% move the rocket
time = 0;
locStart = imagePos(start, :);
locEnd = imagePos(next, :);
points = points + actionCost(2);
while time < md
% Position of the square on this frame
xpos = locStart(1) + time/md*(locEnd(1) - locStart(1));
ypos = locStart(2) + time/md*(locEnd(2) - locStart(2));
% Center the rectangle on the centre of the screen
cRect = CenterRectOnPointd(rocketRect, xpos, ypos);
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% draw planets
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw the rect to the screen
Screen('DrawTexture', window, RocketTexture, [], cRect);
% Flip to the screen
DrawFormattedText(window, '-5', 'center', yCenter-100, white);
vbl = Screen('Flip', window, vbl + 0.5*ifi);
% Increment the time
time = time + ifi;
end
WaitSecs(1);
Screen('Flip', window);
WaitSecs(1);
break;
else
DrawFormattedText(window, 'Bitte S drücken', 'center', 'center', white);
Screen('Flip', window);
WaitSecs(1);
end
end
end
end
% %%%%%%%%%%%% SHOW REISEMUSTER FOR JUMPING Right %%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = [' Hier sehen Sie das Flugmuster noch einmal als Ganzes.' ...
' Bitte prägen Sie es sich gut ein:',...
'\n\n\n\n '];
Reisemuster= imread ('Reisemuster_Vorlage_2.jpg');
ReiseTexture= Screen('MakeTexture', window, Reisemuster);
Screen('DrawTexture', window, ReiseTexture);
% Draw all the text in one go
DrawFormattedText(window, text,'center', screenYpixels * 0.10, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
Screen('flip', window);
WaitSecs(2.)
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
% %%%%%%%%%%%% PRACTISE TRAVEL PATTERN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = [' Um Ihnen zu helfen, das Muster noch mehr zu verinnerlichen, spielen wir jetzt ein kleines Spiel.' ...
'\n\n\n\n Ich zeige Ihnen verschiedene Startpositionen und Sie können mit den Tasten 1-6 sagen,'...
'\n\n\n auf welchem Zielplaneten Sie landen, wenn Sie (S)prung wählen.'...
'\n\n\n\n Anschließend bekommen Sie ein Feedback, ob Sie richtig geantwortet haben.'];
% Draw all the text in one go
DrawFormattedText(window, text,'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% Training_S_Test %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NoTrials=18; %change to 18
NoMiniBlocks = 3; %max. nr of repetitions of the travel pattern training
points = 1000;
TestStarts = [1,2,3,4,5,6,2,5,1,6,3,4,3,6,4,1,5,2];
RightAnswer = [5,4,5,6,2,2,4,2,5,2,5,6,5,2,6,5,2,4];
MinNoRightAnswers = 17; % at least 17/18 right answers (=94.44% correct)
% loop until training criterion met
for NoPatternTrainings = 1:NoMiniBlocks
NoRightAnswers = 0;
for t = 1:NoTrials
start=TestStarts(t);
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
planetList = Practise;
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw numbers
DrawFormattedText(window, '1', xCenter-520, yCenter+30, [1 0 0]);
DrawFormattedText(window, '2', xCenter-220, yCenter-220, [1 0 0]);
DrawFormattedText(window, '3', xCenter+180, yCenter-220, [1 0 0]);
DrawFormattedText(window, '4', xCenter+480, yCenter+30, [1 0 0]);
DrawFormattedText(window, '5', xCenter+180, yCenter+280, [1 0 0]);
DrawFormattedText(window, '6', xCenter-220, yCenter+280, [1 0 0]);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
vbl = Screen('flip', window);
% Wait for a key press
[secs, keyCode, deltaSecs] = KbPressWait;
Resp = KbName(keyCode);
if iscell(Resp)
Resp = Resp{1};
end
if strcmp(Resp, 'ESCAPE')
sca;
return;
end
Resp = str2double(Resp(1));
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
planetList = Practise;
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw numbers
DrawFormattedText(window, '1', xCenter-520, yCenter+30, [1 0 0]);
DrawFormattedText(window, '2', xCenter-220, yCenter-220, [1 0 0]);
DrawFormattedText(window, '3', xCenter+180, yCenter-220, [1 0 0]);
DrawFormattedText(window, '4', xCenter+480, yCenter+30, [1 0 0]);
DrawFormattedText(window, '5', xCenter+180, yCenter+280, [1 0 0]);
DrawFormattedText(window, '6', xCenter-220, yCenter+280, [1 0 0]);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
if Resp == RightAnswer(t)
NoRightAnswers = NoRightAnswers + 1;
DrawFormattedText(window, 'Richtig', 'center', 'center', white)
vbl = Screen('flip', window);
WaitSecs(0.5);
else
DrawFormattedText(window, 'Falsch, die richtige Antwort wäre:', 'center', 'center', white); % ask
vbl = Screen('flip', window);
WaitSecs(2);
end
p = state_transition_matrix(2, start, :);
next = find(cumsum(p)>=rand,1);
% move the rocket
time = 0;
locStart = imagePos(start, :);
locEnd = imagePos(next, :);
points = points + actionCost(2);
while time < md
% Position of the square on this frame
xpos = locStart(1) + time/md*(locEnd(1) - locStart(1));
ypos = locStart(2) + time/md*(locEnd(2) - locStart(2));
% Center the rectangle on the centre of the screen
cRect = CenterRectOnPointd(rocketRect, xpos, ypos);
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% draw planets
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw numbers
DrawFormattedText(window, '1', xCenter-520, yCenter+30, [1 0 0]);
DrawFormattedText(window, '2', xCenter-220, yCenter-220, [1 0 0]);
DrawFormattedText(window, '3', xCenter+180, yCenter-220, [1 0 0]);
DrawFormattedText(window, '4', xCenter+480, yCenter+30, [1 0 0]);
DrawFormattedText(window, '5', xCenter+180, yCenter+280, [1 0 0]);
DrawFormattedText(window, '6', xCenter-220, yCenter+280, [1 0 0]);
% Draw the rect to the screen
Screen('DrawTexture', window, RocketTexture, [], cRect);
% Draw travel costs
DrawFormattedText(window, '-5', 'center', yCenter-100, white);
% Flip to the screen
vbl = Screen('Flip', window, vbl + 0.5*ifi);
% Increment the time
time = time + ifi;
end
WaitSecs(1);
Screen('Flip', window);
WaitSecs(1);
end
if NoRightAnswers >= MinNoRightAnswers
break;
end
end
% check if participant even failed in last pattern training block
if (NoPatternTrainings == NoMiniBlocks) && (NoRightAnswers < MinNoRightAnswers)
NoPatternTrainings = 99;
end
disp(strcat('Nr of trainings: ',int2str(NoPatternTrainings)));
%%%%%%% SHORT BREAK%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DrawFormattedText(window, 'Als nächstes zeige ich Ihnen eine Besonderheit des Kommandos (S)prung.',...
'center', 'center', white);
Screen('flip', window);
WaitSecs(3.);
% %%%%%%%%%%%% PRACTISE JUMP ACTION IN LOW NOISE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Im richtigen Experiment kann es passieren, dass Ihre Reise mit (S)prung unzuverlässig ist.'...
'\n\n\n\n In solchen Fällen verfehlt das Raumschiff den Zielplaneten'...
'\n\n und landet stattdessen auf einem der beiden Nachbarplaneten des Zielplaneten.'];
% Draw all the text in one go
DrawFormattedText(window, text, 'center', screenYpixels * 0.25, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
% %%%%%%%%%%%% PRACTISE RIGHT ACTION IN LOW NOISE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Das Bild soll Ihnen noch einmal verdeutlichen was das bedeutet.'...
'\n\n Die durchgezogene rote Linie zeigt den Sprung zum erwarteten Zielplaneten, '...
'\n\n die gestrichelten Linien zeigen Ihnen wo Ihr Raumschiff landen kann, wenn es den Zielplaneten verfehlt.'];
Reisemuster= imread ('Reisemuster_Vorlage_3.jpg');
ReiseTexture= Screen('MakeTexture', window, Reisemuster);
Screen('DrawTexture', window, ReiseTexture);
% Draw all the text in one go
DrawFormattedText(window, text, 'center', screenYpixels * 0.1, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.95);
% Flip to the screen
Screen('Flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%% SHOW REISEMUSTER FOR JUMPING Right %%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['In manchen Planetensystemen befinden sich Asteroiden.'...
'\n\n In diesen passiert es besonders häufig, dass Sie den Zielplaneten bei (S)prung verfehlen.'...
'\n\n In den Planetensystemen ohne Asteroiden passiert das im Vergleich viel seltener.'...
'\n\n\n\n\n\n Um Ihnen ein Gefühl dafür zu geben, können Sie (S)prung jetzt in beiden Bedingungen ausprobieren.'...
'\n\n Beachten Sie, dass das Reisemuster dabei gleich bleibt und'...
'\n\n lediglich weniger zuverlässig ist.'];
% Draw all the text in one go
DrawFormattedText(window, text,'center', screenYpixels * 0.10, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
Screen('flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
text = ['Wir fangen mit Planetensystemen ohne Asteroiden an.'...
'\n\n Hier landen Sie, wenn Sie (S)prung wählen, fast immer auf dem erwarteten Zielplaneten.'...
'\n\n Hinweis: Die Häufigkeit mit der Sie in dieser Bedingung Ihren Zielplaneten verfehlen,'...
'\n\n ist über das gesamte Experiment gleich.'];
% Draw all the text in one go
DrawFormattedText(window, text,'center', screenYpixels * 0.10, white);
% Press Key to continue
DrawFormattedText(window, 'Drücken Sie eine Taste, um fortzufahren.', ...
'center', screenYpixels*0.9);
Screen('flip', window);
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rnd_val = [0.2320 0.7325 0.9631 0.6932 0.8595 0.8387 ...
0.0786 0.0716 0.0324 0.9084 0.6857 0.0666];
NoTrials = 12; %change to 12
NoMiniBlocks = 1;
points = 1000;
for n = 1:NoMiniBlocks
for t = 1:NoTrials
while(true)
if t < 7
start = t;
else
start = t-6;
end
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
planetList = Practise;
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], rocketPos(:,start)');
vbl = Screen('flip', window);
% Wait for a key press
[secs, keyCode, deltaSecs] = KbPressWait;
Key = KbName(keyCode);
if iscell(Key)
Key = Key{1};
end
if strcmp(Key, 'ESCAPE')
sca;
return;
elseif strcmp(Key, 's')
p = state_transition_matrix(3, start, :);
next = find(cumsum(p)>=rnd_val(t),1);
if next ~= jumps(start)
missed = 1;
else
missed = 0;
end
points = points + actionCost(2);
% move the rocket
time = 0;
locStart = imagePos(start, :);
locEnd = imagePos(next, :);
while time < md
% Position of the square on this frame
xpos = locStart(1) + time/md*(locEnd(1) - locStart(1));
ypos = locStart(2) + time/md*(locEnd(2) - locStart(2));
% Center the rectangle on the centre of the screen
cRect = CenterRectOnPointd(rocketRect, xpos, ypos);
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% draw planets
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw the rect to the screen
Screen('DrawTexture', window, RocketTexture, [], cRect);
% Flip to the screen
DrawFormattedText(window, '-5', 'center', yCenter-100, white);
vbl = Screen('Flip', window, vbl + 0.5*ifi);
% Increment the time
time = time + ifi;
end
if missed
% draw fuel tank
draw_point_bar(points, window, xCenter, screenYpixels);
% plot planets for the given mini block
planetList = Practise;
draw_planets(planetList, window, PlanetsTexture, planetsPos);
% Draw the rocket at the starting position
Screen('DrawTexture', window, RocketTexture, [], cRect);
DrawFormattedText(window, 'Ziel verfehlt', 'center', 'center', [1 0 0]);
WaitSecs(1);