The loops & buttons in a game do not work
I am writing an applet (a type of guessing game) that could collect
responses over the net. The buttons do not work properly, I also have
trouble with loops, as well as can not figure out how to store user input
data. I would appreciate any help that you could give me some hints how to
fix these issues or improve this code.
i) See my semi working code here. 2) Program flowchart here.
In summary, the applet generates a vector of random numbers between 0 and
1 and using those numbers draws a few geographical shapes on the screen
that resemble a face (Chernoff Faces). The program asks the user to guess
whether the face is "good" or "bad", based on values that are mapped into
geographical shapes. The user has to either ACCEPT or REJECT the shown
face and indicate their level of confidence about this decision. After
answering the user receives feedback whether the decision was correct or
not, the points are awarded for correct assessments and points are taken
away if the assessment is incorrect. There are many rounds of this game,
and the goal is to be able to improve ability to assess faces.
// GLOBAL UI & OTHER PARS
final int sizeW = 600;
final int sizeH = 600;
final int lineSpace = 30;
final int numberOfRandomValues = 20;
int frameRateSet = 30;
// FONT global
static final int fontSmall = 14; // SMALL text size
static final int fontMedium = 20; // MEDIUM text size
static final int fontLarge = 50; // LARGE text size
PFont yFont; // Arial Narrow 14 pt
// COLOR global
final color[] c = new color[41];
final color[] colorBW = {
color(204), color(255), color(0)
};
// CHERNOFF PRESETS
final int decisionValueUnit = 1;
final int acceptBadValue = -decisionValueUnit;
final int acceptGoodValue = decisionValueUnit;
final int rejectBadValue = decisionValueUnit;
final int rejectGoodValue = -decisionValueUnit;
int decisionValue = 0;
float[] weights = new float[numberOfRandomValues];
float [] faceValue = new float[100];
float eWeights = 0.05;
float sumFaceValue;
String msgFaceFeedback;
String msgGoodFeedback = "Good Face";
String msgBadFeedback = "Bad Face";
int faceWorth;
boolean goodFace;
boolean badFace;
String msgErrorFeedback = "Error 158 occured!";
String msgDecision;
// RANDOM VARIABLES for drawing chernoff face
float[] p = new float[numberOfRandomValues];
float[] rx = new float[numberOfRandomValues];
float[] ry = new float[numberOfRandomValues];
// PHASE
int switchPhaseMain = 1; //2=game
int switchExperimentState = 1; //1=face,2=feedback
int switchFaceCase = 0; // bad=0, good=1
int round = 1;
int numberOfRounds = 10;
boolean experimentOver;
boolean pause;
boolean faceOnSmall;
boolean faceOnLarge;
// SCORE
int pointsTotal = 0;
int [] points = new int[numberOfRounds];
int [] trials = new int[numberOfRounds];
int [] pointsEarned = new int[numberOfRounds];
// BUTTON: requires button class (button names)
Button btnBack;
Button btnReject;
Button btnAccept;
Button btnInstructNext;
Button btnNextFace;
Button btnInstructBack;
Button btnInstructStart;
Button btnFinish;
Button btnPause;
Button btnUnPause;
// BUTTON LABELS
String btnBackLabel = "Go Back";
String btnRejectLabel = "Reject";
String btnAcceptLabel = "Accept";
String btnIntructNextLabel = "Next";
String btnNextFaceLabel = "Next";
String btnIntructBackLabel = "Go Back";
String btnIntructStartLabel = "Start";
String btnFinishLabel = "Finish";
String btnPauseLabel = "Pause";
String btnUnPauseLabel = "Unpause";
// BUTTON PARAMETERS
int btnMargin = 500;
int btnTextPadding = 20;
int btnX = 30;
int btnY = btnMargin;
int btnWidth = 150;
int btnHeight = 50;
int btnXspace = 30;
int btnYspace = 10;
int btn1X = btnX;
int btn1Y = btnY;
int btn2X = btn1X+btnWidth+btnXspace;
int btn2Y = btnY;
int btn3X = btn2X+btnWidth+btnXspace;
int btn3Y = btnY;
int btnPauseX = 510;
int btnPauseY = 10;
int btnPauseW = btnWidth/2;
int btnPauseH = btnHeight/2;
// SETUP
void setup() {
size(sizeW, sizeH);
smooth();
frameRate(frameRateSet);
println("setup");
// COLOR (in void setup)
c[0] = color(#f4b264);
c[1] = color(#bee5e4);
c[2] = color(#fe022b);
c[3] = color(#082f56);
c[4] = color(#f8f3d6);
c[5] = color(#fceea7);
c[6] = color(#ff7101);
c[7] = color(#f1d7ca);
c[8] = color(#ffafc3);
c[9] = color(#abe6e2);
c[10] = color(#e2e8ce);
c[11] = color(#ffcb00);
c[12] = color(#aae354);
c[13] = color(#ddb0b7);
c[14] = color(#d2e6b5);
c[15] = color(#77a3be);
c[16] = color(#005c9d);
c[17] = color(#bb3325);
c[18] = color(#fdd4e2);
c[19] = color(#0dbbde);
c[20] = color(#643324);
c[21] = color(#99e1d3);
c[22] = color(#ff92a9);
c[23] = color(#a7bbba);
c[24] = color(#d0e099);
c[25] = color(#00b14b);
c[26] = color(#0376b9);
c[27] = color(#fedf2d);
c[28] = color(#fbd362);
c[29] = color(#fe5900);
c[30] = color(#4fb900);
c[31] = color(#fdd4e2);
c[32] = color(#ddb0b7);
c[33] = color(#a9998a);
c[34] = color(#77a3be);
c[35] = color(#bdb0b7);
c[36] = color(#778C85);
c[37] = color(#F2E6D0);
c[38] = color(#395059);
c[39] = color(#8C1B2F);
c[40] = color(#B5BFAA);
// FONT
yFont = createFont("Arial", fontSmall, true);
textAlign (CENTER, CENTER);
// BUTTONS (requires Button class)
btnBack = new Button(btnBackLabel, btn1X, btn1Y, btnWidth,
btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnReject = new Button(btnRejectLabel, btn2X, btn2Y, btnWidth,
btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnAccept = new Button(btnAcceptLabel, btn3X, btn3Y, btnWidth,
btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnInstructNext = new Button(btnIntructNextLabel, btn3X, btn3Y,
btnWidth, btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnNextFace = new Button(btnIntructNextLabel, btn3X, btn3Y,
btnWidth, btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnInstructBack = new Button(btnIntructBackLabel, btn2X, btn2Y,
btnWidth, btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnInstructStart = new Button(btnIntructStartLabel, btn3X, btn3Y,
btnWidth, btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnFinish = new Button(btnFinishLabel, btn3X, btn3Y, btnWidth,
btnHeight, colorBW[0], colorBW[1], colorBW[2]);
btnPause = new Button(btnPauseLabel, btnPauseX, btnPauseY,
btnPauseW, btnPauseH, colorBW[0], colorBW[1], colorBW[2]);
btnUnPause = new Button(btnUnPauseLabel, btnPauseX, btnPauseY,
btnPauseW, btnPauseH, colorBW[0], colorBW[1], colorBW[2]);
}
// DRAW
void draw() {
smooth();
// PHASE
switch (switchPhaseMain) {
case 1:
screenInstructions();
manageButtons();
break;
case 2:
screenInstructions();
manageButtons();
faceOnLarge=true;
break;
case 3:
if (faceOnLarge==true) {
chernoffDraw(round);
pointsEarned[round]=decisionValue;
points[round] = points[round]+pointsEarned[round];
trials[round] = trials[round]+1;
}
manageButtons();
break;
case 4:
screenInstructions();
manageButtons();
break;
case 5:
screenInstructions();
manageButtons();
break;
default:
text ("Error 158 unknown phase: " + switchPhaseMain, width/2, height/4);
println ("Error 158 unknown phase: " + switchPhaseMain);
exit();
}
}
// MOUSE PRESSED
void mousePressed() {
switch(switchPhaseMain) {
case 1:
if (btnInstructNext.press()) {
switchPhaseMain++;
println("Next Button Pressed: 1st Phase of experiment is: "
+switchPhaseMain);// TEMPORARY
}
break;
case 2:
if (btnInstructBack.press()) {
println("Back Button Pressed: 2st Phase of experiment is: "
+switchPhaseMain);// TEMPORARY
switchPhaseMain--;
}
if (btnInstructStart.press()) {
println("Start Button Pressed: 2st Phase of experiment is: "
+switchPhaseMain);// TEMPORARY
switchPhaseMain++;
}
break;
case 3:
if (btnReject.press()) {
if (goodFace == true) {
msgFaceFeedback = msgGoodFeedback;
decisionValue = rejectGoodValue;
msgDecision = "wrongly rejected";
}
else if (goodFace == false) {
msgFaceFeedback = msgBadFeedback;
decisionValue = rejectBadValue;
msgDecision = "correctly rejected";
}
pointsEarned[round]=decisionValue;
println("Reject Pressed: 0 State moved to (3):
"+switchExperimentState+". Round: "+round+". Decision value is :" +
decisionValue);// TEMPORARY
points[round] = points[round]+pointsEarned[round];
trials[round] = trials[round]+1;
manageButtons();
}
else if (btnAccept.press()) {
switch (switchFaceCase) {
case 0:
msgFaceFeedback = msgGoodFeedback;
decisionValue = acceptGoodValue;
msgDecision = "correctly accepted";
break;
case 1:
msgFaceFeedback = msgBadFeedback;
decisionValue = acceptBadValue;
msgDecision = "wrongly accepted";
break;
default:
break;
}
pointsEarned[round]=decisionValue;
points[round] = points[round]+pointsEarned[round];
trials[round] = trials[round]+1;
println("Accept Pressed: 0 state moved to (2):
"+switchExperimentState+". Round: "+round+". Decision value is :" +
decisionValue);
if (faceWorth!=0) {
switchExperimentState=2;
}
introNextFaceRound(round);
manageButtons();
//break;
}
else if (btnNextFace.press()) {
println("Next Button Pressed: 2nd Phase of experiment is: "
+switchPhaseMain);// TEMPORARY
//faceOnSmall=true;
manageButtons();
faceOnLarge=true;
}
println("Mouse Pressed: We are still in the CHERNOFF FACE (3rd)
switchPhaseMain: " +switchPhaseMain);// TEMPORARY
break;
case 4:
println("Mouse Pressed: 4th Phase of experiment is: "
+switchPhaseMain);// TEMPORARY
if (btnFinish.press()) {
switchPhaseMain++;
}
break;
case 5:
println("Mouse Pressed: 5th Phase of experiment is: "
+switchPhaseMain); // TEMPORARY
switchPhaseMain = 0;
break;
default:
text ("Error 158 unknown phase: " + switchPhaseMain, width/2,
height/4+lineSpace);
println ("Mouse Pressed: Error 158 unknown state " + switchPhaseMain);
break;
} //switch
} //mouse pressed
// FUNCTION: DARAWING CHENFOFF FACE
int activate(float sumFaceValue) {
if (sumFaceValue > 0.5) {
return 1;
}
else {
return -1;
}
}
float[] getWeights() {
return weights;
}
void chernoffDraw(int rn) {
round = rn;
faceWorth=0;
chernoff(numberOfRandomValues);
faceValue[round] = sumFaceValue;
showScore(round);
faceOnLarge =false;
faceWorth = activate(sumFaceValue);
if ((sumFaceValue>=0.5) && (sumFaceValue<=1)) {
switchFaceCase = 0; // good face
msgFaceFeedback = msgGoodFeedback;
goodFace = true;
badFace = false;
println("This was a "+msgFaceFeedback+". You shoudl accept it!");
//TEMPORARY
}
else if ((sumFaceValue< 0.5) && (sumFaceValue<=0)) {
switchFaceCase = 1; // bad state
msgFaceFeedback = msgBadFeedback;
goodFace = false;
badFace = true;
println("This was a "+msgFaceFeedback+". You shoudl reject it!");
//TEMPORARY
}
else if ((sumFaceValue<0) || (sumFaceValue>1)) {
msgFaceFeedback = msgErrorFeedback ;
println(msgErrorFeedback);
text(msgFaceFeedback, width/2, height/4);
;
}
//}
println("Experiment round: "+round+ ". "+msgFaceFeedback+" real value
is: "+ faceValue[round]); //TEMPORARY
}
void chernoff(int n) {
background(c[36]);
smooth();
float[] weights = new float[n];
// GENERATING RANDOM NUMBERS
sumFaceValue=0;
for (int i = 0; i < numberOfRandomValues; i++) {
p[i] = random(0, 1); //p is a vector of random values
weights[i] = eWeights;
println(p[i]);
sumFaceValue+=p[i]*weights[i];
println("trial ["+i+"] weight is: "+weights[i]+". Random value is: " +
p[i]+ ". Average Sum is: "+sumFaceValue);
}
// DARAWING
pushMatrix();
color eggHeadColor=color(215);
color faceColor = color(235);
color eyeColor = color(255);
translate(width/2, height/2);
int x=0;
int y=0;
float scale10=10;
// egg head
Egg egg_head;
float egg_head_base=250;
float egg_head_var=50;
int headX=0;
int headY=-height/5;
float tilt_head=PI;
float eggHeadSize= egg_head_base+egg_head_var*p[12];
egg_head = new Egg(headX, headY, tilt_head, eggHeadSize, eggHeadColor);
egg_head.display();
// head
int head_bottom_displace=6;
float topX = scale10*(10+p[1]*16); //top width
float topY = scale10*(16+p[2]*8); //top height
float botX = scale10*(12+p[3]*16); //bottom width
float botY = scale10*(12+p[4]*8); //bottom height
fill(faceColor);
noStroke();
ellipse (x, y, topX, topY);
ellipse (x, y+head_bottom_displace*scale10, botX, botY);
// eyes
float eyeX = scale10*(4+p[7]*4); //float eyeX = random(40, 80);
float eyeY = scale10*(2+p[8]*2); //float eyeY = random(20, 40);
float eye_spacing =4;
stroke(4);
fill(eyeColor);
strokeWeight(4);
ellipse (x-eye_spacing*scale10, y, eyeX, eyeY);
ellipse (x+eye_spacing*scale10, y, eyeX, eyeY);
// pupils
int mini_pupils=8;
int enlarge_pupils=12;
strokeWeight(mini_pupils+p[9]*enlarge_pupils);
point(x-eye_spacing*scale10, y);
point(x+eye_spacing*scale10, y);
// mouth
float mouth = scale10*(-4+p[5]*8); // float mouth = random(-40, 40);
strokeWeight(4);
beginShape();
noFill();
int mouth_displace=6;
int mouth_bottom=8;
curveVertex(x-mouth_displace*scale10, y+mouth_bottom*scale10);
curveVertex(x-mouth_displace*scale10, y+mouth_bottom*scale10);
curveVertex(x, y+(mouth_bottom*scale10+mouth));
curveVertex(x+mouth_displace*scale10, y+mouth_bottom*scale10);
curveVertex(x+mouth_displace*scale10, y+mouth_bottom*scale10);
endShape();
// nose
float noY = scale10*(2.5+p[5]*4); //float noY = random(20, 60);
float noX = scale10*(2+p[6]*4); //float noX = random(20, 60);
float nol = 2*scale10;
strokeWeight(4);
beginShape();
vertex(x, y+nol);
vertex(x-noX, y+noY);
vertex(x+noX, y+noY);
endShape(CLOSE);
// brows
float br_displace=2; // float brY1 = random(20, 80);
float br_length=6; //float brY2 = random(20, 80);
float brY1 = scale10*(br_displace+p[10]*br_length);
float brY2 = scale10*(br_displace+p[11]*br_length);
line(x-br_displace*scale10, y-brY1, x-br_length*scale10, y-brY2);
line(x+br_displace*scale10, y-brY1, x+br_length*scale10, y-brY2);
// FINISH FACE
popMatrix();
faceOnSmall = false;
}
===
// EGG CLASS
class Egg {
float eggX, eggY; // X-coordinate, y-coordinate
float eggTilt; // Left and right angle offset
float eggAngle; // Used to define the tilt
float eggHeightScalar; // Height of the egg
color eggColor= color(255) ;
// Constructor
Egg(int xPos, int yPos, float t, float s, color eC) {
eggX = xPos;
eggY = yPos;
eggTilt = t;
eggColor = eC;
eggHeightScalar = s / 100.0;
}
void wobble() {
eggTilt = cos(eggAngle) / 8;
eggAngle += 0.1;
}
void display() {
noStroke();
fill(eggColor);
pushMatrix(); //
translate(eggX, eggY);
rotate(eggTilt);
scale(eggHeightScalar);
beginShape();
vertex(0, -100);
bezierVertex(25, -100, 40, -65, 40, -40);
bezierVertex(40, -15, 25, 0, 0, 0);
bezierVertex(-25, 0, -40, -15, -40, -40);
bezierVertex(-40, -65, -25, -100, 0, -100);
endShape();
popMatrix();
}
}
// Screen Instructions & Feedback Text
void screenInstructions() {
background(c[36]);
textAlign(CENTER, CENTER);
fill(0);
switch (switchPhaseMain) {
// INSTRUCTION PHASE = 1 & 2
case 1:
text("CHERNOFF FACES", width/2, height/4);
text("In this game consider faces.", width/2, height/4+lineSpace*2);
text("You will have to learn to accept good faces and reject bad
ones.", width/2, height/4+3*lineSpace);
text("Remember that faces are composed of geometrical figures",
width/2, height/4+lineSpace*4);
text("that are generated to visualize complex quantitative data.",
width/2, height/4+lineSpace*5);
text("How to play? Click "+btnIntructNextLabel+" button to read
more...", width/2, height/4+lineSpace*8);
break;
case 2:
text("HOW TO PLAY", width/2, height/4);
text("At the begining you will start with "+pointsTotal+" points.",
width/2, height/4+lineSpace*2);
text("For each correct assesment you will receive bonus points,",
width/2, height/4+3*lineSpace);
text("and for each wrong assesment you will lose the points.",
width/2, height/4+lineSpace*4);
text("You will have an opportunity to evaluate "+numberOfRounds+"
projects", width/2, height/4+lineSpace*5);
text("and receive feedback on your decisions & learning progress.",
width/2, height/4+lineSpace*6);
text("Click "+btnIntructStartLabel+" button to play!", width/2,
height/4+lineSpace*8);
break;
// INSTRUCTION END phase = 4 & 5
case 4:
for (int i =0; i<3; i++) {
pointsTotal=+points[i];
} //Move to setup or draw?
String msgEndThanks = "Thank you for completing the experiment!";
String msgPointsFinal = "In all sets you earned total of "
+pointsTotal+ " points";
String msgClickToStartOver = "Click to start over ";
text(msgEndThanks, width/2, height/4);
text(msgPointsFinal, width/2, height/4+lineSpace*2);
text(msgClickToStartOver, width/2, height/4+lineSpace*3);
break;
case 5:
text ("You are done!", width/2, height/4);
text("Thank you for participating in our experiment!", width/2,
height/4+lineSpace*2);
break;
// EXPERIMENT PHASE = 3
default:
break;
}
}
// introNextFaceRound switchExperimentState = 1
void introNextFaceRound (int chernoffRound) {
background(c[36]);
textAlign(CENTER, CENTER);
fill(0);
String msgEndSet1 = "In round " +round+" you " +msgDecision+" the "
+msgFaceFeedback+"!";
String msgEndSet2 = "and earned " +decisionValue+ " points.";
String msgEndSet3 = "In total, your earned " +points[chernoffRound]+"!";
String msgEndSet4 = "After " +trials[chernoffRound]+ " trial(s) you
have total of " +(numberOfRounds-trials[chernoffRound])+" left";
String msgEndSet5 = "Click "+btnNextFaceLabel+" button to continue
making choices. Next round is number " + (chernoffRound+1) + ".";
String msgEndSet6 = "Click "+btnFinishLabel+" button to finish.";
text(msgEndSet1, width/2, height/4+lineSpace*1);
text(msgEndSet2, width/2, height/4+lineSpace*2);
text(msgEndSet3, width/2, height/4+lineSpace*3);
text(msgEndSet4, width/2, height/4+lineSpace*4);
if (round>numberOfRounds) {
text(msgEndSet5, width/2, height/4+lineSpace*5);
}
if (round==numberOfRounds) {
text(msgEndSet6, width/2, height/4+lineSpace*5);
}
}
// SCORE TEXT
void showScore(int chernoffRound) {
textAlign(LEFT);
String msgScore1 = "The value of your past decision is: " +
decisionValue;
String msgScore2 = "Total points earned: " + points[chernoffRound];
String msgScore3 = "Trials remaining: " +
(numberOfRounds-trials[chernoffRound]);
//String msgScore4 = "Total of wrong answers: "; // to be done
//String msgScore5 = "Total of right answers: "; // to be done
String msgScore6 = "Please evaluate the following project and make
a decision:";
text(msgScore1, width/10, height/11 +lineSpace/2*1);
text(msgScore2, width/10, height/11+lineSpace/2*2);
text(msgScore3, width/10, height/11+lineSpace/2*3);
//text(msgScore4, width/10, height/11+lineSpace/2*4); //to finish later
//text(msgScore5, width/10, height/11+lineSpace/2*5); // to finish later
text(msgScore6, width/10, height/11+lineSpace/2*6);
}
// BUTTON: Update & Dispaly (Requires Button class)
void manageButtons() {
switch (switchPhaseMain) {
case 1:
btnInstructNext.update();
btnInstructNext.display();
break;
case 2:
btnInstructBack.update();
btnInstructBack.display();
btnInstructStart.update();
btnInstructStart.display();
break;
case 3:
switch (switchExperimentState) {
case 1: //stateFace = 1;
btnReject.update();
btnReject.display();
btnAccept.update();
btnAccept.display();
btnPause.update();
btnPause.display();
break;
case 2: // = 2;
btnNextFace.update();
btnNextFace.display();
btnPause.update();
btnPause.display();
break;
default:
break;
}
break;
case 4:
btnFinish.update();
btnFinish.display();
break;
default:
break;
}
}
// BUTTON: Mouse Release (Requires Button class)
void mouseReleased() {
btnBack.release();
btnReject.release();
btnAccept.release();
btnInstructNext.release();
btnNextFace.release();
btnInstructBack.release();
btnInstructStart.release();
btnFinish.release();
btnPause.release();
btnUnPause.release();
}
// BUTTON CLASS:
class Button {
int bx, by; // The x- and y-coordinates
int sizeX, sizeY; // Dimension (width and height)
color btnBaseColor; // Default gray value
color btnOverColor; // Value when mouse is over the button
color btnPressColor; // Value when mouse is over and pressed
color btnTextColor; /// button text color
boolean over = false; // True when the mouse is over
boolean pressed = false; // True when the mouse is over and pressed
String btnLabel;
//sizeX=textWidth(btnLabel); // Can be turned off
Button(String btnLabel, int bx, int by, int sizeX, int sizeY, color
btnBaseColor, color btnOverColor, color btnPressColor) {
this.btnLabel = btnLabel;
this.bx = bx;
this.by = by;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.btnBaseColor = btnBaseColor;
this.btnOverColor = btnOverColor;
this.btnPressColor = btnPressColor;
}
void update() {
if ((mouseX >= bx) && (mouseX <= bx+sizeX) &&
(mouseY >= by) && (mouseY <= by+sizeY)) {
over = true;
}
else {
over = false;
}
}
boolean press() {
if (over == true) {
pressed = true;
return true;
}
else {
return false;
}
}
void release() {
pressed = false;
}
void display() {
if (pressed == true) {
fill(btnPressColor);
}
else if (over == true) {
fill(btnOverColor);
}
else {
fill(btnBaseColor);
}
stroke(255);
strokeWeight(1);
rect(bx, by, sizeX, sizeY);
// rect(bx, by, textWidth(btnLabel), sizeY); flexible with of the button
fill(0);
textAlign(CENTER, CENTER);
text(btnLabel, bx+sizeX/2, by+sizeY/2);
}
}
My major concern are the loops, the "Next" (face) button (to restart the
loop). I have trouble in storing and recording the data, thus, I really
appreciate your comments regarding any of these issues.
The applet has the following sequence:
PHASE 1:
Instructions (page 1)
Instructions (page 2)
PHASE 2:
Start Guessing Game:
STAGE 1 (100 loops):
State 1:
Generate a vector of random numbers (e.g. 11 numbers
from 0 to 1).
Attach equal weights to each random number and
compute the mean value of these random numbers.
Draw geographical figures that use these numbers in a
special way that would resemble a face.
Ask user to "accept" or "reject" this face.
State 2:
Show decision feedback (score) to the user. The score
is computed as follows:
If mean value of random numbers is more X (e.g.0.5),
then it is a "good" face.
If mean value of random numbers is less that X
(e.g.0.5) then it is a "bad" face.
If user accepts a "good" face or rejects a "bad"
face, he made a good decision, and gains 1 point.
If user accepts a "bad" face or rejects a "good"
face, he made a poor decision, and loses 1 point.
STAGE 2(100 loops):
The weights should change assigning 0.9 and 0.1
weights to the first too values, and 0 weights to the
remaining values.
Repeat State 1 and State 2 for additional 100 rounds.
NOTE: Record the random values, weights, mean values, and
responses of the users for both rounds.
PHASE 3:
Finish the game by giving performance summary.
No comments:
Post a Comment