psychopy.org | Reference | Downloads | Github

(edited) Routine not running, even though console.log() suggests it is

URL of experiment: https://pavlovia.org/AnthonyGabay/partner_selection_v1

I have some interestingly strange behaviour going on in my task (separate from an issue I opened yesterday, which has now been solved). I should preface this by saying that all behaviour works as it should locally from python code, but not online with the javascript code.

I know the below is pretty long and involved, but I wanted to give as much detail as I could.

Task flow:

Participants can choose ‘yes’ or ‘no’ in the decision_phase routine. If yes, then the ‘engaged’ routine kicks in. If no, or there was no response, the engaged routine is skipped. This part of task is working as expected. The behaviour of ‘engaged’ is controlled by a variable set in the ‘decision_phase’. If yes, interact = 1, if no interact = 0, if no response interact =2. The engaged routine runs only when interact = 1.

If no response was made during the decision_phase, the ‘timeout’ routine should be triggered. This is not currently working online.

The task goes through the ‘detals_loop’ for a certain amount of time (currently set at 15 seconds). At the end of this time it breaks out of the loop and the ‘new_environment’ routine should run. Now, this works as expected if one selects ‘no’ or makes no response at each decision_phase in the inner loop. If at any point one selects yes at the decision_phase, the new_environment doesn’t behave as it should for that iteration of the outer loop.

I have taken the conditional statement out of the ‘timeout’ routine’s code, so it should run every time. However, it never runs. I have put a console.log(var) statement in to this routine, and that does print the expected variable at the correct value (it’s the interact variable which is set depending on the decision at ‘decision_phase’). I can’t for the life of me figure out why this routine is not running.

The ‘new_environment’ behaviour is also baffling me. I’ve tried various console.log calls to try and understand what’s happening, and the console.log always prints what I would expect it to, but the routine only runs as it should if either ‘no’ was selected at the ‘decision_phase’, or no response was made; but never if even one ‘yes’ response was made. I can’t see anywhere in my code components where the effect of a yes decision should influence the running of the ‘new_environment’ routine.

Any thoughts on additional debugging strategies would be gratefully received.

Thanks,
Anthony

Edit:
Curiouser and curiouser.
I’ve been systematically changing things to debug this. I simplified it by removing the ‘timeout’ routine. When I do that, the ‘end_environment’ routine in the outer loop never runs, regardless of the decision during the decision_phase. When I put the ‘timeout’ routine back, with no conditional statements (so it should always run), not only does it still not run, but the end_environment returns to its previous (incorrect) behaviour - that is, it runs if no decision is made or a ‘no’ decision is made but not if a ‘yes’ decision is made.

There seems to be something seriously wrong going on here.

To solve this I restarted from scratch with experimental settings set to version 2020.2.8.

Note that setting version number within the old file didn’t solve the problem, rather than having to start a new file from scratch with version number set from the beginning.

In case it’s useful for moderators interested in looking into the cause of the problems, I’ll just add some other iterations of moving routines around and the effects they had, all with an absence of any code changes.

I’d be super interested to hear if any of the devs do look into this and figure out what’s going on, because its seems pretty weird that there are non-coded, inter-routine behaviour influences.

Moving ‘new_environment’ to the front of the flow (just before the inner loop): This changed the behaviour such that when yes was selected during the decision phase the inner loop would immediately terminate.

Removing ‘new_environment’ entirely: when selecting ‘no’ in the decision_phase, the timeout routine ran (correct behaviour at this point because I’d removed the conditional code component). But when selecting ‘yes’, timeout didn’t run (incorrect behaviour). However, clicking yes did not cause the inner loop to terminate, as it did with the version above.

1 Like