Set Shifting
MEDState Notation Repository › Forums › Coding Help Archive › Set Shifting
- This topic has 2 replies, 1 voice, and was last updated 8 years, 9 months ago by
Med_Support.
-
AuthorPosts
-
October 2, 2014 at 4:33 pm #12880
Med_Support
Moderatorblee13
Hello, I am having trouble writing a program for set shifting… Basically, the animal will be under one of two rules. The animal must have 8 out of the previous 10 trials correct, at which point the rule will switch. The problem is, how do I keep a running track of correct and incorrect trials? I was thinking of the following: Keep a running track of the trial number. That is easy. Let’s just say it is F and we ADD F every trial…Then a trial comes along and the animal completes that trial, we assign 1 or 0 to a DIM array. Lets say we SET DIM D= 10000… And after every trial we SET D(F) = 1 or 0 (1 and 0 corresponding to correct and incorrect, respectively). After every trial we also want to assess whether or not the animal met criteria of 8 out of the last 10 trials correct… To do this, would the following be executable?: SET X = D(F) + D(F-1) + D(F-2) …….. D(F-9)IF X = 8 [@SwitchRules, @StayOnCurrentRule]@SwitchRules: [initiate a trial on a different rule]@StayOnCurrentRule: [re-initiate a trial on the current rule] If this works, then that would be great. But what happens if the animal gets 8 out of 8 correct in the first 8 trials? When I do SET X = D(F) + D(F-1) + D(F-2) …….. D(F-9) during the first 8-9 trials, I would be trying to access an element of the array D that is out of bounds… How would I assign the value of 0 to the first 10 elements of an array (10 is just arbitrary) from, the start of the program? Also, if I do set the first 10 elements of array D to 0, I would also need to set the first 10 elements of F to some arbitrary values, like 0 as well.
So far, I have experimented with the following code which compiled but does not seem to “switch rules.” This isn’t the actual set shift program, I just wrote a simple program to see if the D(F) + D(F-1) + D(F-2) …… + D(F-9) syntax would work…
Thanks!
\P = error \C = correct ^WN = 10 ^Tone = 3 ^LeftLever = 13 ^RightLever = 12 ^Pellet = 16 ^LeftLeverResponse = 3 ^RightLeverResponse = 2 DIM T = 10000 LIST D = 1, 2 \WN is left Tone is right S.S.1, S1, #START: ---> S2 S2, 5": RANDD X = D; ADD F ---> S3 S3, 0.01": IF X = 1[@1, @NOT1] @1: ON ^WN, ^LeftLever, ^RightLever ---> S4 @2: ON ^Tone, ^LeftLever, ^RightLever ---> S5 S4, #R^RightLeverResponse: OFF ^WN, ^LeftLever, ^RightLever; SET T(F) = 0; ADD P ---> S6 #R^LeftLeverResponse: OFF ^WN, ^LeftLever, ^RightLever; SET T(F) = 1; ADD C ---> S6 S5, #R^LeftLeverResponse: OFF ^Tone, ^LeftLever, ^RightLever; SET T(F) = 0; ADD P---> S6 #R^RightLeverResponse: OFF ^Tone, ^LeftLever, ^RightLever; SET T(F) = 1; ADD C ---> S6 S6, 0.01": IF F >= 10 [@10, @NOT10] @10: SET V = T(F) + T(F-1) + T(F-2) + T(F-3) + T(F-4) + T(F-5) + T(F-6) + T(F-7) + T(F-8) + T(F-9); IF V = 8 [@Switch, @Stay] @Switch: ---> S12 @Stay: ---> S2 @NOT10: ---> S2 S12, 0.01": ON ^Pellet ---> S13 S13, 0.5": OFF ^Pellet ---> S2 \Display S.S.2, S1, #START: ---> S2 S2, 0.01": SHOW 1, Trials,F, 2, Rewards, C, 3, Wrong, P ---> SX [/color]
October 3, 2014 at 9:49 am #12879Med_Support
ModeratorGary Bamberger
All variables and arrays in MSN are initialized to 0 when the programs starts. You don’t have to do anything for this to happen, it is given to you.
With your code sample it looks like you are close, but there is a problem with the IF statement:
S6, 0.01": IF F >= 10 [@10, @Not10] @10: SET V = T(F) + T(F-1) + T(F-2) + T(F-3) + T(F-4) + T(F-5) + T(F-6) + T(F-7) + T(F-8) + T(F-9); IF V = 8 [@Switch, @Stay] @Switch: ---> S12 @Stay: ---> S2 @Not10: ---> S2
What happens if V = 9 or 10. It will not switch. You need to check IF V >= 8.
Gary
October 6, 2014 at 9:26 am #12884Med_Support
Moderatorblee13
As always, thanks for your help Gary!
-
AuthorPosts
- You must be logged in to reply to this topic.