[virtualcommons-svn] commit/foraging: 2 new changesets
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-09-01 21:04:53
|
2 new changesets in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/633247996b34/ changeset: 633247996b34 user: alllee date: 2011-09-01 21:33:33 summary: adding basic quiz explanations affected #: 1 file (334 bytes) --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Thu Sep 01 11:54:48 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Thu Sep 01 12:33:33 2011 -0700 @@ -62,4 +62,15 @@ </form> ]]></entry> +<entry key='q1-explanation'> + <![CDATA[ + Tokens can only grow when there are other tokens around them. They cannot + spontaneously generate from the middle of the screen. + ]]> +</entry> +<entry key='q2-explanation'> + <![CDATA[ + There are no neighboring tokens next to the tokens that appeared in B. + ]]> +</entry></properties> http://bitbucket.org/virtualcommons/foraging/changeset/cf995a1552fb/ changeset: cf995a1552fb user: alllee date: 2011-09-01 23:05:21 summary: tightening up Swing repainting code, there is still some corruption happening on the instructions scroll pane in Linux, but am moving on to other parts of the code now. affected #: 8 files (1.5 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Thu Sep 01 14:05:21 2011 -0700 @@ -271,7 +271,11 @@ public void transmit(PostRoundSanctionRequest request) { if (state == ClientState.WAITING) { //System.out.println("Sending post round sanction request"); - gameWindow2D.switchInstructionsPane(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + gameWindow2D.switchInstructionsPane(); + } + }); super.transmit(request); } } --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Thu Sep 01 14:05:21 2011 -0700 @@ -211,8 +211,8 @@ } else { String currentInstructions = instructionsBuilder.toString(); - // remove submit button, this is expensive but ah well. - currentInstructions = currentInstructions.replaceAll("<input type=\"submit\".*>", ""); + // remove all inputs. + currentInstructions = currentInstructions.replaceAll("<input.*value=\"[\\w]+\">", ""); System.err.println("new instructions: " + currentInstructions); builder.append(currentInstructions); Collections.sort(incorrectAnswers); @@ -248,7 +248,6 @@ builder.append(correctString); setInstructions(builder.toString()); } - getPanel().repaint(); } }; } @@ -331,11 +330,10 @@ } private void setInstructions(String s) { + System.err.println("Setting instructions to " + s); instructionsEditorPane.setText(s); - instructionsEditorPane.setCaretPosition(0); -// instructionsScrollPane.repaint(); -// instructionsScrollPane.requestFocusInWindow(); -// repaint(); + instructionsEditorPane.repaint(); + getPanel().repaint(); } private HtmlEditorPane createInstructionsEditorPane() { @@ -343,6 +341,7 @@ // "Costly Sanctioning Experiment"); final HtmlEditorPane htmlPane = new HtmlEditorPane(); htmlPane.setEditable(false); + htmlPane.setDoubleBuffered(true); htmlPane.setBackground(Color.WHITE); htmlPane.setFont(new Font("sansserif", Font.PLAIN, 12)); return htmlPane; @@ -359,6 +358,7 @@ // add instructions panel card instructionsEditorPane = createInstructionsEditorPane(); instructionsScrollPane = new JScrollPane(instructionsEditorPane); + instructionsScrollPane.setDoubleBuffered(true); instructionsScrollPane.setName(INSTRUCTIONS_PANEL_NAME); add(instructionsScrollPane); @@ -418,6 +418,7 @@ Dimension screenSize = new Dimension(component.getWidth(), component.getHeight() - 50); subjectView.setScreenSize(screenSize); subjectView.setImageSizes(); + getPanel().revalidate(); showPanel(currentCardPanel); } }); @@ -712,17 +713,21 @@ } public void showInstructions() { - RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); + final RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); instructionsBuilder.delete(0, instructionsBuilder.length()); roundConfiguration.buildInstructions(instructionsBuilder); // and add the quiz instructions if the quiz is enabled. - if (roundConfiguration.isQuizEnabled()) { - instructionsEditorPane.setActionListener(null); - instructionsEditorPane.setActionListener(createQuizListener(roundConfiguration)); - } - - setInstructions(instructionsBuilder.toString()); - switchInstructionsPane(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (roundConfiguration.isQuizEnabled()) { + instructionsEditorPane.setActionListener(null); + instructionsEditorPane.setActionListener(createQuizListener(roundConfiguration)); + } + setInstructions(instructionsBuilder.toString()); + switchInstructionsPane(); + instructionsEditorPane.setCaretPosition(0); + } + }); } public void switchInstructionsPane() { showPanel(INSTRUCTIONS_PANEL_NAME); --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 01 14:05:21 2011 -0700 @@ -327,8 +327,6 @@ public double getQuizCorrectAnswerReward() { return getDoubleProperty("quiz-correct-answer-reward", 0.50d); } - - /** * Possible values, freeze, fine? @@ -561,25 +559,26 @@ } instructionsBuilder.append(getInstructions()); if (isFieldOfVisionEnabled()) { - instructionsBuilder.append(getFieldOfVisionInstructions()); + addSpecialInstructions(instructionsBuilder,getFieldOfVisionInstructions()); } if (isCensoredChat()) { - instructionsBuilder.append(getCensoredChatInstructions()); + addSpecialInstructions(instructionsBuilder,getCensoredChatInstructions()); } else if (isInRoundChatEnabled()) { - instructionsBuilder.append(getInRoundChatInstructions()); + addSpecialInstructions(instructionsBuilder,getInRoundChatInstructions()); } else if (isChatEnabled()) { // FIXME: hard-coded, need to make instructions template-able, perhaps // via FreeMarker or Velocity. - instructionsBuilder.append("Before the beginning of this round you will be able to chat with the other members of your group for ").append(getChatDuration()).append(" seconds."); + addSpecialInstructions(instructionsBuilder, + "Before the beginning of this round you will be able to chat with the other members of your group for " + getChatDuration() + " seconds."); } String resourceGeneratorType = getResourceGeneratorType(); if (resourceGeneratorType.equals("mobile")) { - instructionsBuilder.append(getMobileResourceInstructions()); + addSpecialInstructions(instructionsBuilder,getMobileResourceInstructions()); } else if (resourceGeneratorType.equals("top-bottom-patchy")) { - instructionsBuilder.append(getPatchyResourceInstructions()); + addSpecialInstructions(instructionsBuilder,getPatchyResourceInstructions()); } // and add the quiz instructions if the quiz is enabled. @@ -589,6 +588,10 @@ return instructionsBuilder; } + private void addSpecialInstructions(StringBuilder builder, String instructions) { + builder.append("<p>").append(instructions).append("</p>"); + } + private String getMobileResourceInstructions() { return getProperty("mobile-resource-instructions", "<p>The resource can move around in a semblance of free will / agency.</p>"); } --- a/src/main/java/edu/asu/commons/foraging/event/QuizResponseEvent.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/QuizResponseEvent.java Thu Sep 01 14:05:21 2011 -0700 @@ -12,7 +12,7 @@ * * A client's quiz responses for a given quiz page. * - * + * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev: 522 $ */ @@ -42,4 +42,15 @@ public String toString() { return String.format("%s, responses: %s, incorrect answers: %s", id, responses, incorrectAnswers); } + + public int getNumberOfCorrectAnswers() { + int correctAnswers = responses.size() - incorrectAnswers.size(); + if (correctAnswers < 0) { + // FIXME: replace with proper logging? + System.err.println("Somehow the number of responses was less than the number of incorrect answers: " + + responses + " -- " + incorrectAnswers); + return 0; + } + return correctAnswers; + } } --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Thu Sep 01 14:05:21 2011 -0700 @@ -69,7 +69,8 @@ private ArrayList<String> trustGameLog = new ArrayList<String>(); - private double trustGameEarnings = 0.0d; + private double trustGameEarnings = 0.0d; + private int correctQuizAnswers = 0; public void setTrustGamePlayerOneAmountToKeep(double trustGamePlayerOneAmountToKeep) { this.trustGamePlayerOneAmountToKeep = trustGamePlayerOneAmountToKeep; @@ -595,4 +596,13 @@ public List<String> getTrustGameLog() { return trustGameLog; } + + public int getCorrectQuizAnswers() { + return correctQuizAnswers; + } + + public void addCorrectQuizAnswers(int numberOfCorrectAnswers) { + correctQuizAnswers += numberOfCorrectAnswers; + } + } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 01 14:05:21 2011 -0700 @@ -299,14 +299,16 @@ addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { public void handle(final QuizResponseEvent event) { numberOfSubmittedQuizzes++; + transmit(new QuizCompletedEvent(facilitatorId)); + ClientData clientData = clients.get(event.getId()); + clientData.addCorrectQuizAnswers(event.getNumberOfCorrectAnswers()); if (numberOfSubmittedQuizzes >= clients.size()) { // we're done, notify the sleeping queue. logger.info("Received all quizzes, notifying quiz signal"); Utils.notify(quizSignal); numberOfSubmittedQuizzes = 0; } - // FIXME: pass in the id of the client completing the quiz? - transmit(new QuizCompletedEvent(facilitatorId)); + } }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionRequest>(PostRoundSanctionRequest.class) { --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Thu Sep 01 14:05:21 2011 -0700 @@ -43,34 +43,31 @@ Before we begin the practice round please answer the following questions. </p><form> -<fieldset> -<span class='q1'>Q1. Which of the statements is <b><u>incorrect</u></b>?</span><br> -<input type="radio" name="q1" value="A"/>A. Your decisions of where to collect tokens affects the regeneration of tokens.<br> -<input type="radio" name="q1" value="B"/>B. When you have collected all tokens on the screen, no new tokens will appear.<br> -<input type="radio" name="q1" value="C"/>C. Tokens grow from the middle of the screen.<br> -<input type="radio" name="q1" value="D"/>D. In order to collect a token you need to press the space bar while your yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"> is on a cell with a token.<br> -</fieldset> - -<fieldset> -<span class='q2'>Q2. Which sequence of situations is <b><u>not possible</u></b>?</span><br> -<img src="@CODEBASE_URL@/images/question2.jpg"><br> +<span class='q1'>Q1. Which one of the following statements is incorrect?</span><br> +<input type="radio" name="q1" value="A">A. Your decisions of where to collect tokens affects the regeneration of tokens.<br> +<input type="radio" name="q1" value="B">B. When you have collected all tokens on the screen, no new tokens will appear.<br> +<input type="radio" name="q1" value="C">C. Tokens grow from the middle of the screen.<br> +<input type="radio" name="q1" value="D">D. In order to collect a token you need to press the space bar while your yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"></img> is on a cell with a token.<br> +<br><br> +<span class='q2'>Q2. Which sequence of situations is not possible?</span><br> +<img src="@CODEBASE_URL@/images/question2.jpg"></img><br><input type="radio" name="q2" value="A">A<br><input type="radio" name="q2" value="B">B<br><input type="radio" name="q2" value="C">C<br> -</fieldset> -<input type="submit" name="submit" value="Submit"> +<input type="submit" name="submit" value="Submit"><br></form> ]]></entry><entry key='q1-explanation'><![CDATA[ - Tokens can only grow when there are other tokens around them. They cannot - spontaneously generate from the middle of the screen. + Tokens only regenerate when there are other tokens present in their immediately + neighboring cells. They do not spontaneously generate from the middle of the + screen. ]]></entry><entry key='q2-explanation'><![CDATA[ - There are no neighboring tokens next to the tokens that appeared in B. + Tokens cannot regenerate on an empty screen as shown in sequence B. ]]></entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Thu Sep 01 12:33:33 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Thu Sep 01 14:05:21 2011 -0700 @@ -56,11 +56,11 @@ six rounds of the experiment. </p><p> -You will appear on the screen as a yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif">. + You will appear on the screen as a yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"></img>. You can move by pressing the four arrow keys on your keyboard. You can move up, down, left, or right. You have to press a key for each and every move of your yellow dot. In this experiment you can collect green diamond shaped tokens -<img src="@CODEBASE_URL@/images/gem-token.gif"> and earn two cents for each collected token. +<img src="@CODEBASE_URL@/images/gem-token.gif"></img> and earn two cents for each collected token. To collect a token, move your yellow dot over a green token and <b>press the space bar</b>. Simply moving your avatar over a token does NOT collect that token. </p> @@ -75,6 +75,7 @@ The middle cell in Image 1 denoted with an X has a greater chance of regeneration than the middle cell in Image 2. When all neighboring cells are empty, there is <b>no chance for regeneration</b>. +</p><table width="100%"><tr> @@ -83,13 +84,14 @@ </tr><tr><td align="center"> -<img src="@CODEBASE_URL@/images/8neighbors.jpg" alt="image 1"> + <img src="@CODEBASE_URL@/images/8neighbors.jpg" alt="image 1"></img></td><td align="center"> -<img src="@CODEBASE_URL@/images/5neighbors.jpg" alt="image 2"> + <img src="@CODEBASE_URL@/images/5neighbors.jpg" alt="image 2"></img></td></tr></table> + <h3>Best Strategy</h3><p> The chance that a token will regenerate on an empty cell increases as there are @@ -98,7 +100,8 @@ regrowth. The optimal spatial pattern of tokens on the screen is the checkerboard diagram shown below, where half of the cells are empty and arranged in a way that maximizes regrowth. -<img src="@CODEBASE_URL@/images/optimal-strategy.jpg" alt="Checkerboard Resource"> +<br> +<img src="@CODEBASE_URL@/images/optimal-strategy.jpg" alt="Checkerboard Resource"></img></p> ]]></entry> @@ -116,25 +119,25 @@ </p><h3>Game Mechanics</h3> +<p> The game works as follows: +</p><ol><li>Player 1 first receives an endowment of one dollar and has to decide <b>how much to keep</b> and <b>how much to send to Player 2</b>. <li>The amount Player 1 decides to send to Player 2 is tripled by the system and then given to Player 2. Player 2 then has to decide <b>how much to keep</b> and <b>how much to send back to Player 1</b>. </ol> - +<p> For example, if Player 1 sends 0 cents to Player 2, Player 1 earns 1 dollar and Player 2 earns 0 cents. However, if Player 1 sends 1 dollar to Player 2, 3 dollars would be sent to Player 2. Player 2 then decides to return $1.75 back to Player 1. In this case, Player 1 earns $1.75, and Player 2 earns $1.25. - -<p> - To design your strategies, please fill in the following form by selecting the - <b>Amount to Keep</b> column. </p><p> - <b>Are there any questions?</b> +Please fill in the following form to design your strategies as Player 1 or Player 2. +<br> +<b>If you have any questions, please raise your hand. Are there any questions?</b></p> ]]></entry> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |