+x
Dear Dave,
Thanks for the reply.
I will try the question about the keyboard.
I will change my question about setting the speed of the throws by the NPCs.
I had a suggestion the other day to create a scheduling list, but that didn't work and instead I used "if else" and it worked.
What I want to do is have the NPCs (P1, P4) only make fast passes to other NPCs (P3).
If a fast pass is thrown by another player (mainly participant P2), it is constrained to throw only slow passes, not fast passes.
With the code below(The green line drawn corresponds to the area), I could set up P1 or P4 to only make fast passes against P3.
However, the "if fast paths are received, only slow paths can be thrown" constraint, which was working until I wrote the if else to do this, does not work in this code.
In other words, if a fast pass is received from P2 (participant), the NPCs will throw a fast pass against P3.
What part of the code is incorrect?
Currently, the program for the trial looks like this:
**************************************************************************************************************
**************************************************************************************************************
TRIALS
**************************************************************************************************************
**************************************************************************************************************
// handles the NPCs (virtual players) as well as player 2 in "spectate" conditions
<trial npctrial>
/ ontrialbegin = [
values.received_from = values.ball_at;
values.ball_at = values.throw_to;
if (values.ball_at == 2) {
values.player2received += 1;
};
expressions.set_offsets;
values.player1state = (values.ball_at == 1) + 1;
values.player2state = (values.ball_at == 2) + 1;
values.player3state = (values.ball_at == 3) + 1;
values.player4state = (values.ball_at == 4) + 1;
values.player5state = (values.ball_at == 5) + 1;
values.player6state = (values.ball_at == 6) + 1;
values.player7state = (values.ball_at == 7) + 1;
values.player8state = (values.ball_at == 8) + 1;
values.player9state = (values.ball_at == 9) + 1;
values.throw_to = list.throwschedule.nextvalue;
values.delay = list.delayschedule.nextvalue;
if (values.throw_to == 0){
values.throw_to = list.npcs.nextindex;
values.delay = round(rand(1, 4)) * 1000;
};
while (values.throw_to == values.ball_at){
values.deprecated +=1;
values.throw_to = list.throwschedule.nextvalue;
values.delay = list.delayschedule.nextvalue;
};
]
/ ontrialend = [
values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
values.throwcount += 1;
values.previousthrowspeed = parameters.throwspeed;
if (values.previousthrowspeed == parameters.fastspeed) { // if previous throw was fast
parameters.throwspeed = parameters.slowspeed; // next throw must be slow
} else if(values.throw_to == 3){
parameters.throwspeed = parameters.fastspeed;
} else {
parameters.throwspeed = parameters.slowspeed;
};
if (values.ball_at == 2) {
values.player2thrown += 1;
};]
/ stimulusframes = [1=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
stats]
/ inputdevice = keyboard
/ showmousecursor = false
/ validresponse = (0)
/ trialduration = values.delay
/ branch = [
return trial.throw;
]
</trial>
<trial player2forceslow>
/ ontrialbegin = [
values.received_from = values.ball_at;
expressions.set_offsets;
values.player2received += 1;
values.player1state = 1;
//catch
values.player2state = 2;
values.player3state = 1;
values.player4state = 1;
values.player5state = 1;
values.player6state = 1;
values.player7state = 1;
values.player8state = 1;
values.player9state = 1;
values.ball_at = 2;
values.throw_to = list.throwschedule.nextvalue;
values.delay = list.delayschedule.nextvalue;
]
/ ontrialend = [
parameters.throwspeed = parameters.slowspeed;
]
/ validresponse = (0)
/ trialduration = 0
/ branch = [
return trial.player2;
]
/ recorddata = false
</trial>
// handles the human player
<trial player2speed>
/ ontrialbegin = [
values.received_from = values.ball_at;
expressions.set_offsets;
values.player2received += 1;
values.player1state = 1;
//catch
values.player2state = 2;
values.player3state = 1;
values.player4state = 1;
values.player5state = 1;
values.player6state = 1;
values.player7state = 1;
values.player8state = 1;
values.player9state = 1;
values.ball_at = 2;
values.throw_to = list.throwschedule.nextvalue;
values.delay = list.delayschedule.nextvalue;
]
/ ontrialend = [
if (trial.player2speed.response == "slow") {
parameters.throwspeed = parameters.slowspeed;
} else if (trial.player2speed.response == "fast") {
parameters.throwspeed = parameters.fastspeed;
};
]
/ stimulusframes = [1=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
stats, slow, fast]
/ validresponse = (button.slow, button.fast)
/ branch = [
return trial.player2;
]
/ recorddata = false
</trial>
<button slow>
/ caption = "SLOW THROW"
/ size = (15%, 8%)
/ position = (50%, 45%)
/ fontstyle = ("Verdana", 3%, true)
</button>
<button fast>
/ caption = "FAST THROW"
/ size = (15%, 8%)
/ position = (50%, 55%)
/ fontstyle = ("Verdana", 3%, true)
</button>
<trial player2>
/ ontrialbegin = [
//values.received_from = values.ball_at;
//expressions.set_offsets;
//values.player2received += 1;
//values.player1state = 1;
//catch
//values.player2state = 2;
//values.player3state = 1;
//values.player4state = 1;
//values.player5state = 1;
//values.player6state = 1;
//values.player7state = 1;
//values.player8state = 1;
//values.player9state = 1;
//values.ball_at = 2;
//values.throw_to = list.throwschedule.nextvalue;
//values.delay = list.delayschedule.nextvalue;
]
/ ontrialend = [
values.throw_to = substring(trial.player2.response, length(trial.player2.response)-1, 1);
values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
values.player2thrown += 1;
values.throwcount += 1;
]
/ stimulusframes = [1=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
stats]
/ validresponse = (player1, player3, player4, player5, player6, player7, player8, player9)
/ responsemessage = (player1, player1click, 100)
/ responsemessage = (player3, player3click, 100)
/ responsemessage = (player4, player4click, 100)
/ responsemessage = (player5, player5click, 100)
/ responsemessage = (player6, player6click, 100)
/ responsemessage = (player7, player7click, 100)
/ responsemessage = (player8, player8click, 100)
/ responsemessage = (player9, player9click, 100)
/ branch = [
return trial.throw;
]
</trial>
// implements the throw animation
<trial throw>
/ ontrialbegin = [
trial.throw.resetstimulusframes();
if (parameters.throwspeed == parameters.fastspeed) {
systembeep.duration = 2000;
systembeep.frequency = 100;
systembeep.playthrough = true;
trial.throw.insertstimulustime(systembeep, 900 + expressions.throwduration);
};
picture.player1.skip = expressions.skip_player1pic;
picture.player2.skip = expressions.skip_player2pic;
picture.player3.skip = expressions.skip_player3pic;
picture.player4.skip = expressions.skip_player4pic;
picture.player5.skip = expressions.skip_player5pic;
picture.player6.skip = expressions.skip_player6pic;
picture.player7.skip = expressions.skip_player7pic;
picture.player8.skip = expressions.skip_player8pic;
picture.player9.skip = expressions.skip_player9pic;
values.throwingplayer_x = list.player_x.item(values.ball_at);
values.throwingplayer_y = list.player_y.item(values.ball_at);
values.receivingplayer_x = list.player_x.item(values.throw_to);
values.receivingplayer_y = list.player_y.item(values.throw_to);
values.ball_x = values.receivingplayer_x;
expressions.set_throwoffset;
]
/ ontrialend = [
if (values.throwcount >= parameters.nthrows){
values.stop = true;
} else {
values.stop = false;
};
picture.player1.skip = false;
picture.player2.skip = false;
picture.player3.skip = false;
picture.player4.skip = false;
picture.player5.skip = false;
picture.player6.skip = false;
picture.player7.skip = false;
picture.player8.skip = false;
picture.player9.skip = false;
]
/ stimulustimes = [0=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
playerthrow0, stats;
500=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
playerthrow1, stats;
600=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
playerthrow2, stats;
700=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
playerthrow3, stats;
800=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
playerthrow4, stats;
900=ball_to]
/ inputdevice = keyboard
/ showmousecursor = false
/ validresponse = (0)
/ trialduration = 900 + expressions.throwduration
/ branch = [
if (values.throw_to == 2 && !parameters.spectate){
if (parameters.throwspeed == parameters.fastspeed) { // if throw received was fast
return trial.player2forceslow; // player 2 must throw slow
} else if (parameters.throwspeed == parameters.slowspeed) { // otherwise go to speed selection first
return trial.player2speed;
};
} else {
return trial.npctrial;
}
]
/ recorddata = false
</trial>
// displays the welcome message / instructions / game cover story
<trial instructions>
/ stimulusframes = [1=clearscreen, banner, logo, instructions, play]
/ validresponse = (play)
/ recorddata = false
</trial>
// displays the "Connecting to other players..." message and animation
<trial start>
/ ontrialbegin = [
list.npcs.reset();
values.throw_to = list.throwschedule.nextvalue;
values.delay = list.delayschedule.nextvalue;
values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
values.ball_x = list.player_x.item(values.throw_to);
]
/ stimulusframes = [1=clearscreen, connectingmessage, connectinganimation]
/ inputdevice = keyboard
/ validresponse = (0)
/ trialduration = replace(5000,6000,7000)
/ branch = [
if (values.throw_to == 2 && !parameters.spectate){
return trial.player2speed; //trial.player2;
} else {
return trial.npctrial;
}
]
/ recorddata = false
</trial>
// end screen with exit button
<trial thankyou>
/ stimulusframes = [1=clearscreen, thankyoumessage, exit]
/ validresponse = (exit)
/ recorddata = false
</trial>
Sorry for the length of this message.
Please confirm.
Respectfully yours,