/* Some links to the Monty Hall Dilemma: http://math.ucsd.edu/~crypto/Monty/monty.html http://econwpa.wustl.edu:8089/eps/exp/papers/9906/9906001.html */
Experiment(){
Context(){
AssignmentGroup(){
SubjectCode = "pxlab";
ExperimentName = "Monty Hall Problem";
TrialFactor = 100;
// Set this to 1 if you want to be informed about all internal parameter values
new open = 0;
// These image matrices are needed // All doors closed
new all_closed = ["door_closed.jpg", "door_closed.jpg", "door_closed.jpg"];
// The quiz master's selection is open: three possibilities
new open0 = ["door_goat.jpg", "door_closed.jpg", "door_closed.jpg"];
new open1 = ["door_closed.jpg", "door_goat.jpg", "door_closed.jpg"];
new open2 = ["door_closed.jpg", "door_closed.jpg", "door_goat.jpg"];
// The final result: six possibilities
new open0_car1 = ["door_goat.jpg", "door_car.jpg", "door_goat.jpg"];
new open0_car2 = ["door_goat.jpg", "door_goat.jpg", "door_car.jpg"];
new open1_car0 = ["door_car.jpg", "door_goat.jpg", "door_goat.jpg"];
new open1_car2 = ["door_goat.jpg", "door_goat.jpg", "door_car.jpg"];
new open2_car0 = ["door_car.jpg", "door_goat.jpg", "door_goat.jpg"];
new open2_car1 = ["door_goat.jpg", "door_car.jpg", "door_goat.jpg"];
// This is the position of the car
new car = Trial.RandomGenerator:Car.ResponseCode;
// The subject's first choice
new firstChoice = Trial.PictureMatrix:FirstChoice.Selection;
new firstChoiceMsg = Trial.PictureMatrix:FirstChoice.Selection+1;
// The possible selection sets remaining for Monty Hall after the subject's first choice
new set01 = [0, 1];
new set02 = [0, 2];
new set12 = [1, 2];
// Monty Hall's actual selection set of doors after the subject's choice
new selectionSet = (firstChoice==0)? set12: ((firstChoice==1)? set02: set01);
// A random sample from Monty Hall's selection set // used when the subject chooses the car's position as her first choice
new randomSelection = Trial.RandomGenerator:Selection.ResponseCode;
// Monty Hall's actual selection
new selection = (firstChoice==car)? randomSelection: ((car==valueOf(selectionSet, 0))? valueOf(selectionSet, 1): valueOf(selectionSet, 0));
new selectionMsg = selection+1;
// Subject's response to second question
new change = (Trial.ChoiceResponse.Selection==1);
new decisionFeedback = change? "You decided to change your mind": "You stick to your first choice";
// The subjects final choice
new finalChoice = change? ((selection==valueOf(selectionSet, 0))? valueOf(selectionSet, 1): valueOf(selectionSet, 0)): firstChoice;
new finalChoiceMsg = finalChoice+1;
// Indicates that the subject wins the car
new win = finalChoice==car;
new resultMsg = win? "You win!": "Sorry, you loose!";
// Final feedback messages for standard and for open parameter case
new finalFeedback = ["%decisionFeedback%, so your final choice is door %finalChoiceMsg%.", " ", "Press any key to go on!"];
new openFinalFeedback = ["The car is behind door %car% of [0,1,2]", "The first choice is %firstChoice% of [0,1,2]", "Monty Hall has set %selectionSet% of [0,1,2] to select from.", "He actually opens door %selection% of [0,1,2]", "The final choice is %finalChoice% of [0,1,2]", " ", "%decisionFeedback%, so your final choice is door %finalChoiceMsg%.", " ", "Press any key to go on!"];
// Gap between images
new pictureGap = 20;
// Top left picture position for images of size 278x478 pixels
new pictureLocationX = -278-139-20;
new pictureLocationY = -300;
// Base line of first message text line
new messageLocationY = 240;
new imageDir = "@./images/monty_hall";
}
Session(){
Message(){
Text = ["Welcome to the", "Monty Hall Quiz Show!"];
Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
Duration = 2000;
}
}
SessionEnd(){
Message(){
Text = ["Thank you for visiting the", "Monty Hall Quiz Show!"];
Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
Duration = 2000;
}
}
Trial(){
RandomGenerator:Car(){
ProbabilityDistribution = [0.3333, 0.3333];
ResponseSet = [0, 1, 2];
DistributionType = de.pxlab.pxl.RandomGeneratorCodes.MULTINOMIAL_DISTRIBUTION;
JustInTime = 1;
}
TextParagraph:Car(){
Execute = open;
Text = ["The car is behind door %car% of [0,1,2]", " ", "[Note that internally the doors are numbered 0, 1, and 2 but the subject will see numbers 1, 2, and 3 which are more natural.]", " ", "Press any key to go on!"];
FontSize = 24;
Timer = de.pxlab.pxl.TimerCodes.RELEASE_RESPONSE_TIMER;
JustInTime = 1;
}
TextParagraph:Intro(){
Text = ["You have been invited to Monty Hall\'s quiz show where you have the chance to win a car hidden behind one of three doors.", "Choose one of the doors and confirm your choice with the space bar!"];
LocationY = messageLocationY;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_CENTER;
FontSize = 24;
JustInTime = 1;
Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
}
PictureMatrix:FirstChoice(){
Timer = de.pxlab.pxl.TimerCodes.MOUSE_TRACKING_RELEASE_KEY_TIMER;
FileName = all_closed;
Directory = imageDir;
NumberOfColumns = 3;
HorizontalGap = pictureGap;
LocationX = pictureLocationX;
LocationY = pictureLocationY;
ResponseSet = 32;
Selection = 0;
JustInTime = 1;
Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_LEFT;
}
RandomGenerator:Selection(){
ProbabilityDistribution = 0.5;
ResponseSet = selectionSet;
DistributionType = de.pxlab.pxl.RandomGeneratorCodes.MULTINOMIAL_DISTRIBUTION;
JustInTime = 1;
}
TextParagraph:OpenSelection(){
Execute = open;
Text = ["The car is behind door %car% of [0,1,2]", "The first choice is %firstChoice% of [0,1,2]", "Monty Hall has set %selectionSet% of [0,1,2] to select from.", "He actually opens door %selection% of [0,1,2]", " ", "Press any key to go on!"];
FontSize = 24;
Timer = de.pxlab.pxl.TimerCodes.RELEASE_RESPONSE_TIMER;
JustInTime = 1;
}
TextParagraph:Selection(){
Text = ["Your choice is door %firstChoiceMsg%.", " ", "Now Monty Hall, the quiz master, wants to help you a little bit. He opens one of the remaining doors from which he knows, that it does not contain the car!", " ", "Press any key to go on!"];
// LocationY = messageLocationY; // ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.BASE_CENTER;
FontSize = 24;
JustInTime = 1;
Timer = de.pxlab.pxl.TimerCodes.RELEASE_RESPONSE_TIMER;
}
TextParagraph:FinalChoice(){
Text = ["Remember, your choice was door %firstChoiceMsg%.", "Now that you have seen Monty Hall opening door %selectionMsg%, do you want to change your mind or do you want to stick to your first choice?"];
LocationY = messageLocationY;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_CENTER;
FontSize = 24;
JustInTime = 1;
Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
}
PictureMatrix:FinalChoice(){
Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
FileName = (selection==0)? open0: ((selection==1)? open1: open2);
Directory = imageDir;
NumberOfColumns = 3;
HorizontalGap = pictureGap;
LocationX = pictureLocationX;
LocationY = pictureLocationY;
JustInTime = 1;
Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_LEFT;
}
ChoiceResponse(){
Timer = de.pxlab.pxl.TimerCodes.MOUSE_TRACKING_TIMER;
Choices = ["stick to 1st choice", "change my mind"];
// FontSize = 24;
LocationY = messageLocationY+116;
Width = 1000;
Height = 48;
JustInTime = 1;
Selection = 0;
Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
}
TextParagraph:FinalChoiceFeedback(){
Text = open? openFinalFeedback: finalFeedback;
FontSize = 24;
JustInTime = 1;
Timer = de.pxlab.pxl.TimerCodes.RELEASE_RESPONSE_TIMER;
}
TextParagraph:Result(){
Text = ["%resultMsg%", " ", "Press ESC to stop, any other key to get a new try!"];
LocationY = messageLocationY;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_CENTER;
Alignment = de.pxlab.pxl.AlignmentCodes.CENTER;
FontSize = 24;
JustInTime = 1;
Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
}
PictureMatrix:Result(){
Timer = de.pxlab.pxl.TimerCodes.RELEASE_RESPONSE_TIMER;
FileName = (selection==0)? ((car==1)? open0_car1: open0_car2): ((selection==1)? ((car==0)? open1_car0: open1_car2): ((car==0)? open2_car0: open2_car1));
Directory = imageDir;
NumberOfColumns = 3;
DisableNonSelection = 0;
HorizontalGap = pictureGap;
LocationX = pictureLocationX;
LocationY = pictureLocationY;
JustInTime = 1;
Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
ReferencePoint = de.pxlab.pxl.PositionReferenceCodes.TOP_LEFT;
}
ClearScreen(){
Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
Duration = 500;
}
// Check whether the subject wants to procede or wants to stop
SetParameter(){
Parameter = "BlockState";
Value = (Trial.PictureMatrix:Result.ResponseCode==de.pxlab.pxl.KeyCodes.ESCAPE_KEY)? de.pxlab.pxl.StateCodes.BREAK: de.pxlab.pxl.StateCodes.EXECUTE;
JustInTime = 1;
}
}
// Command line assignments
AssignmentGroup();
}
Procedure(){
Session(){
Block(){
Trial();
}
}
}
}