virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 26)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bitbucket <com...@bi...> - 2011-10-02 04:49:17
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/584573eb2f5b/ changeset: 584573eb2f5b user: alllee date: 2011-10-02 06:49:06 summary: adding candidate set to event so clients can know which rules participated in a tiebreaker if there was one. affected #: 3 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/event/RuleSelectedUpdateEvent.java Sat Oct 01 21:44:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/RuleSelectedUpdateEvent.java Sat Oct 01 21:49:06 2011 -0700 @@ -1,6 +1,8 @@ package edu.asu.commons.foraging.event; +import java.util.List; + import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.foraging.rules.ForagingRule; import edu.asu.commons.net.Identifier; @@ -18,21 +20,27 @@ public class RuleSelectedUpdateEvent extends AbstractPersistableEvent { private static final long serialVersionUID = 4360213814026474451L; - private ForagingRule rule; + private final ForagingRule selectedRule; + private final List<ForagingRule> candidates; - public RuleSelectedUpdateEvent(Identifier id, ForagingRule rule) { + public RuleSelectedUpdateEvent(Identifier id, ForagingRule rule, List<ForagingRule> candidates) { super(id, rule.toString()); - this.rule = rule; + this.selectedRule = rule; + this.candidates = candidates; } - public ForagingRule getRule() { - return rule; + public ForagingRule getSelectedRule() { + return selectedRule; } @Override public String toString() { - return rule.toString(); + return selectedRule.toString(); } + public List<ForagingRule> getCandidates() { + return candidates; + } + } --- a/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Sat Oct 01 21:44:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Sat Oct 01 21:49:06 2011 -0700 @@ -68,9 +68,7 @@ private EnforcementMechanism activeEnforcementMechanism = EnforcementMechanism.NONE; private SanctionMechanism activeSanctionMechanism = SanctionMechanism.NONE; private RegulationData activeRegulation; - - private Map<ForagingRule, Integer> ruleTallyMap = new HashMap<ForagingRule, Integer>(); - + private List<ClientData> waitingMonitors; private ClientData activeMonitor; @@ -79,6 +77,8 @@ private ArrayList<RegulationData> submittedRegulations = new ArrayList<RegulationData>(); + private ForagingRule selectedRule; + public GroupDataModel(ServerDataModel serverDataModel) { this(serverDataModel, nextGroupId++); } @@ -771,7 +771,7 @@ return serverDataModel.getEventChannel(); } - public ForagingRule generateSelectedRule() { + public List<ForagingRule> generateSelectedRule() { Map<ForagingRule, Integer> tallyMap = new HashMap<ForagingRule, Integer>(); for (ClientData client: clients.values()) { ForagingRule rule = client.getVotedRule(); @@ -802,8 +802,12 @@ // getLogger().info("tally map is: " + tallyMap); getLogger().info("picking first rule from " + selectedRules); Collections.shuffle(selectedRules); - return selectedRules.get(0); - + selectedRule = selectedRules.get(0); + return selectedRules; + } + + public ForagingRule getSelectedRule() { + return selectedRule; } } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Sat Oct 01 21:44:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Sat Oct 01 21:49:06 2011 -0700 @@ -385,10 +385,11 @@ if (votesReceived >= clients.size()) { // calculate votes for (GroupDataModel group: serverDataModel.getGroups()) { - ForagingRule selectedRule = group.generateSelectedRule(); + List<ForagingRule> candidates = group.generateSelectedRule(); + ForagingRule selectedRule = group.getSelectedRule(); for (Identifier id: group.getClientIdentifiers()) { - sendFacilitatorMessage("Group " + group + " selected " + selectedRule); - transmit(new RuleSelectedUpdateEvent(id, selectedRule)); + sendFacilitatorMessage("Group " + group + " selected " + selectedRule + " from candidate set: " + candidates); + transmit(new RuleSelectedUpdateEvent(id, selectedRule, candidates)); } } 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. |
From: Bitbucket <com...@bi...> - 2011-10-02 04:44:49
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/f04d1ff461c3/ changeset: f04d1ff461c3 user: alllee date: 2011-10-02 06:44:39 summary: adding rule selection logic to GroupDataModel and ForagingServer affected #: 8 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/event/VoteRuleRequest.java Sat Oct 01 02:12:11 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -package edu.asu.commons.foraging.event; - - -import edu.asu.commons.event.AbstractPersistableEvent; -import edu.asu.commons.foraging.rules.ForagingRule; -import edu.asu.commons.net.Identifier; - -/** - * $Id: EnforcementRankingRequest.java 522 2010-06-30 19:17:48Z alllee $ - * - * Sent from a client to the server signaling that the client - * has updated the votes to the given options - * - * @author <a href='all...@as...'>Allen Lee</a> - * @version $Revision: 522 $ - */ - -public class VoteRuleRequest extends AbstractPersistableEvent { - - private static final long serialVersionUID = 4360213814026474451L; - private ForagingRule rule; - - public VoteRuleRequest(Identifier id, ForagingRule rule) { - super(id, rule.toString()); - this.rule = rule; - } - - public ForagingRule getRule() { - return rule; - } - - @Override - public String toString() { - return String.format("%s voted for rule [%s]", id, rule); - } - - -} --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Sat Oct 01 02:12:11 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Sat Oct 01 21:44:39 2011 -0700 @@ -13,6 +13,7 @@ import edu.asu.commons.foraging.conf.RoundConfiguration.SanctionAction; import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.graphics.Point3D; +import edu.asu.commons.foraging.rules.ForagingRule; import edu.asu.commons.foraging.ui.Circle; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Duration; @@ -67,6 +68,7 @@ private double trustGamePlayerOneAmountToKeep; private double[] trustGamePlayerTwoAmountsToKeep; + private ForagingRule votedRule; private ArrayList<String> trustGameLog = new ArrayList<String>(); private double trustGameEarnings = 0.0d; @@ -604,5 +606,13 @@ public void addCorrectQuizAnswers(int numberOfCorrectAnswers) { correctQuizAnswers += numberOfCorrectAnswers; } + + public ForagingRule getVotedRule() { + return votedRule; + } + + public void setVotedRule(ForagingRule votedRule) { + this.votedRule = votedRule; + } } --- a/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Sat Oct 01 02:12:11 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Sat Oct 01 21:44:39 2011 -0700 @@ -771,4 +771,39 @@ return serverDataModel.getEventChannel(); } + public ForagingRule generateSelectedRule() { + Map<ForagingRule, Integer> tallyMap = new HashMap<ForagingRule, Integer>(); + for (ClientData client: clients.values()) { + ForagingRule rule = client.getVotedRule(); + Integer count = tallyMap.get(rule); + if (count == null) { + count = 0; + } + tallyMap.put(rule, count + 1); + } + ArrayList<ForagingRule> selectedRules = new ArrayList<ForagingRule>(); + Integer maxSeenValue = 0; + for (Map.Entry<ForagingRule, Integer> entry : tallyMap.entrySet()) { + Integer currentValue = entry.getValue(); +// getLogger().info("rule : " + entry.getKey() + " has a vote value of " + currentValue); + + + if (currentValue > maxSeenValue) { + maxSeenValue = currentValue; +// getLogger().info("That was better than " + maxSeenValue + " - clearing out the old rule set and adding this one."); + selectedRules.clear(); + selectedRules.add(entry.getKey()); + } + else if (currentValue == maxSeenValue) { +// getLogger().info("that was the same as " + maxSeenValue + " - adding this one." + selectedRules); + selectedRules.add(entry.getKey()); + } + } +// getLogger().info("tally map is: " + tallyMap); + getLogger().info("picking first rule from " + selectedRules); + Collections.shuffle(selectedRules); + return selectedRules.get(0); + + } + } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Sat Oct 01 02:12:11 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Sat Oct 01 21:44:39 2011 -0700 @@ -55,6 +55,8 @@ import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; +import edu.asu.commons.foraging.event.RuleSelectedUpdateEvent; +import edu.asu.commons.foraging.event.RuleVoteRequest; import edu.asu.commons.foraging.event.SanctionAppliedEvent; import edu.asu.commons.foraging.event.ShowRequest; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; @@ -62,7 +64,6 @@ import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; import edu.asu.commons.foraging.event.UnlockResourceRequest; -import edu.asu.commons.foraging.event.VoteRuleRequest; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; import edu.asu.commons.foraging.model.EnforcementMechanism; @@ -70,6 +71,7 @@ import edu.asu.commons.foraging.model.ResourceDispenser; import edu.asu.commons.foraging.model.SanctionMechanism; import edu.asu.commons.foraging.model.ServerDataModel; +import edu.asu.commons.foraging.rules.ForagingRule; import edu.asu.commons.foraging.ui.Circle; import edu.asu.commons.net.Dispatcher; import edu.asu.commons.net.Identifier; @@ -372,11 +374,27 @@ resourceDispenser.resetTokenDistribution(event); } }); - addEventProcessor(new EventTypeProcessor<VoteRuleRequest>(VoteRuleRequest.class) { + addEventProcessor(new EventTypeProcessor<RuleVoteRequest>(RuleVoteRequest.class) { + int votesReceived = 0; @Override - public void handle(VoteRuleRequest request) { - - + public void handle(RuleVoteRequest request) { + sendFacilitatorMessage("Received vote rule request: " + request); + ClientData client = clients.get(request.getId()); + client.setVotedRule(request.getRule()); + votesReceived++; + if (votesReceived >= clients.size()) { + // calculate votes + for (GroupDataModel group: serverDataModel.getGroups()) { + ForagingRule selectedRule = group.generateSelectedRule(); + for (Identifier id: group.getClientIdentifiers()) { + sendFacilitatorMessage("Group " + group + " selected " + selectedRule); + transmit(new RuleSelectedUpdateEvent(id, selectedRule)); + } + + } + } + + } }); addEventProcessor(new EventTypeProcessor<RealTimeSanctionRequest>(RealTimeSanctionRequest.class) { --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Sat Oct 01 02:12:11 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Sat Oct 01 21:44:39 2011 -0700 @@ -25,7 +25,7 @@ import javax.swing.JRadioButton; import edu.asu.commons.foraging.client.ForagingClient; -import edu.asu.commons.foraging.event.VoteRuleRequest; +import edu.asu.commons.foraging.event.RuleVoteRequest; import edu.asu.commons.foraging.rules.ForagingRule; /** @@ -102,7 +102,7 @@ return; } ForagingRule selectedRule = ForagingRule.valueOf(model.getActionCommand()); - client.transmit(new VoteRuleRequest(client.getId(), selectedRule)); + client.transmit(new RuleVoteRequest(client.getId(), selectedRule)); } }); return submitButton; 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 09:12:19
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/176c12f683d5/ changeset: 176c12f683d5 user: alllee date: 2011-10-01 11:12:11 summary: && appears to be working to daisy chain the mvn and ant commands. buildr is looking more attractive by the minute, though comes with its own dependency issues, namely installing ruby on windows, etc. affected #: 1 file (-1 bytes) --- a/deploy.bat Sat Oct 01 01:40:33 2011 -0700 +++ b/deploy.bat Sat Oct 01 02:12:11 2011 -0700 @@ -1,9 +1,10 @@ -REM set ANT_HOME to the location where you unpacked Ant. Inside this -REM directory should be bin and lib directories containing the Ant -REM executables and library dependencies. -REM set JAVA_HOME to the location of the installed JDK (customize as necessary) +::REM set ANT_HOME to the location where you unpacked Ant. Inside this +::REM directory should be bin and lib directories containing the Ant +::REM executables and library dependencies. +::REM set JAVA_HOME to the location of the installed JDK (customize as necessary) +REM This script will not work unless you make sure that ANT_HOME, M2_HOME, and JAVA_HOME are pointing at the correct location. set ANT_HOME=C:\tools\ant set M2_HOME=C:\tools\maven set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 set PATH=%M2_HOME%\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% -mvn clean compile & ant clean deploy server +mvn clean compile && ant clean deploy server 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 08:40:41
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/7bc37e950dcd/ changeset: 7bc37e950dcd user: alllee date: 2011-10-01 10:40:33 summary: ugh, dos affected #: 1 file (-1 bytes) --- a/deploy.bat Sat Oct 01 01:36:15 2011 -0700 +++ b/deploy.bat Sat Oct 01 01:40:33 2011 -0700 @@ -6,5 +6,4 @@ set M2_HOME=C:\tools\maven set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 set PATH=%M2_HOME%\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% -mvn clean compile -ant clean deploy server +mvn clean compile & ant clean deploy server 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 08:36:22
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/cc9462716257/ changeset: cc9462716257 user: alllee date: 2011-10-01 10:36:15 summary: cleaning up rule selection logic in the UI based on the enum. affected #: 4 files (-1 bytes) --- a/deploy.bat Fri Sep 30 23:03:42 2011 -0700 +++ b/deploy.bat Sat Oct 01 01:36:15 2011 -0700 @@ -3,6 +3,8 @@ REM executables and library dependencies. REM set JAVA_HOME to the location of the installed JDK (customize as necessary) set ANT_HOME=C:\tools\ant +set M2_HOME=C:\tools\maven set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 -set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% +set PATH=%M2_HOME%\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% +mvn clean compile ant clean deploy server --- a/ivysettings.xml Fri Sep 30 23:03:42 2011 -0700 +++ b/ivysettings.xml Sat Oct 01 01:36:15 2011 -0700 @@ -6,7 +6,7 @@ <settings defaultResolver="chain-resolver" /><property name='local-m2-pattern' value='${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]'/><resolvers> - <chain name='chain-resolver' returnFirst='true'> + <chain name='chain-resolver'><filesystem name='m2' m2compatible='true'><ivy pattern='${local-m2-pattern}.pom' /><artifact pattern='${local-m2-pattern}.[ext]'/> --- a/src/main/java/edu/asu/commons/foraging/event/VoteRuleRequest.java Fri Sep 30 23:03:42 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/VoteRuleRequest.java Sat Oct 01 01:36:15 2011 -0700 @@ -18,26 +18,20 @@ public class VoteRuleRequest extends AbstractPersistableEvent { private static final long serialVersionUID = 4360213814026474451L; - private int index; private ForagingRule rule; - public VoteRuleRequest(Identifier id, int index, ForagingRule rule) { + public VoteRuleRequest(Identifier id, ForagingRule rule) { super(id, rule.toString()); - this.index = index; this.rule = rule; } - public int getIndex() { - return index; - } - public ForagingRule getRule() { return rule; } @Override public String toString() { - return String.format("%s voted for rule # %s (%s)", id, index, rule); + return String.format("%s voted for rule [%s]", id, rule); } --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 23:03:42 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Sat Oct 01 01:36:15 2011 -0700 @@ -13,7 +13,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import javax.swing.ButtonModel; @@ -76,7 +75,7 @@ for (ForagingRule rule: rules) { JRadioButton radioButton = new JRadioButton(); - radioButton.setActionCommand(String.valueOf(radioButtons.size())); + radioButton.setActionCommand(rule.name()); radioButtons.add(radioButton); horizontalButtonParallelGroup.addComponent(radioButton); JLabel ruleLabel = new JLabel(String.format("%d. %s", radioButtons.size(), rule)); @@ -102,9 +101,8 @@ JOptionPane.showMessageDialog(VotingForm.this, "Please select a rule."); return; } - String selectedRule = model.getActionCommand(); - int selectedRuleIndex = Integer.parseInt(selectedRule); - client.transmit(new VoteRuleRequest(client.getId(), selectedRuleIndex, ForagingRule.values()[selectedRuleIndex])); + ForagingRule selectedRule = ForagingRule.valueOf(model.getActionCommand()); + client.transmit(new VoteRuleRequest(client.getId(), selectedRule)); } }); return submitButton; 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 06:03:51
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/c429ae49e6c9/ changeset: c429ae49e6c9 user: alllee date: 2011-10-01 08:03:42 summary: updating jdk to 1.6.0_26 affected #: 1 file (-1 bytes) --- a/jetty.bat Fri Sep 30 23:01:06 2011 -0700 +++ b/jetty.bat Fri Sep 30 23:03:42 2011 -0700 @@ -6,6 +6,6 @@ REM configure this application. set ANT_HOME=C:\tools\ant set M2_HOME=C:\tools\maven -set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_10 +set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%M2_HOME%\bin;%PATH% mvn jetty:run 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 06:01:16
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/c9dd198794c3/ changeset: c9dd198794c3 user: alllee date: 2011-10-01 08:01:06 summary: having deploy.bat start the server as well. affected #: 1 file (-1 bytes) --- a/deploy.bat Fri Sep 30 22:59:16 2011 -0700 +++ b/deploy.bat Fri Sep 30 23:01:06 2011 -0700 @@ -1,7 +1,8 @@ REM set ANT_HOME to the location where you unpacked Ant. Inside this REM directory should be bin and lib directories containing the Ant REM executables and library dependencies. +REM set JAVA_HOME to the location of the installed JDK (customize as necessary) set ANT_HOME=C:\tools\ant set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% -ant clean deploy +ant clean deploy server 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. |
From: Bitbucket <com...@bi...> - 2011-10-01 05:59:27
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/2198aca323ac/ changeset: 2198aca323ac user: alllee date: 2011-10-01 07:59:16 summary: turning rules into an enum to make it a bit more manageable to work with. Could split into specialized subpackages if it turns out that they are too treatment/experiment specific. affected #: 8 files (-1 bytes) --- a/deploy.bat Fri Sep 30 06:26:15 2011 -0700 +++ b/deploy.bat Fri Sep 30 22:59:16 2011 -0700 @@ -4,4 +4,4 @@ set ANT_HOME=C:\tools\ant set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_26 set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% -ant deploy +ant clean deploy --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Fri Sep 30 06:26:15 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Fri Sep 30 22:59:16 2011 -0700 @@ -14,6 +14,7 @@ import edu.asu.commons.foraging.graphics.Point3D; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.EnforcementMechanism; +import edu.asu.commons.foraging.rules.ForagingRule; import edu.asu.commons.net.Identifier; @@ -49,14 +50,7 @@ private static final double DEFAULT_TOKEN_BIRTH_PROBABILITY = 0.01d; - private final static List<String> FIXED_RULES = Arrays.asList( - "Wait 2 minutes for the screen to fill up with green tokens. Then everyone collect tokens for the remaining amount of time.", - "Each person gets a set area within which they can do whatever they want with the green tokens. With four people, each person gets one of the four corners.", - "Each person collects green tokens at a certain rate: 1 token every 3 seconds (i.e., count to 3 between each token you collect).", - "When someone collects from a cluster of green tokens (i.e., 3 or more tokens that are touching each other) that person leaves at least 2 tokens touching each other.", - "Collect green tokens until only about 10 are left; at that point, everyone must wait at least 1 minute before collecting any more tokens.", - "No rule (Everyone can do whatever they want)." - ); + public double getTrustGamePayoffIncrement() { return getDoubleProperty("trust-game-payoff", 0.25d); @@ -534,9 +528,9 @@ public String getInitialVotingInstructions() { return getProperty("initial-voting-instructions", "<h1>Notice</h1><hr><p>You will be given the ability to vote for rules in the next screen.</p>"); } - - public List<String> getFixedRules() { - return FIXED_RULES; + + public List<ForagingRule> getForagingRules() { + return Arrays.asList(ForagingRule.values()); } public boolean isVotingAndRegulationEnabled() { --- a/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Fri Sep 30 06:26:15 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Fri Sep 30 22:59:16 2011 -0700 @@ -25,6 +25,7 @@ import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TokenCollectedEvent; import edu.asu.commons.foraging.event.UnlockResourceRequest; +import edu.asu.commons.foraging.rules.ForagingRule; import edu.asu.commons.foraging.ui.Circle; import edu.asu.commons.net.Identifier; @@ -68,6 +69,8 @@ private SanctionMechanism activeSanctionMechanism = SanctionMechanism.NONE; private RegulationData activeRegulation; + private Map<ForagingRule, Integer> ruleTallyMap = new HashMap<ForagingRule, Integer>(); + private List<ClientData> waitingMonitors; private ClientData activeMonitor; --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 06:26:15 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 22:59:16 2011 -0700 @@ -56,14 +56,13 @@ import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.SanctionAppliedEvent; -import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowRequest; -import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; import edu.asu.commons.foraging.event.UnlockResourceRequest; +import edu.asu.commons.foraging.event.VoteRuleRequest; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; import edu.asu.commons.foraging.model.EnforcementMechanism; @@ -364,6 +363,7 @@ addEventProcessor(new EventTypeProcessor<CollectTokenRequest>(CollectTokenRequest.class) { public void handle(CollectTokenRequest event) { ClientData clientData = clients.get(event.getId()); + // FIXME: change this to collect the token immediately clientData.setCollecting(); } }); @@ -372,6 +372,13 @@ resourceDispenser.resetTokenDistribution(event); } }); + addEventProcessor(new EventTypeProcessor<VoteRuleRequest>(VoteRuleRequest.class) { + @Override + public void handle(VoteRuleRequest request) { + + + } + }); addEventProcessor(new EventTypeProcessor<RealTimeSanctionRequest>(RealTimeSanctionRequest.class) { @Override public void handleInExperimentThread(final RealTimeSanctionRequest request) { --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 06:26:15 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 22:59:16 2011 -0700 @@ -779,12 +779,13 @@ JScrollPane scrollPane = new JScrollPane(instructionsEditorPane); instructionsEditorPane.setText(client.getCurrentRoundConfiguration().getVotingInstructions()); votingPanel.add(scrollPane); - VotingForm votingForm = new VotingForm(dataModel.getRoundConfiguration().getFixedRules()); + VotingForm votingForm = new VotingForm(client); votingPanel.add(votingForm); votingPanel.setName(VotingForm.NAME); } return votingPanel; } + public void showVoteScreen() { add(getVotingPanel()); showPanel(VotingForm.NAME); --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 06:26:15 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 22:59:16 2011 -0700 @@ -27,6 +27,7 @@ import edu.asu.commons.foraging.client.ForagingClient; import edu.asu.commons.foraging.event.VoteRuleRequest; +import edu.asu.commons.foraging.rules.ForagingRule; /** * @@ -34,31 +35,23 @@ */ public class VotingForm extends javax.swing.JPanel { + private static final long serialVersionUID = 3871660663519284024L; + public final static String NAME = "Voting form"; private ForagingClient client; private List<JRadioButton> radioButtons = new ArrayList<JRadioButton>(); private List<JLabel> labels = new ArrayList<JLabel>(); - private List<String> rules = new ArrayList<String>(); - /** Creates new form VotingForm */ - public VotingForm() { - this(Arrays.asList("Rule 1", "Rule 2", "Rule 3", "Rule 4")); - } - + public VotingForm(ForagingClient client) { - this(client.getCurrentRoundConfiguration().getFixedRules()); this.client = client; - } - - public VotingForm(List<String> rules) { initComponents(); - this.rules.addAll(rules); - initForm(rules); + initForm(ForagingRule.values()); setName(NAME); } - private void initForm(List<String> rules) { + private void initForm(ForagingRule... rules) { GroupLayout groupLayout = new GroupLayout(this); setLayout(groupLayout); groupLayout.setAutoCreateGaps(true); @@ -81,7 +74,7 @@ verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleHeaderLabel).addGap(10).addComponent(buttonHeaderLabel)); - for (String rule: rules) { + for (ForagingRule rule: rules) { JRadioButton radioButton = new JRadioButton(); radioButton.setActionCommand(String.valueOf(radioButtons.size())); radioButtons.add(radioButton); @@ -111,7 +104,7 @@ } String selectedRule = model.getActionCommand(); int selectedRuleIndex = Integer.parseInt(selectedRule); - client.transmit(new VoteRuleRequest(client.getId(), selectedRuleIndex, rules.get(selectedRuleIndex))); + client.transmit(new VoteRuleRequest(client.getId(), selectedRuleIndex, ForagingRule.values()[selectedRuleIndex])); } }); return submitButton; @@ -133,7 +126,7 @@ public static void main(String[] args) { JFrame frame = new JFrame(); - frame.add(new VotingForm()); + frame.add(new VotingForm(null)); frame.pack(); frame.setVisible(true); 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 13:26:24
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/010ac82f26a5/ changeset: 010ac82f26a5 user: alllee date: 2011-09-30 15:26:15 summary: integrating client so we can transmit messages out affected #: 1 file (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 06:03:29 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 06:26:15 2011 -0700 @@ -10,16 +10,23 @@ */ package edu.asu.commons.foraging.ui; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.swing.ButtonModel; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; +import javax.swing.JButton; +import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JRadioButton; -import edu.asu.commons.foraging.conf.RoundConfiguration; +import edu.asu.commons.foraging.client.ForagingClient; +import edu.asu.commons.foraging.event.VoteRuleRequest; /** * @@ -29,16 +36,24 @@ public final static String NAME = "Voting form"; - private RoundConfiguration roundConfiguration; + private ForagingClient client; + private List<JRadioButton> radioButtons = new ArrayList<JRadioButton>(); private List<JLabel> labels = new ArrayList<JLabel>(); + private List<String> rules = new ArrayList<String>(); /** Creates new form VotingForm */ public VotingForm() { this(Arrays.asList("Rule 1", "Rule 2", "Rule 3", "Rule 4")); } + + public VotingForm(ForagingClient client) { + this(client.getCurrentRoundConfiguration().getFixedRules()); + this.client = client; + } public VotingForm(List<String> rules) { initComponents(); + this.rules.addAll(rules); initForm(rules); setName(NAME); } @@ -64,9 +79,8 @@ ruleHeaderLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); horizontalLabelParallelGroup.addComponent(ruleHeaderLabel); - verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleHeaderLabel).addComponent(buttonHeaderLabel)); + verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleHeaderLabel).addGap(10).addComponent(buttonHeaderLabel)); - for (String rule: rules) { JRadioButton radioButton = new JRadioButton(); radioButton.setActionCommand(String.valueOf(radioButtons.size())); @@ -79,9 +93,30 @@ horizontalLabelParallelGroup.addComponent(ruleLabel); verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleLabel).addComponent(radioButton)); } + JButton submitButton = getSubmitButton(); + horizontalLabelParallelGroup.addComponent(submitButton); + verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(submitButton).addGap(80)); groupLayout.setHorizontalGroup(horizontalGroup); groupLayout.setVerticalGroup(verticalGroup); } + + private JButton getSubmitButton() { + JButton submitButton = new JButton("Submit"); + submitButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ButtonModel model = buttonGroup.getSelection(); + if (model == null) { + JOptionPane.showMessageDialog(VotingForm.this, "Please select a rule."); + return; + } + String selectedRule = model.getActionCommand(); + int selectedRuleIndex = Integer.parseInt(selectedRule); + client.transmit(new VoteRuleRequest(client.getId(), selectedRuleIndex, rules.get(selectedRuleIndex))); + } + }); + return submitButton; + + } /** This method is called from within the constructor to * initialize the form. @@ -91,21 +126,16 @@ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { + buttonGroup = new javax.swing.ButtonGroup(); + }// </editor-fold>//GEN-END:initComponents - buttonGroup = new javax.swing.ButtonGroup(); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 790, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 469, Short.MAX_VALUE) - ); - }// </editor-fold>//GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup; - // End of variables declaration//GEN-END:variables + + public static void main(String[] args) { + JFrame frame = new JFrame(); + frame.add(new VotingForm()); + frame.pack(); + frame.setVisible(true); + + } } 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 13:03:37
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/2208812b5d60/ changeset: 2208812b5d60 user: alllee date: 2011-09-30 15:03:29 summary: updated voting form UI affected #: 5 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 05:21:54 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 06:03:29 2011 -0700 @@ -162,7 +162,7 @@ }); addEventProcessor(new EventTypeProcessor<ShowVotingInstructionsRequest>(ShowVotingInstructionsRequest.class) { public void handle(ShowVotingInstructionsRequest request) { - getGameWindow2D().showVotingInstructions(); + getGameWindow2D().showInitialVotingInstructions(); } }); addEventProcessor(new EventTypeProcessor<ShowVoteScreenRequest>(ShowVoteScreenRequest.class) { --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Fri Sep 30 05:21:54 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Fri Sep 30 06:03:29 2011 -0700 @@ -232,7 +232,7 @@ JPanel messagePanel = new JPanel(new BorderLayout()); JLabel messagePanelLabel = new JLabel("System messages"); - messagePanelLabel.setFont(ForagingInterface.DEFAULT_FONT_PLAIN); + messagePanelLabel.setFont(ForagingInterface.DEFAULT_PLAIN_FONT); messagePanel.add(messagePanelLabel, BorderLayout.NORTH); Dimension minimumSize = new Dimension(600, 200); messagePanel.setMinimumSize(minimumSize); --- a/src/main/java/edu/asu/commons/foraging/ui/ForagingInterface.java Fri Sep 30 05:21:54 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/ForagingInterface.java Fri Sep 30 06:03:29 2011 -0700 @@ -20,7 +20,7 @@ */ public final class ForagingInterface { - public static final Font DEFAULT_FONT_PLAIN = new Font(getDefaultFont().getFamily(), Font.PLAIN, 16); + public static final Font DEFAULT_PLAIN_FONT = new Font(getDefaultFont().getFamily(), Font.PLAIN, 16); public static final Font DEFAULT_BOLD_FONT = new Font(getDefaultFont().getFamily(), Font.BOLD, 16); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 05:21:54 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 06:03:29 2011 -0700 @@ -761,18 +761,33 @@ } - public void showVotingInstructions() { + public void showInitialVotingInstructions() { SwingUtilities.invokeLater(new Runnable() { public void run() { - setInstructions(dataModel.getRoundConfiguration().getVotingInstructions()); + setInstructions(dataModel.getRoundConfiguration().getInitialVotingInstructions()); switchInstructionsPane(); } }); } + private JPanel votingPanel; + private JPanel getVotingPanel() { + if (votingPanel == null) { + votingPanel = new JPanel(); + votingPanel.setLayout(new BoxLayout(votingPanel, BoxLayout.Y_AXIS)); + JEditorPane instructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); + JScrollPane scrollPane = new JScrollPane(instructionsEditorPane); + instructionsEditorPane.setText(client.getCurrentRoundConfiguration().getVotingInstructions()); + votingPanel.add(scrollPane); + VotingForm votingForm = new VotingForm(dataModel.getRoundConfiguration().getFixedRules()); + votingPanel.add(votingForm); + votingPanel.setName(VotingForm.NAME); + } + return votingPanel; + } public void showVoteScreen() { - // implement vote screen - + add(getVotingPanel()); + showPanel(VotingForm.NAME); } public void showSurveyInstructions() { --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 05:21:54 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java Fri Sep 30 06:03:29 2011 -0700 @@ -13,34 +13,39 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JRadioButton; +import edu.asu.commons.foraging.conf.RoundConfiguration; + /** * * @author alllee */ public class VotingForm extends javax.swing.JPanel { - - List<JRadioButton> radioButtons = new ArrayList<JRadioButton>(); - List<JLabel> labels = new ArrayList<JLabel>(); + + public final static String NAME = "Voting form"; + + private RoundConfiguration roundConfiguration; + private List<JRadioButton> radioButtons = new ArrayList<JRadioButton>(); + private List<JLabel> labels = new ArrayList<JLabel>(); /** Creates new form VotingForm */ public VotingForm() { this(Arrays.asList("Rule 1", "Rule 2", "Rule 3", "Rule 4")); } - + public VotingForm(List<String> rules) { + initComponents(); initForm(rules); - initComponents(); + setName(NAME); } private void initForm(List<String> rules) { - JPanel panel = new JPanel(); - GroupLayout groupLayout = new GroupLayout(panel); - panel.setLayout(groupLayout); + GroupLayout groupLayout = new GroupLayout(this); + setLayout(groupLayout); groupLayout.setAutoCreateGaps(true); groupLayout.setAutoCreateContainerGaps(true); GroupLayout.SequentialGroup horizontalGroup = groupLayout.createSequentialGroup(); @@ -51,13 +56,23 @@ horizontalGroup.addGroup(horizontalButtonParallelGroup); GroupLayout.SequentialGroup verticalGroup = groupLayout.createSequentialGroup(); + JLabel buttonHeaderLabel = new JLabel("Select one"); + buttonHeaderLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); + horizontalButtonParallelGroup.addComponent(buttonHeaderLabel); + + JLabel ruleHeaderLabel = new JLabel("Rule"); + ruleHeaderLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); + horizontalLabelParallelGroup.addComponent(ruleHeaderLabel); + + verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleHeaderLabel).addComponent(buttonHeaderLabel)); + for (String rule: rules) { JRadioButton radioButton = new JRadioButton(); radioButton.setActionCommand(String.valueOf(radioButtons.size())); radioButtons.add(radioButton); horizontalButtonParallelGroup.addComponent(radioButton); - JLabel ruleLabel = new JLabel(rule); + JLabel ruleLabel = new JLabel(String.format("%d. %s", radioButtons.size(), rule)); ruleLabel.setFont(ForagingInterface.DEFAULT_PLAIN_FONT); labels.add(ruleLabel); buttonGroup.add(radioButton); 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 12:22:39
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/3469d16c7e78/ changeset: 3469d16c7e78 user: <all...@asu.edu> Allen Lee date: 2011-09-30 14:21:54 summary: first cut at a voting form. affected #: 2 files (-1 bytes) 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 11:28:06
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/b34467980dc6/ changeset: b34467980dc6 user: alllee date: 2011-09-30 13:27:57 summary: stubs for survey and voting instructions in place. affected #: 3 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 04:27:57 2011 -0700 @@ -32,7 +32,10 @@ import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowSurveyInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; +import edu.asu.commons.foraging.event.ShowVoteScreenRequest; +import edu.asu.commons.foraging.event.ShowVotingInstructionsRequest; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; @@ -95,6 +98,7 @@ @Override protected void postConnect() { + // FIXME: this is hacky.. using the client side socket as the "authoritative" id. SocketIdentifier socketId = (SocketIdentifier) getId(); transmit(new SocketIdentifierUpdateRequest(socketId, socketId.getStationNumber())); state = ClientState.WAITING; @@ -156,6 +160,21 @@ getGameWindow().showTrustGame(); } }); + addEventProcessor(new EventTypeProcessor<ShowVotingInstructionsRequest>(ShowVotingInstructionsRequest.class) { + public void handle(ShowVotingInstructionsRequest request) { + getGameWindow2D().showVotingInstructions(); + } + }); + addEventProcessor(new EventTypeProcessor<ShowVoteScreenRequest>(ShowVoteScreenRequest.class) { + public void handle(ShowVoteScreenRequest request) { + getGameWindow2D().showVoteScreen(); + } + }); + addEventProcessor(new EventTypeProcessor<ShowSurveyInstructionsRequest>(ShowSurveyInstructionsRequest.class) { + public void handle(ShowSurveyInstructionsRequest request) { + getGameWindow2D().showSurveyInstructions(); + } + }); addEventProcessor(new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { public void handle(RoundStartedEvent event) { System.err.println("client starting round: " + dataModel.is2dExperiment()); @@ -404,6 +423,7 @@ } public void sendSurveyId(String surveyId) { + getId().setSurveyId(surveyId); transmit(new SurveyIdSubmissionRequest(getId(), surveyId)); getGameWindow2D().surveyIdSubmitted(); } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 04:27:57 2011 -0700 @@ -539,13 +539,13 @@ addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class, true) { public void handle(ShowRequest request) { if (request.getId().equals(facilitatorId)) { - logger.info("handling request " + request + " from facilitator"); for (Identifier id: clients.keySet()) { transmit(request.copy(id)); } + sendFacilitatorMessage("Received " + request + " from facilitator, copied & broadcastto all clients."); } else { - sendFacilitatorMessage("Ignoring show request from id: " + request.getId()); + sendFacilitatorMessage("Ignoring show request from non facilitator id: " + request.getId()); } } }); @@ -610,7 +610,6 @@ ClientData clientData = clients.get(request.getId()); clientData.getId().setSurveyId(request.getSurveyId()); sendFacilitatorMessage(String.format("Storing survey id %s for client %s", request.getSurveyId(), clientData)); - } }); addEventProcessor(new EventTypeProcessor<TrustGameSubmissionRequest>(TrustGameSubmissionRequest.class) { --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 04:27:57 2011 -0700 @@ -712,25 +712,35 @@ public void showTrustGame() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); if (roundConfiguration.isTrustGameEnabled()) { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - JEditorPane trustGameInstructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); - JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); - trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); - panel.add(scrollPane); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + JEditorPane trustGameInstructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); + JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); + trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); + panel.add(scrollPane); - TrustGamePanel trustGamePanel = new TrustGamePanel(client); - // trustGamePanel.setPreferredSize(new Dimension(300, 400)); - JScrollPane trustGameScrollPane = new JScrollPane(trustGamePanel); - panel.add(trustGameScrollPane); - panel.setName(TRUST_GAME_PANEL_NAME); - // addCenterComponent(panel); - // panel.revalidate(); - // panel.repaint(); - add(panel); - showPanel(TRUST_GAME_PANEL_NAME); + TrustGamePanel trustGamePanel = new TrustGamePanel(client); + // trustGamePanel.setPreferredSize(new Dimension(300, 400)); + JScrollPane trustGameScrollPane = new JScrollPane(trustGamePanel); + panel.add(trustGameScrollPane); + panel.setName(TRUST_GAME_PANEL_NAME); + // addCenterComponent(panel); + // panel.revalidate(); + // panel.repaint(); + add(panel); + showPanel(TRUST_GAME_PANEL_NAME); + } + }); } } + + public void trustGameSubmitted() { + instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); + setInstructions(instructionsBuilder.toString()); + switchInstructionsPane(); + } public void showInstructions() { final RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); @@ -750,13 +760,31 @@ }); } - public void trustGameSubmitted() { - instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); - setInstructions(instructionsBuilder.toString()); - switchInstructionsPane(); - + + public void showVotingInstructions() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setInstructions(dataModel.getRoundConfiguration().getVotingInstructions()); + switchInstructionsPane(); + } + }); } + public void showVoteScreen() { + // implement vote screen + + } + + public void showSurveyInstructions() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setInstructions(dataModel.getRoundConfiguration().getSurveyInstructions(dataModel.getId())); + switchInstructionsPane(); + } + }); + } + + public void switchInstructionsPane() { showPanel(INSTRUCTIONS_PANEL_NAME); } @@ -852,4 +880,5 @@ setInstructions(dataModel.getRoundConfiguration().getWelcomeInstructions()); switchInstructionsPane(); } + } 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 11:12:50
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/bd991e6567ed/ changeset: bd991e6567ed user: alllee date: 2011-09-30 13:12:39 summary: refactoring facilitator show logic, making it a bit more generic. All ShowXXX requests now automatically pass through to the client w/o having to explicitly iterate and recreate them via the ShowRequest interface. affected #: 18 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Fri Sep 30 04:12:39 2011 -0700 @@ -385,11 +385,7 @@ } public String getSanctionInstructions() { - return getProperty("sanction-instructions", "<h2>Voting instructions</h2>" + - "<ul> " + - "<li> You must make a choice within the next 30 seconds. " + - "<li>The votes of all participants in your group will determine the outcome." + - "</ul>"); + return getProperty("sanction-instructions"); } public boolean isAlwaysInExplicitCollectionMode() { @@ -523,6 +519,10 @@ return getBooleanProperty("rotating-monitor-enabled", false); } + /** + * Returns true if voting is enabled before the beginning of this round. + * @return + */ public boolean isVotingEnabled() { return getBooleanProperty("voting-enabled"); } @@ -659,6 +659,10 @@ return getDoubleProperty("quiz-correct-answer-reward", getParentConfiguration().getQuizCorrectAnswerReward()); } + /** + * Returns true if we should have a survey at the beginning of this round. + * @return + */ public boolean isExternalSurveyEnabled() { return getBooleanProperty("external-survey-enabled"); } --- a/src/main/java/edu/asu/commons/foraging/event/ShowInstructionsRequest.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/ShowInstructionsRequest.java Fri Sep 30 04:12:39 2011 -0700 @@ -3,11 +3,17 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.net.Identifier; -public class ShowInstructionsRequest extends AbstractEvent { +public class ShowInstructionsRequest extends AbstractEvent implements ShowRequest<ShowInstructionsRequest> { private static final long serialVersionUID = 3774308614796618926L; public ShowInstructionsRequest(Identifier id) { super(id); } + + @Override + public ShowInstructionsRequest copy(Identifier id) { + return new ShowInstructionsRequest(id); + } + } --- a/src/main/java/edu/asu/commons/foraging/event/ShowTrustGameRequest.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/ShowTrustGameRequest.java Fri Sep 30 04:12:39 2011 -0700 @@ -3,11 +3,16 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.net.Identifier; -public class ShowTrustGameRequest extends AbstractEvent { +public class ShowTrustGameRequest extends AbstractEvent implements ShowRequest<ShowTrustGameRequest> { private static final long serialVersionUID = 3774308614796618926L; public ShowTrustGameRequest(Identifier id) { super(id); } + + @Override + public ShowTrustGameRequest copy(Identifier id) { + return new ShowTrustGameRequest(id); + } } --- a/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Fri Sep 30 04:12:39 2011 -0700 @@ -22,7 +22,10 @@ import edu.asu.commons.foraging.event.FacilitatorUpdateEvent; import edu.asu.commons.foraging.event.QuizCompletedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowSurveyInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; +import edu.asu.commons.foraging.event.ShowVoteScreenRequest; +import edu.asu.commons.foraging.event.ShowVotingInstructionsRequest; import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.model.ServerDataModel; @@ -106,44 +109,6 @@ } } - // public void accept(Identifier id, Object event) { - // if (event instanceof ConfigurationEvent) { - // ConfigurationEvent configEvent = (ConfigurationEvent) event; - // setConfiguration(configEvent.getConfiguration()); - // } - // else if (event instanceof ServerGameStateEvent) { - // ServerGameStateEvent serverGameStateEvent = (ServerGameStateEvent) event; - // if (!stopExperiment) { - // - // if (serverGameState == null) { - // System.err.println("about to display game.."); - // experimentRunning = true; - // // FIXME: could use configuration from this event... serverGameStateEvent.getServerGameState().getConfiguration(); - // serverGameState = serverGameStateEvent.getServerGameState(); - // facilitatorWindow.displayGame(); - // } - // else { - // // synchronous updates - // serverGameState = serverGameStateEvent.getServerGameState(); - // } - // } - // facilitatorWindow.updateWindow(serverGameStateEvent.getTimeLeft()); - // // facilitatorWindow.repaint(); - // } - // else if (event instanceof FacilitatorEndRoundEvent) { - // FacilitatorEndRoundEvent endRoundEvent = (FacilitatorEndRoundEvent) event; - // serverGameState = null; - // facilitatorWindow.endRound(endRoundEvent); - // } - // else if (event instanceof FacilitatorSanctionUpdateEvent) { - // FacilitatorSanctionUpdateEvent fdue = (FacilitatorSanctionUpdateEvent) event; - // facilitatorWindow.updateDebriefing(fdue); - // } - // else if (event instanceof QuizCompletedEvent) { - // facilitatorWindow.quizCompleted(); - // } - // } - /* * Send a request to server to start an experiment */ @@ -159,9 +124,22 @@ transmit(new ShowInstructionsRequest(getId())); } - void sendShowTrustGameRequest() { + public void sendShowTrustGameRequest() { transmit(new ShowTrustGameRequest(getId())); } + + + public void sendShowVotingInstructionsRequest() { + transmit(new ShowVotingInstructionsRequest(getId())); + } + + public void sendShowVoteScreenRequest() { + transmit(new ShowVoteScreenRequest(getId())); + } + + public void sendShowSurveyInstructionsRequest() { + transmit(new ShowSurveyInstructionsRequest(getId())); + } /* * Send a request to start a round @@ -246,4 +224,5 @@ public void setServerGameState(ServerDataModel serverGameState) { this.serverDataModel = serverGameState; } + } --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Fri Sep 30 04:12:39 2011 -0700 @@ -62,6 +62,9 @@ private JMenuItem startChatMenuItem; private JMenuItem showTrustGameMenuItem; + private JMenuItem showVotingInstructionsMenuItem; + private JMenuItem showVoteScreenMenuItem; + private JMenuItem showSurveyInstructionsMenuItem; private HtmlEditorPane messageEditorPane; @@ -138,6 +141,8 @@ } }); menu.add(showTrustGameMenuItem); + + startRoundMenuItem = new JMenuItem("Start"); startRoundMenuItem.setMnemonic(KeyEvent.VK_T); @@ -159,6 +164,30 @@ }); menu.add(stopRoundMenuItem); menuBar.add(menu); + + // voting menu + menu = new JMenu("Voting"); + + showVotingInstructionsMenuItem = createMenuItem(menu, "Show voting instructions", new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.sendShowVotingInstructionsRequest(); + } + }); + showVoteScreenMenuItem = createMenuItem(menu, "Show voting screen", new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.sendShowVoteScreenRequest(); + } + }); + menuBar.add(menu); + + // survey menu + menu = new JMenu("Survey"); + showSurveyInstructionsMenuItem = createMenuItem(menu, "Show survey instructions", new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.sendShowSurveyInstructionsRequest(); + } + }); + menuBar.add(menu); //Configuration menu menu = new JMenu("Configuration"); @@ -176,6 +205,13 @@ return menuBar; } + + private JMenuItem createMenuItem(JMenu menu, String name, ActionListener listener) { + JMenuItem menuItem = new JMenuItem(name); + menuItem.addActionListener(listener); + menu.add(menuItem); + return menuItem; + } public JMenuBar getMenuBar() { return menuBar; --- a/src/main/java/edu/asu/commons/foraging/jcal3d/core/CoreModel.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/jcal3d/core/CoreModel.java Fri Sep 30 04:12:39 2011 -0700 @@ -5,7 +5,6 @@ import java.util.Vector; import edu.asu.commons.foraging.graphics.RGBA; -import edu.asu.commons.foraging.jcal3d.misc.Error; import edu.asu.commons.foraging.jcal3d.misc.Loader; import edu.asu.commons.foraging.jcal3d.misc.Saver; --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 04:12:39 2011 -0700 @@ -57,6 +57,7 @@ import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.SanctionAppliedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; @@ -535,33 +536,46 @@ } } }); - addEventProcessor(new EventTypeProcessor<ShowInstructionsRequest>(ShowInstructionsRequest.class) { - public void handle(ShowInstructionsRequest event) { - // FIXME: assign groups? - if (event.getId().equals(facilitatorId)) { - logger.info("Show Instructions request from facilitator - showing round instructions."); - for (Identifier id : clients.keySet()) { - transmit(new ShowInstructionsRequest(id)); + addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class, true) { + public void handle(ShowRequest request) { + if (request.getId().equals(facilitatorId)) { + logger.info("handling request " + request + " from facilitator"); + for (Identifier id: clients.keySet()) { + transmit(request.copy(id)); } } else { - logger.warning("Ignoring show instructions request from id: " + event.getId()); + sendFacilitatorMessage("Ignoring show request from id: " + request.getId()); } } }); - addEventProcessor(new EventTypeProcessor<ShowTrustGameRequest>(ShowTrustGameRequest.class) { - public void handle(ShowTrustGameRequest event) { - if (event.getId().equals(facilitatorId)) { - logger.info("Showing trust game."); - for (Identifier id : clients.keySet()) { - transmit(new ShowTrustGameRequest(id)); - } - } - else { - logger.warning("Ignoring show instructions request from id: " + event.getId()); - } - } - }); +// addEventProcessor(new EventTypeProcessor<ShowInstructionsRequest>(ShowInstructionsRequest.class) { +// public void handle(ShowInstructionsRequest event) { +// // FIXME: assign groups? +// if (event.getId().equals(facilitatorId)) { +// logger.info("Show Instructions request from facilitator - showing round instructions."); +// for (Identifier id : clients.keySet()) { +// transmit(new ShowInstructionsRequest(id)); +// } +// } +// else { +// logger.warning("Ignoring show instructions request from id: " + event.getId()); +// } +// } +// }); +// addEventProcessor(new EventTypeProcessor<ShowTrustGameRequest>(ShowTrustGameRequest.class) { +// public void handle(ShowTrustGameRequest event) { +// if (event.getId().equals(facilitatorId)) { +// logger.info("Showing trust game."); +// for (Identifier id : clients.keySet()) { +// transmit(new ShowTrustGameRequest(id)); +// } +// } +// else { +// logger.warning("Ignoring show instructions request from id: " + event.getId()); +// } +// } +// }); addEventProcessor(new EventTypeProcessor<BeginRoundRequest>(BeginRoundRequest.class) { public void handle(BeginRoundRequest event) { if (event.getId().equals(facilitatorId)) { --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 04:12:39 2011 -0700 @@ -785,9 +785,10 @@ getPanel().remove(chatPanel); chatPanel = null; } - if (dataModel.getRoundConfiguration().isPostRoundSanctioningEnabled()) { + RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); + if (roundConfiguration.isPostRoundSanctioningEnabled()) { // add sanctioning text and slap the PostRoundSanctioningPanel in - PostRoundSanctioningPanel panel = new PostRoundSanctioningPanel(event, dataModel.getRoundConfiguration(), client); + PostRoundSanctioningPanel panel = new PostRoundSanctioningPanel(event, roundConfiguration, client); panel.setName(POST_ROUND_SANCTIONING_PANEL_NAME); add(panel); showPanel(POST_ROUND_SANCTIONING_PANEL_NAME); --- a/src/main/java/edu/asu/commons/foraging/ui/TrustGamePanel.java Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/TrustGamePanel.java Fri Sep 30 04:12:39 2011 -0700 @@ -1,21 +1,19 @@ package edu.asu.commons.foraging.ui; import java.awt.Component; -import java.util.Arrays; +import javax.swing.ButtonModel; import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import edu.asu.commons.foraging.client.ForagingClient; import edu.asu.commons.foraging.conf.RoundConfiguration; -import javax.sound.midi.SysexMessage; -import javax.swing.ButtonModel; -import javax.swing.table.TableColumn; /** * $Id:$ --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Fri Sep 30 04:12:39 2011 -0700 @@ -31,6 +31,7 @@ ]]></entry> + <entry key='voting-instructions'><![CDATA[ <h1>Voting Instructions</h1> @@ -52,6 +53,25 @@ ]]></entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<hr> +<p> + Round 4 is about to begin. +</p> + +<p> +The length of this round is four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + <entry key='external-survey-enabled'>true</entry><entry key='survey-instructions'><![CDATA[ @@ -77,22 +97,45 @@ ]]></entry> -<entry key="instructions"> -<![CDATA[ -<h3>Round 4 Instructions</h3> + +<entry key='sanction-type'>REAL_TIME</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> +<entry key='sanction-instructions'> + <![CDATA[ + <h1>Instructions</h1> + <hr> +<p> +During this upcoming round you will have the option to reduce the earnings of +another participant at a cost to your own earnings. +</p> +<h2>How it works</h2><hr> -<p> - Round 4 is about to begin. -</p> - -<p> -The length of this round is four minutes. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> + <ul> + <li>If you press the numeric key 1-5 corresponding to another participant, you + will reduce the number of tokens they have collected in this round by two + tokens. This will also reduce your own token amount by one token. The decision + whether or when to use this option is up to you. + </li> + <li>When you reduce the number of tokens of another participant, they will + receive a message stating that you have reduced their tokens. Likewise, if + another participant reduces your number of tokens, you will also receive a + message. These messages will be displayed on the bottom of your screen. + </li> + <li>If your tokens are being reduced or you are reducing another participant's + tokens, you will receive some visual cues. When your tokens are being reduced + your yellow dot will turn red briefly with a blue background. The participant + currently reducing your tokens will turn purple with a white background. + </li> + <li>You may reduce the earnings of other participants as long as there are + tokens remaining on the screen and while both you and the other participant + have a positive number of tokens collected during the round. <b>Each time</b> + you press the numeric key corresponding to another participant your token + amount is reduced by <b>one</b>, and their token amount is reduced by + <b>two</b>. + </li> + </ul> + ]]></entry></properties> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Fri Sep 30 04:12:39 2011 -0700 @@ -28,23 +28,44 @@ </p> ]]></entry> -<entry key="chat-instructions"> -<![CDATA[ + +<entry key='sanction-type'>REAL_TIME</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> +<entry key='sanction-instructions'> + <![CDATA[ + <h1>Instructions</h1> + <hr><p> -You can chat with the other participants in your group during this round. -You may communicate about any aspect of the experiment that you would like to -discuss with other participants with whom you have been matched. You may not promise -them side-payments after the experiment is completed or threaten them with any -consequence after the experiment is finished. We are monitoring the chat traffic -while you chat. If we see that somebody reveals his or her identity, we have to stop -the experiment and remove the whole group from which this person is a member out of -this room. +During this upcoming round you will have the option to reduce the earnings of +another participant at a cost to your own earnings. </p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the chat -box. You can send a chat message by typing into the textfield and pressing the -enter key. -</p> -]]> +<h2>How it works</h2> +<hr> + <ul> + <li>If you press the numeric key 1-5 corresponding to another participant, you + will reduce the number of tokens they have collected in this round by two + tokens. This will also reduce your own token amount by one token. The decision + whether or when to use this option is up to you. + </li> + <li>When you reduce the number of tokens of another participant, they will + receive a message stating that you have reduced their tokens. Likewise, if + another participant reduces your number of tokens, you will also receive a + message. These messages will be displayed on the bottom of your screen. + </li> + <li>If your tokens are being reduced or you are reducing another participant's + tokens, you will receive some visual cues. When your tokens are being reduced + your yellow dot will turn red briefly with a blue background. The participant + currently reducing your tokens will turn purple with a white background. + </li> + <li>You may reduce the earnings of other participants as long as there are + tokens remaining on the screen and while both you and the other participant + have a positive number of tokens collected during the round. <b>Each time</b> + you press the numeric key corresponding to another participant your token + amount is reduced by <b>one</b>, and their token amount is reduced by + <b>two</b>. + </li> + </ul> + ]]></entry></properties> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Fri Sep 30 04:12:39 2011 -0700 @@ -8,14 +8,75 @@ <entry key="resource-width">26</entry><entry key="duration">240</entry> -<entry key='tokens-field-of-vision'>true</entry> -<entry key='subjects-field-of-vision'>true</entry> - <entry key="initial-distribution">.25</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> +<entry key='sanction-type'>REAL_TIME</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> +<entry key='sanction-instructions'> + <![CDATA[ + <h1>Instructions</h1> + <hr> +<p> +During this upcoming round you will have the option to reduce the earnings of +another participant at a cost to your own earnings. +</p> +<h2>How it works</h2> +<hr> + <ul> + <li>If you press the numeric key 1-5 corresponding to another participant, you + will reduce the number of tokens they have collected in this round by two + tokens. This will also reduce your own token amount by one token. The decision + whether or when to use this option is up to you. + </li> + <li>When you reduce the number of tokens of another participant, they will + receive a message stating that you have reduced their tokens. Likewise, if + another participant reduces your number of tokens, you will also receive a + message. These messages will be displayed on the bottom of your screen. + </li> + <li>If your tokens are being reduced or you are reducing another participant's + tokens, you will receive some visual cues. When your tokens are being reduced + your yellow dot will turn red briefly with a blue background. The participant + currently reducing your tokens will turn purple with a white background. + </li> + <li>You may reduce the earnings of other participants as long as there are + tokens remaining on the screen and while both you and the other participant + have a positive number of tokens collected during the round. <b>Each time</b> + you press the numeric key corresponding to another participant your token + amount is reduced by <b>one</b>, and their token amount is reduced by + <b>two</b>. + </li> + </ul> + ]]> +</entry> +<entry key='external-survey-enabled'>true</entry> +<entry key='survey-instructions'> + <![CDATA[ + <h1>Survey</h1> + <hr> + <p> + Before we continue to the next round of the token task, we would like to ask you + some quick questions. At the beginning of the survey you will need to enter: + </p> + <ul> + <li>Your player ID: {participantId} </li> + <li>Your survey ID: {surveyId} </li> + </ul> + <p> + Please <a href='{surveyLink}'>click here</a> to begin the survey. + </p> + ]]> +</entry> + +<entry key='survey-link'> + <![CDATA[ + https://qtrial.qualtrics.com/SE/?SID=SV_38lReBOv0Wk7wgY + ]]> +</entry> + <entry key="instructions"><![CDATA[ --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round7.xml Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round7.xml Fri Sep 30 04:12:39 2011 -0700 @@ -8,9 +8,6 @@ <entry key="resource-width">26</entry><entry key="duration">240</entry> -<entry key='tokens-field-of-vision'>true</entry> -<entry key='subjects-field-of-vision'>true</entry> - <entry key="initial-distribution">.25</entry><entry key='always-explicit'>true</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round9.xml Thu Sep 29 19:48:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round9.xml Fri Sep 30 04:12:39 2011 -0700 @@ -17,12 +17,38 @@ <entry key='max-cell-occupancy'>1</entry> +<entry key='external-survey-enabled'>true</entry> +<entry key='survey-instructions'> + <![CDATA[ + <h1>Survey</h1> + <hr> + <p> + Before we continue to the next round of the token task, we would like to ask you + some quick questions. At the beginning of the survey you will need to enter: + </p> + <ul> + <li>Your player ID: {participantId} </li> + <li>Your survey ID: {surveyId} </li> + </ul> + <p> + Please <a href='{surveyLink}'>click here</a> to begin the survey. + </p> + ]]> +</entry> + +<entry key='survey-link'> + <![CDATA[ + https://qtrial.qualtrics.com/SE/?SID=SV_38lReBOv0Wk7wgY + ]]> +</entry> + + <entry key="instructions"><![CDATA[ <h3>Instructions</h3><hr><p> -The length of this round is again four minutes. + This is the last round of the experiment. </p><p> If you have any questions please raise your hand. <b>Do you have any 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. |
From: Bitbucket <com...@bi...> - 2011-09-30 02:48:41
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/cbc1c7bd57f8/ changeset: cbc1c7bd57f8 user: alllee date: 2011-09-30 04:48:30 summary: setting up StringTemplate usage for survey instructions, seems pretty easy to use. Should probably fold support into csidex eventually. affected #: 3 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 15:16:16 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 19:48:30 2011 -0700 @@ -8,6 +8,8 @@ import java.util.Map; import java.util.Properties; +import org.stringtemplate.v4.ST; + import edu.asu.commons.conf.ExperimentRoundParameters; import edu.asu.commons.foraging.graphics.Point3D; import edu.asu.commons.foraging.model.ClientData; @@ -671,8 +673,11 @@ public String getSurveyInstructions(Identifier id) { String surveyInstructions = getSurveyInstructions(); - String updatedSurveyInstructions = surveyInstructions.replace("@PLAYER_ID@", id.toString()); - return updatedSurveyInstructions; + ST template = new ST(surveyInstructions, '{', '}'); + template.add("surveyLink", getSurveyLink()); + template.add("participantId", id); + template.add("surveyId", id.getSurveyId()); + return template.render(); } @Override --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 15:16:16 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 19:48:30 2011 -0700 @@ -62,11 +62,11 @@ some quick questions. At the beginning of the survey you will need to enter: </p><ul> - <li>Your player ID: @PLAYER_ID@ </li> - <li>Your survey ID: @SURVEY_ID@ </li> + <li>Your player ID: {participantId} </li> + <li>Your survey ID: {surveyId} </li></ul><p> - <a href='@SURVEY_LINK@'>Please click here to begin the survey</a>. + Please <a href='{surveyLink}'>click here</a> to begin the survey. </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. |
From: Bitbucket <com...@bi...> - 2011-09-29 22:16:27
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/2eeafaccc6fd/ changeset: 2eeafaccc6fd user: alllee date: 2011-09-30 00:16:16 summary: evaluating stringtemplate for our templating needs. affected #: 5 files (-1 bytes) --- a/ivy.xml Thu Sep 29 14:54:18 2011 -0700 +++ b/ivy.xml Thu Sep 29 15:16:16 2011 -0700 @@ -8,5 +8,6 @@ <dependency org="edu.asu.commons" name="csidex" rev="0.2-SNAPSHOT"/><dependency org="net.java.dev.jogl" name="jogl" rev="1.1.1-rc6"/><dependency org="javax.media" name="jmf" rev="2.1.1e"/> + <dependency org="org.antlr" name="stringtemplate" rev="4.0.2"/></dependencies></ivy-module> --- a/pom.xml Thu Sep 29 14:54:18 2011 -0700 +++ b/pom.xml Thu Sep 29 15:16:16 2011 -0700 @@ -83,6 +83,11 @@ <version>0.2-SNAPSHOT</version></dependency><dependency> + <groupId>org.antlr</groupId> + <artifactId>stringtemplate</artifactId> + <version>4.0.2</version> + </dependency> + <dependency><groupId>net.java.dev.jogl</groupId><artifactId>jogl</artifactId><version>1.1.1-rc6</version> --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 14:54:18 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 15:16:16 2011 -0700 @@ -12,6 +12,7 @@ import edu.asu.commons.foraging.graphics.Point3D; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.EnforcementMechanism; +import edu.asu.commons.net.Identifier; /** @@ -655,6 +656,24 @@ public double getQuizCorrectAnswerReward() { return getDoubleProperty("quiz-correct-answer-reward", getParentConfiguration().getQuizCorrectAnswerReward()); } + + public boolean isExternalSurveyEnabled() { + return getBooleanProperty("external-survey-enabled"); + } + + public String getSurveyInstructions() { + return getProperty("survey-instructions"); + } + + public String getSurveyLink() { + return getProperty("survey-link", "https://qtrial.qualtrics.com/SE/?SID=SV_38lReBOv0Wk7wgY"); + } + + public String getSurveyInstructions(Identifier id) { + String surveyInstructions = getSurveyInstructions(); + String updatedSurveyInstructions = surveyInstructions.replace("@PLAYER_ID@", id.toString()); + return updatedSurveyInstructions; + } @Override public String toString() { --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Thu Sep 29 14:54:18 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Thu Sep 29 15:16:16 2011 -0700 @@ -88,10 +88,6 @@ "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } - public boolean isExternalSurveyEnabled() { - return getBooleanProperty("external-survey-enabled"); - } - public boolean shouldAskForSurveyId() { return getBooleanProperty("survey-id-enabled"); } --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 14:54:18 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 15:16:16 2011 -0700 @@ -52,6 +52,7 @@ ]]></entry> +<entry key='external-survey-enabled'>true</entry><entry key='survey-instructions'><![CDATA[ <h1>Survey</h1> @@ -70,12 +71,18 @@ ]]></entry> +<entry key='survey-link'> + <![CDATA[ + https://qtrial.qualtrics.com/SE/?SID=SV_38lReBOv0Wk7wgY + ]]> +</entry> + <entry key="instructions"><![CDATA[ <h3>Round 4 Instructions</h3><hr><p> - In this round you will + Round 4 is about to begin. </p><p> 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. |
From: Bitbucket <com...@bi...> - 2011-09-29 21:54:31
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/b4775338bf72/ changeset: b4775338bf72 user: alllee date: 2011-09-29 23:54:18 summary: initial set up for survey linkages affected #: 4 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 03:52:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 14:54:18 2011 -0700 @@ -308,11 +308,6 @@ return getProperty("regulation-instructions"); } - public String getVotingInstructions() { - return getProperty( - "voting-instructions", - "You may rank the options below from 1 to 5, where 1 is the most favorable and 5 is the least favorable. When you rank a given option it will be sorted automatically."); - } public String getLastRoundDebriefing() { return getProperty("last-round-debriefing"); @@ -529,6 +524,14 @@ return getBooleanProperty("voting-enabled"); } + public String getVotingInstructions() { + return getProperty("voting-instructions"); + } + + public String getInitialVotingInstructions() { + return getProperty("initial-voting-instructions", "<h1>Notice</h1><hr><p>You will be given the ability to vote for rules in the next screen.</p>"); + } + public List<String> getFixedRules() { return FIXED_RULES; --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Thu Sep 29 03:52:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Thu Sep 29 14:54:18 2011 -0700 @@ -48,23 +48,4 @@ </p> ]]></entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can chat with the other participants in your group during this round. -You may communicate about any aspect of the experiment that you would like to -discuss with other participants with whom you have been matched. You may not promise -them side-payments after the experiment is completed or threaten them with any -consequence after the experiment is finished. We are monitoring the chat traffic -while you chat. If we see that somebody reveals his or her identity, we have to stop -the experiment and remove the whole group from which this person is a member out of -this room. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the chat -window. You can send a chat message by typing into the textfield and pressing the -enter key. -</p> -]]> -</entry></properties> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Thu Sep 29 03:52:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Thu Sep 29 14:54:18 2011 -0700 @@ -19,9 +19,7 @@ <![CDATA[ <h3>Round 3 Instructions</h3><hr> -<p> -Round 3 is the same as round 2. Except now the resources move. -</p> +<p>This round is the same as the previous round.</p><p> If you have any questions please raise your hand. <b>Do you have any questions so far?</b> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 03:52:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 14:54:18 2011 -0700 @@ -12,18 +12,70 @@ <entry key='max-cell-occupancy'>1</entry><entry key="initial-distribution">.25</entry> +<entry key='voting-enabled'>true</entry> +<entry key='initial-voting-instructions'> + <![CDATA[ +<h1>Notice</h1> +<hr> +<p> +In a moment, you will see a screen on your computer called Rule Options. It +will list 6 different rules that you can consider as options for managing how +each of your groups collect green tokens today. +</p> +<p> +You can nominate one rule from the list to help decide whether or not to have a +rule and what that rule will be. The rule that has the most nominations will be +considered chosen and established as the rule. If there is a tie, then each +tied nominated rule will receive an equal chance of getting selected at random. +</p> + ]]> +</entry> + +<entry key='voting-instructions'> +<![CDATA[ +<h1>Voting Instructions</h1> +<hr> +<p> +To nominate a rule, click the radio button to the left of the one you choose, and +then click "submit." The computer will tally the nominations and then report +the results on the next screen. The results will be presented to each +participant in your group and the experimenter. +</p> + +<p> +The identity of people who nominated a particular rule will NOT be revealed. +Therefore, neither you nor the experimenter will know who nominated a +particular rule. +</p> + +</p> +]]> +</entry> + +<entry key='survey-instructions'> + <![CDATA[ + <h1>Survey</h1> + <hr> + <p> + Before we continue to the next round of the token task, we would like to ask you + some quick questions. At the beginning of the survey you will need to enter: + </p> + <ul> + <li>Your player ID: @PLAYER_ID@ </li> + <li>Your survey ID: @SURVEY_ID@ </li> + </ul> + <p> + <a href='@SURVEY_LINK@'>Please click here to begin the survey</a>. + </p> + ]]> +</entry><entry key="instructions"><![CDATA[ <h3>Round 4 Instructions</h3><hr><p> - Round 4 is the same as the previous rounds with one exception. You will be able - to communicate with the other participants in your group <b>during</b> the - round. To communicate, hit the enter key, type uour message, and then hit the - enter key again. You must hit the enter key before every message you type, - otherwise control will return to the game screen where you can use the arrow - keys to move around. + In this round you will </p><p> @@ -36,23 +88,4 @@ ]]></entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can chat with the other participants in your group during this round. -You may communicate about any aspect of the experiment that you would like to -discuss with other participants with whom you have been matched. You may not promise -them side-payments after the experiment is completed or threaten them with any -consequence after the experiment is finished. We are monitoring the chat traffic -while you chat. If we see that somebody reveals his or her identity, we have to stop -the experiment and remove the whole group from which this person is a member out of -this room. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the chat -box. You can send a chat message by typing into the textfield and pressing the -enter key. -</p> -]]> -</entry></properties> 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. |
From: Bitbucket <com...@bi...> - 2011-09-29 11:20:33
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/8a517b0c64da/ changeset: 8a517b0c64da user: <all...@asu.edu> Allen Lee date: 2011-09-29 12:52:30 summary: forgot import affected #: 1 file (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 03:48:47 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 03:52:30 2011 -0700 @@ -1,6 +1,7 @@ package edu.asu.commons.foraging.conf; import java.awt.Dimension; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -12,6 +13,7 @@ import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.EnforcementMechanism; + /** * $Id: RoundConfiguration.java 534 2011-05-08 02:02:39Z alllee $ * 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. |
From: Bitbucket <com...@bi...> - 2011-09-29 10:48:56
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/fb8379345ce6/ changeset: fb8379345ce6 user: alllee date: 2011-09-29 12:48:47 summary: adjusting resource size in configuration files, adding fixed rules for voting condition affected #: 10 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 29 03:48:47 2011 -0700 @@ -44,6 +44,15 @@ private static final double DEFAULT_TOKEN_BIRTH_PROBABILITY = 0.01d; + private final static List<String> FIXED_RULES = Arrays.asList( + "Wait 2 minutes for the screen to fill up with green tokens. Then everyone collect tokens for the remaining amount of time.", + "Each person gets a set area within which they can do whatever they want with the green tokens. With four people, each person gets one of the four corners.", + "Each person collects green tokens at a certain rate: 1 token every 3 seconds (i.e., count to 3 between each token you collect).", + "When someone collects from a cluster of green tokens (i.e., 3 or more tokens that are touching each other) that person leaves at least 2 tokens touching each other.", + "Collect green tokens until only about 10 are left; at that point, everyone must wait at least 1 minute before collecting any more tokens.", + "No rule (Everyone can do whatever they want)." + ); + public double getTrustGamePayoffIncrement() { return getDoubleProperty("trust-game-payoff", 0.25d); } @@ -514,6 +523,14 @@ return getBooleanProperty("rotating-monitor-enabled", false); } + public boolean isVotingEnabled() { + return getBooleanProperty("voting-enabled"); + } + + public List<String> getFixedRules() { + return FIXED_RULES; + + } public boolean isVotingAndRegulationEnabled() { return getBooleanProperty("voting-and-regulation-enabled", false); } @@ -637,7 +654,7 @@ @Override public String toString() { List<RoundConfiguration> allParameters = getParentConfiguration().getAllParameters(); - return String.format("Round %d of %d -- %s", allParameters.indexOf(this) + 1, allParameters.size(), getProperties()); + return String.format("Round %d of %d\n\t%s", allParameters.indexOf(this) + 1, allParameters.size(), getProperties()); } } --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Thu Sep 29 03:48:47 2011 -0700 @@ -5,8 +5,8 @@ <entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry><entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round2.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round2.xml Thu Sep 29 03:48:47 2011 -0700 @@ -5,8 +5,8 @@ <entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry><entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><!-- enable field of vision for tokens and subjects --> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Thu Sep 29 03:48:47 2011 -0700 @@ -5,8 +5,8 @@ <entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry><entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,8 +4,8 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key='always-explicit'>true</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,15 +4,14 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key="initial-distribution">.25</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> -<entry key="in-round-chat-enabled">true</entry><entry key="instructions"><![CDATA[ --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,8 +4,8 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key='tokens-field-of-vision'>true</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round7.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round7.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,8 +4,8 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key='tokens-field-of-vision'>true</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round8.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round8.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,8 +4,8 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key='tokens-field-of-vision'>true</entry> --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round9.xml Wed Sep 28 21:03:30 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round9.xml Thu Sep 29 03:48:47 2011 -0700 @@ -4,8 +4,8 @@ <comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry><entry key="clients-per-group">4</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> +<entry key="resource-depth">26</entry> +<entry key="resource-width">26</entry><entry key="duration">240</entry><entry key='tokens-field-of-vision'>true</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. |
From: Bitbucket <com...@bi...> - 2011-09-29 04:03:41
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/dee26cb23631/ changeset: dee26cb23631 user: alllee date: 2011-09-29 06:03:30 summary: adding sendFacilitatorMessage convenience call to foraging server, basic support for storing survey ids is now in place. affected #: 8 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Sep 28 18:20:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Sep 28 21:03:30 2011 -0700 @@ -399,16 +399,16 @@ logger.warning("unapply() not implemented yet: " + persistableEvent); } - public void calculateTrustGame(ClientData playerOne, ClientData playerTwo) { + public String calculateTrustGame(ClientData playerOne, ClientData playerTwo) { if (playerOne.getId().equals(playerTwo.getId())) { - logger.warning("Tried to calculate trust game with self, aborting"); - return; + return "Tried to calculate trust game with self, aborting"; } double p1AmountToKeep = playerOne.getTrustGamePlayerOneAmountToKeep(); double[] p2AmountsToKeep = playerTwo.getTrustGamePlayerTwoAmountsToKeep(); double amountSent = 1.0d - p1AmountToKeep; - logger.info(String.format("Player one (%s) sent %s", playerOne, amountSent)); + StringBuilder builder = new StringBuilder(); + builder.append(String.format("Player one (%s) sent %s to player two (%s)\n", playerOne, amountSent, playerTwo)); if (amountSent > 0) { double p2AmountToKeep = 0.0d; int index = 0; @@ -425,11 +425,11 @@ double totalAmountSent = 3 * amountSent; double amountReturnedToP1 = totalAmountSent - p2AmountToKeep; String playerOneLog = String.format("Player one (%s) earned %s + %s = %s", playerOne, p1AmountToKeep, amountReturnedToP1, p1AmountToKeep + amountReturnedToP1); - logger.info(playerOneLog); + builder.append(playerOneLog).append("\n"); playerOne.logTrustGameEarnings(playerOneLog); playerOne.addTrustGameEarnings(p1AmountToKeep + amountReturnedToP1); String playerTwoLog = String.format("Player two (%s) earned %s", playerTwo, p2AmountToKeep); - logger.info(playerTwoLog); + builder.append(playerTwoLog).append("\n"); playerTwo.logTrustGameEarnings(playerTwoLog); playerTwo.addTrustGameEarnings(p2AmountToKeep); } @@ -439,6 +439,7 @@ playerOne.addTrustGameEarnings(p1AmountToKeep); playerTwo.logTrustGameEarnings(playerOneLog + " - you were player two and didn't receive anything."); } + return builder.toString(); } @Override --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 28 18:20:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 28 21:03:30 2011 -0700 @@ -58,6 +58,7 @@ import edu.asu.commons.foraging.event.SanctionAppliedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; +import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; @@ -256,19 +257,12 @@ transmit(new ClientMessageEvent(event.getId(), "The experiment has already started, we cannot add you at this time.")); return; } - // String t = event.getId().toString(); - // StringBuilder t1 = new StringBuilder(t); - // t1.append(clientIdCount); - Identifier newClientIdentifier = event.getId(); - // Identifier newClientIdentifier = (Identifier)t1.toString(); - - System.out.println("New Client ID : " + newClientIdentifier); - + Identifier identifier = event.getId(); synchronized (clients) { - clients.put(newClientIdentifier, new ClientData(newClientIdentifier)); + clients.put(identifier, new ClientData(identifier)); } // send welcome instructions and experiment configuration - transmit(new SetConfigurationEvent<RoundConfiguration>(newClientIdentifier, getCurrentRoundConfiguration())); + transmit(new SetConfigurationEvent<RoundConfiguration>(identifier, getCurrentRoundConfiguration())); } }); addEventProcessor(new EventTypeProcessor<DisconnectionRequest>(DisconnectionRequest.class) { @@ -284,7 +278,7 @@ public void handle(final ChatRequest request) { RoundConfiguration configuration = getCurrentRoundConfiguration(); if (!configuration.isChatEnabled()) { - logger.warning("configuration doesn't allow for chat but received " + request); + sendFacilitatorMessage("configuration doesn't allow for chat but received " + request); return; } if (configuration.isCensoredChat()) { @@ -298,15 +292,14 @@ addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { public void handle(final QuizResponseEvent event) { - logger.info("Received quiz response: " + event); + sendFacilitatorMessage("Received quiz response: " + event); numberOfSubmittedQuizzes++; transmit(new QuizCompletedEvent(facilitatorId, event)); ClientData clientData = clients.get(event.getId()); clientData.addCorrectQuizAnswers(event.getNumberOfCorrectAnswers()); if (numberOfSubmittedQuizzes >= clients.size()) { // we're done, notify the quizSignal - logger.info("Received all quizzes, notifying quiz signal"); - transmit(new FacilitatorMessageEvent(facilitatorId, "Received all quizzes, ready to start round.")); + sendFacilitatorMessage("Received all quizzes, ready to start round."); Utils.notify(quizSignal); } @@ -314,7 +307,7 @@ }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionRequest>(PostRoundSanctionRequest.class) { public void handle(PostRoundSanctionRequest event) { - System.out.println("Received post round sanction request"); + logger.info("Received post round sanction request"); clients.get(event.getId()).getGroupDataModel().handleSanctionRequest(event); // postRoundSanctionLatch.countDown(); numberOfCompletedSanctions++; @@ -576,15 +569,16 @@ logger.info("Begin round request from facilitator - starting round."); experimentStarted = true; Utils.notify(roundSignal); - System.out.println("Notified round signal"); } else { - transmit(new FacilitatorMessageEvent(facilitatorId, - String.format("Couldn't start round, waiting on %d of %d quizzes", numberOfSubmittedQuizzes, clients.size()))); + sendFacilitatorMessage(String.format( + "Couldn't start round, waiting on %d of %d quizzes", + numberOfSubmittedQuizzes, + clients.size())); } } else { - logger.warning("Ignoring begin round request from id: " + event.getId()); + sendFacilitatorMessage("Ignoring begin round request from id: " + event.getId()); } } }); @@ -596,12 +590,20 @@ } } }); + addEventProcessor(new EventTypeProcessor<SurveyIdSubmissionRequest>(SurveyIdSubmissionRequest.class) { + @Override + public void handle(SurveyIdSubmissionRequest request) { + ClientData clientData = clients.get(request.getId()); + clientData.getId().setSurveyId(request.getSurveyId()); + sendFacilitatorMessage(String.format("Storing survey id %s for client %s", request.getSurveyId(), clientData)); + + } + }); addEventProcessor(new EventTypeProcessor<TrustGameSubmissionRequest>(TrustGameSubmissionRequest.class) { int numberOfSubmissions = 0; - + @Override public void handle(TrustGameSubmissionRequest request) { if (getCurrentRoundConfiguration().isTrustGameEnabled()) { - logger.info("trust game submission: " + request); // basic sanity check ClientData clientData = clients.get(request.getId()); clientData.setTrustGamePlayerOneAmountToKeep(request.getPlayerOneAmountToKeep()); @@ -609,6 +611,7 @@ persister.store(request); transmit(new TrustGameSubmissionEvent(facilitatorId, request)); numberOfSubmissions++; + sendFacilitatorMessage(String.format("%d trust game submissions (%s)", numberOfSubmissions, request)); } if (numberOfSubmissions >= clients.size()) { // once all clients have submitted their decisions, execute the trust game. @@ -623,9 +626,8 @@ if (iter.hasNext()) { playerTwo = iter.next(); } - - logger.info(String.format("Pairing %s with %s for trust game", playerOne, playerTwo)); - serverDataModel.calculateTrustGame(playerOne, playerTwo); + String trustGameResults = serverDataModel.calculateTrustGame(playerOne, playerTwo); + sendFacilitatorMessage(String.format("Pairing %s with %s for trust game resulted in: %s", playerOne, playerTwo, trustGameResults)); } } numberOfSubmissions = 0; @@ -711,6 +713,11 @@ transmit(chatEvent); } } + + private void sendFacilitatorMessage(String message) { + logger.info(message); + transmit(new FacilitatorMessageEvent(facilitatorId, message)); + } // FIXME: remove Dispatcher reference if it's unused. public void execute(Dispatcher dispatcher) { --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 28 18:20:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 28 21:03:30 2011 -0700 @@ -165,7 +165,7 @@ public void run() { if (roundConfiguration.isFirstRound()) { if (roundConfiguration.getParentConfiguration().shouldAskForSurveyId()) { - mainPanel.add(getSurveyIdPanel()); + add(getSurveyIdPanel()); showPanel(SurveyIdPanel.NAME); } else { @@ -831,7 +831,7 @@ public JPanel getSurveyIdPanel() { if (surveyIdPanel == null) { - surveyIdPanel = new SurveyIdPanel(); + surveyIdPanel = new SurveyIdPanel(client); } return surveyIdPanel; } --- a/src/main/java/edu/asu/commons/foraging/ui/SurveyIdPanel.java Wed Sep 28 18:20:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/SurveyIdPanel.java Wed Sep 28 21:03:30 2011 -0700 @@ -1,5 +1,8 @@ package edu.asu.commons.foraging.ui; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -21,11 +24,22 @@ public SurveyIdPanel() { initComponents(); setName(NAME); + submitButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + String surveyId = surveyIdTextField.getText(); + if (surveyId == null || surveyId.trim().isEmpty()) { + JOptionPane.showMessageDialog(SurveyIdPanel.this, "Please enter a survey id."); + return; + } + client.sendSurveyId(surveyId); + } + }); } public SurveyIdPanel(ForagingClient client) { this(); this.client = client; + participantIdLabel.setText(client.getId().toString()); } /** This method is called from within the constructor to @@ -42,7 +56,7 @@ submitButton = new javax.swing.JButton(); participantIdLabel = new javax.swing.JLabel(); - surveyIdInstructionsLabel.setText("Please enter a unique survey ID for this participant:"); + surveyIdInstructionsLabel.setText("Please enter a unique survey ID for this participant."); surveyIdTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -85,12 +99,6 @@ }// </editor-fold>//GEN-END:initComponents private void surveyIdTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_surveyIdTextFieldActionPerformed - String surveyId = surveyIdTextField.getText(); - if (surveyId == null || surveyId.trim().isEmpty()) { - JOptionPane.showMessageDialog(this, "Please enter a survey id."); - return; - } - client.sendSurveyId(surveyId); }//GEN-LAST:event_surveyIdTextFieldActionPerformed --- a/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Wed Sep 28 18:20:32 2011 -0700 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Wed Sep 28 21:03:30 2011 -0700 @@ -3,7 +3,7 @@ <properties><comment>Foraging XML-ized experiment round configuration</comment><entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> +<entry key="clients-per-group">4</entry><entry key="resource-depth">29</entry><entry key="resource-width">29</entry><entry key="duration">240</entry> @@ -12,12 +12,9 @@ <entry key='subjects-field-of-vision'>true</entry><entry key="initial-distribution">.25</entry> -<!-- in round chat enabled --> -<entry key="in-round-chat-enabled">true</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> -<entry key='post-round-trust-game'>true</entry><entry key="instructions"> @@ -35,43 +32,4 @@ </p> ]]></entry> - -<entry key="last-round-debriefing"> -<![CDATA[ -<p> -This was the last round, but not the end of the experiment. We will now -determine your payments. While we are doing this, we request that you -carefully fill out a brief survey. -</p> -<p> -When we are ready we will call you one by one to the room next door. We will -pay you there in private. Please wait until your computer number is called, -and then proceed to the room next door to turn in your computer number and -your survey. -</p> -<p> -Please answer the survey carefully and thank you for participating. -</p> -]]> -</entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can chat with the other participants in your group during this round. -You may communicate about any aspect of the experiment that you would like to -discuss with other participants with whom you have been matched. You may not promise -them side-payments after the experiment is completed or threaten them with any -consequence after the experiment is finished. We are monitoring the chat traffic -while you chat. If we see that somebody reveals his or her identity, we have to stop -the experiment and remove the whole group from which this person is a member out of -this room. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the chat -box. You can send a chat message by typing into the textfield and pressing the -enter key. -</p> -]]> -</entry> - </properties> 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. |
From: Bitbucket <com...@bi...> - 2011-09-29 01:20:51
|
4 new changesets in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/3b71d2234f37/ changeset: 3b71d2234f37 user: alllee date: 2011-09-28 00:02:06 summary: setting up configuration files and survey logic for Daniel DeCaro's experiments in Indiana affected #: 10 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Fri Sep 23 18:01:40 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Tue Sep 27 15:02:06 2011 -0700 @@ -88,7 +88,12 @@ "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } + public boolean isExternalSurveyEnabled() { + return getBooleanProperty("external-survey-enabled"); + } - + public boolean shouldAskForSurveyId() { + return getBooleanProperty("survey-id-enabled"); + } } --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Fri Sep 23 18:01:40 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Tue Sep 27 15:02:06 2011 -0700 @@ -31,7 +31,7 @@ private final Identifier id; private GroupDataModel groupDataModel; - + private RegulationData regulationData; private int[] regulationRankings; --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round0.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="resource-width">13</entry> +<entry key="resource-depth">13</entry> +<entry key="practice-round">true</entry> +<entry key="private-property">true</entry> +<entry key="duration">240</entry> + +<entry key="quiz">true</entry> +<entry key="q1">C</entry> +<entry key="q2">B</entry> + +<entry key='instructions'> +<![CDATA[ +<h2>Practice Round Instructions</h2> +<hr> +<p> +You will now have four minutes to practice with the experimental environment. The +decisions you make in this round will NOT influence your earnings. At the beginning +of the practice round half of the cells are occupied with green tokens. The +environment is a 13 x 13 grid of cells. +</p> +<p> +During this practice round, and <b>only during</b> this practice round, you are able +to reset the tokens displayed on the screen by pressing the <b>R</b> key. When you +press the <b>R</b> key you will reset the resource to its initial distribution, +randomly filling half of the cells. +</p> +<p>If you have any questions please raise your hand. <b>Do you have any questions so far?</b></p> +]]> +</entry> + +<entry key="quiz-instructions"> +<![CDATA[ +<h2>Quiz</h2> +<hr> +<p> +Before we begin the practice round please answer the following questions. You will earn $0.50 for each correct answer. +</p> +<br><br> +<form> +<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> +<input type="submit" name="submit" value="Submit"><br> +</form> +]]> +</entry> +<entry key='q1-explanation'> + <![CDATA[ + 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[ + Tokens cannot regenerate on an empty screen as shown in sequence B. + ]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 1 Instructions</h3> +<hr> +<p> +This is the first round of the experiment. The length of the round is 4 +minutes. As in the practice round you can collect green tokens but now +you will earn <b>two cents</b> for each token collected. You <b>cannot</b> +reset the distribution of green tokens. +</p> +<p> +In this round the renewable resource will become five times bigger. You will share this +larger environment with four other players in this room that have been randomly +selected. Each group's resource environment is distinct from the other groups. +</p> +<p> +Each of you has been assigned a number from 1 to 5. These numbers will remain the +same throughout the experiment but you will <b>not</b> be able to identify which +person in the room has been assigned which number, so your anonymity is guaranteed. +</p> + +<p> +The other four players will appear on the screen as blue dots +<img src="@CODEBASE_URL@/images/gem-other.gif"> with a white +number embedded in the dot. On the top right corner of the screen you can see +how many tokens each player has collected. On the top left corner of the screen you can see +a clock that displays the remaining time in the round.</p> +<p>Since you can only see the resource within your vision you may neither see all +the other participants nor all the resource units. The figure below indicates the +vision range compared to the whole environment</p> +<img src="@CODEBASE_URL@/images/vision-range.jpg"> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +window. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round2.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + + +<!-- enable field of vision for tokens and subjects --> +<entry key='initial-distribution'>.25</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 2 Instructions</h3> +<hr> +<p> +Round 2 is the same as round 1. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- resource regrowth parameters --> +<entry key="initial-distribution">.25</entry> + + +<entry key="instructions"> +<![CDATA[ +<h3>Round 3 Instructions</h3> +<hr> +<p> +Round 3 is the same as round 2. Except now the resources move. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="initial-distribution">.25</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<hr> +<p> + Round 4 is the same as the previous rounds with one exception. You will be able + to communicate with the other participants in your group <b>during</b> the + round. To communicate, hit the enter key, type uour message, and then hit the + enter key again. You must hit the enter key before every message you type, + otherwise control will return to the game screen where you can use the arrow + keys to move around. +</p> + +<p> +The length of this round is four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key="initial-distribution">.25</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> +<entry key="in-round-chat-enabled">true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 5 Instructions</h3> +<hr> +<p> +Round 5 is the same as round 4.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round6.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<entry key="initial-distribution">.25</entry> +<!-- in round chat enabled --> +<entry key="in-round-chat-enabled">true</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> +<entry key='post-round-trust-game'>true</entry> + + +<entry key="instructions"> +<![CDATA[ +<h3>Round 6 Instructions</h3> +<hr> +<p> +Round 6 is the same as round 5.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="last-round-debriefing"> +<![CDATA[ +<p> +This was the last round, but not the end of the experiment. We will now +determine your payments. While we are doing this, we request that you +carefully fill out a brief survey. +</p> +<p> +When we are ready we will call you one by one to the room next door. We will +pay you there in private. Please wait until your computer number is called, +and then proceed to the room next door to turn in your computer number and +your survey. +</p> +<p> +Please answer the survey carefully and thank you for participating. +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> + +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/server.xml Tue Sep 27 15:02:06 2011 -0700 @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging experiment server configuration</comment> +<entry key="hostname">@SERVER_ADDRESS@</entry> +<entry key="port">@PORT_NUMBER@</entry> +<entry key="round0">round0.xml</entry> +<entry key="round1">round1.xml</entry> +<entry key="round2">round2.xml</entry> +<entry key="round3">round3.xml</entry> +<entry key="round4">round4.xml</entry> +<entry key="round5">round5.xml</entry> +<entry key="round6">round6.xml</entry> +<entry key="round7">round7.xml</entry> +<entry key="round8">round8.xml</entry> +<entry key="round9">round9.xml</entry> +<entry key="wait-for-participants">true</entry> +<entry key="number-of-rounds">7</entry> +<entry key='external-survey-enabled'>true</entry> +<entry key='survey-id-enabled'>true</entry> +<entry key="facilitator-instructions"> +<![CDATA[ +<p> + This facilitator interface allows you to control the experiment. In general you + will be following a sequence similar to this: + <ol> + <li>Show instructions</li> + <li>Start round</li> + <li>After round is over + <ol> + <li>show trust game if necessary</li> + <li>start standalone chat round if necessary</li> + </ol> + </li> + <li>Goto 1.</li> + </ol> +</p> +]]> +</entry> + +<entry key='field-of-vision-instructions'> +<![CDATA[ +Your vision is limited in this experiment. The area that is visible to you will be +shaded. +]]> +</entry> + +<entry key="welcome-instructions"> +<![CDATA[ +<h1>Welcome</h1> +<hr> +<p> +Welcome to the experiment. The experiment will begin shortly after everyone has been +assigned a station. +<br><br> +Please <b>wait quietly</b> and <b>do not close this window, open any other applications, or communicate with any of the other participants</b>. +</p> +]]> +</entry> + +<entry key="general-instructions"> +<![CDATA[ +<h1>General Instructions</h1> +<p> + <b>Welcome</b>. You have already earned 5 dollars just for showing up at this experiment. +</p> +<p> +You can earn more, up to a maximum of about 40 dollars, by participating in this +experiment which will take about an hour to an hour and a half. The amount of money +you earn depends on your decisions as well as the decisions of other people in this room +over the course of the experiment. +</p> +<h2>How to participate</h2> +<hr> +<p> +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. +</p> +<p> + You can move up, down, left, or right. You have to press a key for each and + every move of your yellow dot. As you move around you can collect green diamond + shaped tokens <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> + +<h2>Tokens</h2> +<hr> +<p> +The tokens that you collect have the potential to regenerate. After you have +collected a green token, a new token can re-appear on that empty cell. The rate at +which new tokens appear is dependent on the number of adjacent cells with tokens. +The more tokens in the eight cells that surround an empty cell, the faster a new +token will appear on that empty cell. In other words, <b>existing tokens can +generate new tokens</b>. To illustrate this, please refer to Image 1 and Image 2. +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> +<td align="center"><b>Image 1</b></td> +<td align="center"><b>Image 2</b></td> +</tr> +<tr> +<td align="center"> + <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> +</td> +</tr> +</table> + +<h2>Best Strategy</h2> +<hr> +<p> +The chance that a token will regenerate on an empty cell increases as there are +more tokens surrounding it. Therefore, you want to have as many tokens around an +empty cell as possible. However, you also need empty cells to benefit from this +regrowth. The best arrangement of tokens that maximizes overall regrowth is the +checkerboard diagram shown below. +<br> +<img src="@CODEBASE_URL@/images/foraging-checkerboard.png" alt="Checkerboard Resource"></img> +</p> +]]> +</entry> + +<entry key='trust-game-instructions'> +<![CDATA[ +<h1>Instructions</h1> +<hr> +<p> + You will now participate in an exercise where you will be matched with a random + person in your group. In this exercise there are two roles, Player 1 and Player 2. + Your job is to design strategies for both Player 1 and Player 2 roles. When you + are randomly paired with another member of your group you may be selected as + Player 1 <b>or</b> Player 2. The results of randomly pairing your strategies + with the other group member's strategies will be shown to you at the <b>end of + the experiment</b>. +</p> + +<h2>How to participate</h2> +<hr> +<ol> + <li>Player 1 will first receive an endowment of one dollar and has to decide <b>how much to keep</b>. The remaining amount is <b>sent to Player 2</b>. + <li>The amount Player 1 sends to Player 2 is tripled by the system and then + given to Player 2. Player 2 must then 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> +<p> +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> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may discuss any aspect of the experiment with the other participants in your group with two exceptions: +<ol> + <li>You <b>may not promise side-payments after the experiment is completed or threaten anyone with any consequence after the experiment is finished</b>.</li> + <li>You <b>may not reveal your actual identity</b></li> +</ol> +We are monitoring the chat traffic while you chat. If we detect any violation of the +rules we will have to stop the the experiment and remove the group where the offense +occurred from the room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> + +</properties> http://bitbucket.org/virtualcommons/foraging/changeset/f64d1f94cc9b/ changeset: f64d1f94cc9b user: alllee date: 2011-09-29 03:02:58 summary: setting up survey id panel affected #: 4 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Tue Sep 27 15:02:06 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Sep 28 18:02:58 2011 -0700 @@ -3,15 +3,12 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.util.LinkedList; -import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import javax.swing.text.html.HTMLDocument; import edu.asu.commons.client.BaseClient; import edu.asu.commons.event.ClientMessageEvent; @@ -67,14 +64,11 @@ }; private ClientState state = ClientState.UNCONNECTED; + + private GameWindow gameWindow; - private GameWindow2D gameWindow2D; - - private GameWindow3D gameWindow3D; - private ClientDataModel dataModel; - private MessageQueue messageQueue; private JPanel clientPanel = new JPanel(); @@ -88,13 +82,13 @@ dataModel = new ClientDataModel(this); clientPanel.setLayout(new BorderLayout()); if (configuration.shouldInitialize2D()) { - gameWindow2D = new GameWindow2D(this, screenSize); - clientPanel.add(gameWindow2D.getPanel(), BorderLayout.CENTER); + gameWindow = new GameWindow2D(this, screenSize); } else if (configuration.shouldInitialize3D()) { - gameWindow3D = new GameWindow3D(this); - clientPanel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); + gameWindow = new GameWindow3D(this); } + clientPanel.add(gameWindow.getPanel(), BorderLayout.CENTER); + } @@ -106,30 +100,25 @@ } public GameWindow2D getGameWindow2D() { - return gameWindow2D; + return (GameWindow2D) gameWindow; } public GameWindow3D getGameWindow3D() { - return gameWindow3D; + return (GameWindow3D) gameWindow; } public GameWindow getGameWindow() { - if (dataModel.is2dExperiment()) { - return gameWindow2D; - } - else { - return gameWindow3D; - } + return gameWindow; } public void sendAvatarInfo(boolean male, Color hairColor, Color skinColor, Color shirtColor, Color trouserColor, Color shoesColor) { transmit(new AgentInfoRequest(getId(), male, hairColor, skinColor, shirtColor, trouserColor, shoesColor)); - gameWindow3D.removeAgentDesigner(); + getGameWindow3D().removeAgentDesigner(); } public void sendAgentInfo(Color color) { transmit(new AgentInfoRequest(getId(), color)); - gameWindow3D.removeAgentDesigner(); + getGameWindow3D().removeAgentDesigner(); } @Override @@ -141,20 +130,15 @@ dataModel.setRoundConfiguration(configuration); SwingUtilities.invokeLater(new Runnable() { public void run() { - clientPanel.removeAll(); - if (dataModel.is2dExperiment()) { - clientPanel.add(gameWindow2D.getPanel(), BorderLayout.CENTER); - if (gameWindow3D != null) { - gameWindow3D.dispose(); - } - } - else { - clientPanel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); - - } - getGameWindow().init(); - clientPanel.revalidate(); - clientPanel.repaint(); +// clientPanel.removeAll(); + // only needed for defunct 3d case, getting rid of this now. +// if (gameWindow != null) { +// gameWindow.dispose(); +// } +// clientPanel.add(gameWindow.getPanel(), BorderLayout.CENTER); + gameWindow.init(); +// clientPanel.revalidate(); +// clientPanel.repaint(); } }); @@ -199,8 +183,9 @@ addEventProcessor(new EventTypeProcessor<SynchronizeClientEvent>(SynchronizeClientEvent.class) { public void handle(SynchronizeClientEvent event) { dataModel.setGroupDataModel(event.getGroupDataModel()); + // FIXME: gross if (dataModel.is2dExperiment()) { - dataModel.update(event, gameWindow2D); + dataModel.update(event, getGameWindow2D()); } getGameWindow().update(event.getTimeLeft()); } @@ -214,7 +199,7 @@ addEventProcessor(new EventTypeProcessor<LockResourceEvent>(LockResourceEvent.class) { public void handle(LockResourceEvent event) { // tell the game window to highlight the appropriate resource - gameWindow3D.highlightResource(event); + getGameWindow3D().highlightResource(event); } }); } @@ -223,52 +208,27 @@ addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { public void handle(BeginChatRoundRequest request) { dataModel.initialize(request.getGroupDataModel()); - gameWindow2D.initializeChatPanel(); + getGameWindow2D().initializeChatPanel(); } }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionUpdateEvent>(PostRoundSanctionUpdateEvent.class) { public void handle(PostRoundSanctionUpdateEvent event) { - gameWindow2D.updateDebriefing(event); + getGameWindow2D().updateDebriefing(event); } }); addEventProcessor(new EventTypeProcessor<ClientPositionUpdateEvent>(ClientPositionUpdateEvent.class) { public void handle(ClientPositionUpdateEvent event) { if (state == ClientState.RUNNING) { - dataModel.updateDiffs(event, gameWindow2D); + dataModel.updateDiffs(event, getGameWindow2D()); } } }); addEventProcessor(new EventTypeProcessor<ClientMessageEvent>(ClientMessageEvent.class) { public void handle(ClientMessageEvent event) { - gameWindow2D.displayMessage(event.toString()); + getGameWindow2D().displayMessage(event.toString()); } }); -// addEventProcessor(new EventTypeProcessor<EnforcementMechanismUpdateEvent>(EnforcementMechanismUpdateEvent.class) { -// public void handle(final EnforcementMechanismUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.displayActiveEnforcementMechanism(); -// } -// }); -// addEventProcessor(new EventTypeProcessor<RegulationSubmissionUpdateEvent>(RegulationSubmissionUpdateEvent.class) { -// public void handle(final RegulationSubmissionUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.initializeRegulationVotingPanel(); -// } -// }); -// addEventProcessor(new EventTypeProcessor<RegulationUpdateEvent>(RegulationUpdateEvent.class) { -// public void handle(final RegulationUpdateEvent event) { -// dataModel.setActiveRegulation(event.getRegulationData()); -// gameWindow2D.displayActiveRegulation(); -// } -// }); -// -// addEventProcessor(new EventTypeProcessor<SanctionUpdateEvent>(SanctionUpdateEvent.class) { -// public void handle(final SanctionUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.displaySanctionMechanism(); -// } -// }); } public boolean canPerformRealTimeSanction() { @@ -281,7 +241,7 @@ //System.out.println("Sending post round sanction request"); SwingUtilities.invokeLater(new Runnable() { public void run() { - gameWindow2D.switchInstructionsPane(); + getGameWindow2D().switchInstructionsPane(); } }); super.transmit(request); --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Tue Sep 27 15:02:06 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 28 18:02:58 2011 -0700 @@ -86,7 +86,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision: 529 $ */ -public class ForagingServer extends AbstractExperiment<ServerConfiguration> { +public class ForagingServer extends AbstractExperiment<ServerConfiguration, RoundConfiguration> { private final Logger logger = Logger.getLogger(getClass().getName()); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Tue Sep 27 15:02:06 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Wed Sep 28 18:02:58 2011 -0700 @@ -17,6 +17,7 @@ public void startRound(); public void endRound(EndRoundEvent event); public void init(); + public void dispose(); public void update(long millisecondsLeft); public void showInstructions(); public void showTrustGame(); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Tue Sep 27 15:02:06 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 28 18:02:58 2011 -0700 @@ -70,11 +70,15 @@ private final ClientDataModel dataModel; - private final static String INSTRUCTIONS_PANEL_NAME = "Foraging instructions panel"; - private final static String GAME_PANEL_NAME = "Game panel"; - private final static String TRUST_GAME_PANEL_NAME = "Trust game panel"; + // instructions panel + private final static String INSTRUCTIONS_PANEL_NAME = "instructions screen panel"; + // game board panel + private final static String GAME_PANEL_NAME = "foraging game panel"; + private final static String TRUST_GAME_PANEL_NAME = "trust game panel"; // standalone chat panel - private final static String CHAT_PANEL_NAME = "Chat panel"; + private final static String CHAT_PANEL_NAME = "standalone chat panel"; + // survey id panel + private final static String SURVEY_ID_PANEL_NAME = "survey id panel"; protected static final String POST_ROUND_SANCTIONING_PANEL_NAME = null; @@ -93,6 +97,8 @@ private JTextPane messageTextPane; private JPanel labelPanel; + + private JPanel surveyIdPanel; // FIXME: this shouldn't be public public static Duration duration; @@ -158,7 +164,12 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { if (roundConfiguration.isFirstRound()) { - setInstructions(roundConfiguration.getWelcomeInstructions()); + if (roundConfiguration.getParentConfiguration().shouldAskForSurveyId()) { + + } + else { + setInstructions(roundConfiguration.getWelcomeInstructions()); + } } // don't display next round time, instead wait for the // facilitator signal. @@ -816,6 +827,19 @@ public JPanel getPanel() { return mainPanel; } + + public JPanel getSurveyIdPanel() { + if (surveyIdPanel == null) { + surveyIdPanel = new JPanel(); + surveyIdPanel.setName(SURVEY_ID_PANEL_NAME); + } + return surveyIdPanel; + } + + @Override + public void dispose() { + // no-op, nothing to dispose. + } @Override public void requestFocusInWindow() { http://bitbucket.org/virtualcommons/foraging/changeset/0dcdee118942/ changeset: 0dcdee118942 user: alllee date: 2011-09-29 03:03:07 summary: Automated merge with ssh://bitbucket.org/virtualcommons/foraging affected #: 14 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Sep 28 18:03:07 2011 -0700 @@ -3,15 +3,12 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.util.LinkedList; -import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import javax.swing.text.html.HTMLDocument; import edu.asu.commons.client.BaseClient; import edu.asu.commons.event.ClientMessageEvent; @@ -67,14 +64,11 @@ }; private ClientState state = ClientState.UNCONNECTED; + + private GameWindow gameWindow; - private GameWindow2D gameWindow2D; - - private GameWindow3D gameWindow3D; - private ClientDataModel dataModel; - private MessageQueue messageQueue; private JPanel clientPanel = new JPanel(); @@ -88,13 +82,13 @@ dataModel = new ClientDataModel(this); clientPanel.setLayout(new BorderLayout()); if (configuration.shouldInitialize2D()) { - gameWindow2D = new GameWindow2D(this, screenSize); - clientPanel.add(gameWindow2D.getPanel(), BorderLayout.CENTER); + gameWindow = new GameWindow2D(this, screenSize); } else if (configuration.shouldInitialize3D()) { - gameWindow3D = new GameWindow3D(this); - clientPanel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); + gameWindow = new GameWindow3D(this); } + clientPanel.add(gameWindow.getPanel(), BorderLayout.CENTER); + } @@ -106,30 +100,25 @@ } public GameWindow2D getGameWindow2D() { - return gameWindow2D; + return (GameWindow2D) gameWindow; } public GameWindow3D getGameWindow3D() { - return gameWindow3D; + return (GameWindow3D) gameWindow; } public GameWindow getGameWindow() { - if (dataModel.is2dExperiment()) { - return gameWindow2D; - } - else { - return gameWindow3D; - } + return gameWindow; } public void sendAvatarInfo(boolean male, Color hairColor, Color skinColor, Color shirtColor, Color trouserColor, Color shoesColor) { transmit(new AgentInfoRequest(getId(), male, hairColor, skinColor, shirtColor, trouserColor, shoesColor)); - gameWindow3D.removeAgentDesigner(); + getGameWindow3D().removeAgentDesigner(); } public void sendAgentInfo(Color color) { transmit(new AgentInfoRequest(getId(), color)); - gameWindow3D.removeAgentDesigner(); + getGameWindow3D().removeAgentDesigner(); } @Override @@ -141,20 +130,15 @@ dataModel.setRoundConfiguration(configuration); SwingUtilities.invokeLater(new Runnable() { public void run() { - clientPanel.removeAll(); - if (dataModel.is2dExperiment()) { - clientPanel.add(gameWindow2D.getPanel(), BorderLayout.CENTER); - if (gameWindow3D != null) { - gameWindow3D.dispose(); - } - } - else { - clientPanel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); - - } - getGameWindow().init(); - clientPanel.revalidate(); - clientPanel.repaint(); +// clientPanel.removeAll(); + // only needed for defunct 3d case, getting rid of this now. +// if (gameWindow != null) { +// gameWindow.dispose(); +// } +// clientPanel.add(gameWindow.getPanel(), BorderLayout.CENTER); + gameWindow.init(); +// clientPanel.revalidate(); +// clientPanel.repaint(); } }); @@ -199,8 +183,9 @@ addEventProcessor(new EventTypeProcessor<SynchronizeClientEvent>(SynchronizeClientEvent.class) { public void handle(SynchronizeClientEvent event) { dataModel.setGroupDataModel(event.getGroupDataModel()); + // FIXME: gross if (dataModel.is2dExperiment()) { - dataModel.update(event, gameWindow2D); + dataModel.update(event, getGameWindow2D()); } getGameWindow().update(event.getTimeLeft()); } @@ -214,7 +199,7 @@ addEventProcessor(new EventTypeProcessor<LockResourceEvent>(LockResourceEvent.class) { public void handle(LockResourceEvent event) { // tell the game window to highlight the appropriate resource - gameWindow3D.highlightResource(event); + getGameWindow3D().highlightResource(event); } }); } @@ -223,52 +208,27 @@ addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { public void handle(BeginChatRoundRequest request) { dataModel.initialize(request.getGroupDataModel()); - gameWindow2D.initializeChatPanel(); + getGameWindow2D().initializeChatPanel(); } }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionUpdateEvent>(PostRoundSanctionUpdateEvent.class) { public void handle(PostRoundSanctionUpdateEvent event) { - gameWindow2D.updateDebriefing(event); + getGameWindow2D().updateDebriefing(event); } }); addEventProcessor(new EventTypeProcessor<ClientPositionUpdateEvent>(ClientPositionUpdateEvent.class) { public void handle(ClientPositionUpdateEvent event) { if (state == ClientState.RUNNING) { - dataModel.updateDiffs(event, gameWindow2D); + dataModel.updateDiffs(event, getGameWindow2D()); } } }); addEventProcessor(new EventTypeProcessor<ClientMessageEvent>(ClientMessageEvent.class) { public void handle(ClientMessageEvent event) { - gameWindow2D.displayMessage(event.toString()); + getGameWindow2D().displayMessage(event.toString()); } }); -// addEventProcessor(new EventTypeProcessor<EnforcementMechanismUpdateEvent>(EnforcementMechanismUpdateEvent.class) { -// public void handle(final EnforcementMechanismUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.displayActiveEnforcementMechanism(); -// } -// }); -// addEventProcessor(new EventTypeProcessor<RegulationSubmissionUpdateEvent>(RegulationSubmissionUpdateEvent.class) { -// public void handle(final RegulationSubmissionUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.initializeRegulationVotingPanel(); -// } -// }); -// addEventProcessor(new EventTypeProcessor<RegulationUpdateEvent>(RegulationUpdateEvent.class) { -// public void handle(final RegulationUpdateEvent event) { -// dataModel.setActiveRegulation(event.getRegulationData()); -// gameWindow2D.displayActiveRegulation(); -// } -// }); -// -// addEventProcessor(new EventTypeProcessor<SanctionUpdateEvent>(SanctionUpdateEvent.class) { -// public void handle(final SanctionUpdateEvent event) { -// dataModel.setGroupDataModel(event.getGroupDataModel()); -// gameWindow2D.displaySanctionMechanism(); -// } -// }); } public boolean canPerformRealTimeSanction() { @@ -281,7 +241,7 @@ //System.out.println("Sending post round sanction request"); SwingUtilities.invokeLater(new Runnable() { public void run() { - gameWindow2D.switchInstructionsPane(); + getGameWindow2D().switchInstructionsPane(); } }); super.transmit(request); --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Wed Sep 28 18:03:07 2011 -0700 @@ -88,7 +88,12 @@ "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } + public boolean isExternalSurveyEnabled() { + return getBooleanProperty("external-survey-enabled"); + } - + public boolean shouldAskForSurveyId() { + return getBooleanProperty("survey-id-enabled"); + } } --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Sep 28 18:03:07 2011 -0700 @@ -31,7 +31,7 @@ private final Identifier id; private GroupDataModel groupDataModel; - + private RegulationData regulationData; private int[] regulationRankings; --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 28 18:03:07 2011 -0700 @@ -86,7 +86,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision: 529 $ */ -public class ForagingServer extends AbstractExperiment<ServerConfiguration> { +public class ForagingServer extends AbstractExperiment<ServerConfiguration, RoundConfiguration> { private final Logger logger = Logger.getLogger(getClass().getName()); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Wed Sep 28 18:03:07 2011 -0700 @@ -17,6 +17,7 @@ public void startRound(); public void endRound(EndRoundEvent event); public void init(); + public void dispose(); public void update(long millisecondsLeft); public void showInstructions(); public void showTrustGame(); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 28 18:01:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 28 18:03:07 2011 -0700 @@ -70,11 +70,15 @@ private final ClientDataModel dataModel; - private final static String INSTRUCTIONS_PANEL_NAME = "Foraging instructions panel"; - private final static String GAME_PANEL_NAME = "Game panel"; - private final static String TRUST_GAME_PANEL_NAME = "Trust game panel"; + // instructions panel + private final static String INSTRUCTIONS_PANEL_NAME = "instructions screen panel"; + // game board panel + private final static String GAME_PANEL_NAME = "foraging game panel"; + private final static String TRUST_GAME_PANEL_NAME = "trust game panel"; // standalone chat panel - private final static String CHAT_PANEL_NAME = "Chat panel"; + private final static String CHAT_PANEL_NAME = "standalone chat panel"; + // survey id panel + private final static String SURVEY_ID_PANEL_NAME = "survey id panel"; protected static final String POST_ROUND_SANCTIONING_PANEL_NAME = null; @@ -93,6 +97,8 @@ private JTextPane messageTextPane; private JPanel labelPanel; + + private JPanel surveyIdPanel; // FIXME: this shouldn't be public public static Duration duration; @@ -158,7 +164,12 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { if (roundConfiguration.isFirstRound()) { - setInstructions(roundConfiguration.getWelcomeInstructions()); + if (roundConfiguration.getParentConfiguration().shouldAskForSurveyId()) { + + } + else { + setInstructions(roundConfiguration.getWelcomeInstructions()); + } } // don't display next round time, instead wait for the // facilitator signal. @@ -816,6 +827,19 @@ public JPanel getPanel() { return mainPanel; } + + public JPanel getSurveyIdPanel() { + if (surveyIdPanel == null) { + surveyIdPanel = new JPanel(); + surveyIdPanel.setName(SURVEY_ID_PANEL_NAME); + } + return surveyIdPanel; + } + + @Override + public void dispose() { + // no-op, nothing to dispose. + } @Override public void requestFocusInWindow() { --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round0.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="resource-width">13</entry> +<entry key="resource-depth">13</entry> +<entry key="practice-round">true</entry> +<entry key="private-property">true</entry> +<entry key="duration">240</entry> + +<entry key="quiz">true</entry> +<entry key="q1">C</entry> +<entry key="q2">B</entry> + +<entry key='instructions'> +<![CDATA[ +<h2>Practice Round Instructions</h2> +<hr> +<p> +You will now have four minutes to practice with the experimental environment. The +decisions you make in this round will NOT influence your earnings. At the beginning +of the practice round half of the cells are occupied with green tokens. The +environment is a 13 x 13 grid of cells. +</p> +<p> +During this practice round, and <b>only during</b> this practice round, you are able +to reset the tokens displayed on the screen by pressing the <b>R</b> key. When you +press the <b>R</b> key you will reset the resource to its initial distribution, +randomly filling half of the cells. +</p> +<p>If you have any questions please raise your hand. <b>Do you have any questions so far?</b></p> +]]> +</entry> + +<entry key="quiz-instructions"> +<![CDATA[ +<h2>Quiz</h2> +<hr> +<p> +Before we begin the practice round please answer the following questions. You will earn $0.50 for each correct answer. +</p> +<br><br> +<form> +<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> +<input type="submit" name="submit" value="Submit"><br> +</form> +]]> +</entry> +<entry key='q1-explanation'> + <![CDATA[ + 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[ + Tokens cannot regenerate on an empty screen as shown in sequence B. + ]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round1.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 1 Instructions</h3> +<hr> +<p> +This is the first round of the experiment. The length of the round is 4 +minutes. As in the practice round you can collect green tokens but now +you will earn <b>two cents</b> for each token collected. You <b>cannot</b> +reset the distribution of green tokens. +</p> +<p> +In this round the renewable resource will become five times bigger. You will share this +larger environment with four other players in this room that have been randomly +selected. Each group's resource environment is distinct from the other groups. +</p> +<p> +Each of you has been assigned a number from 1 to 5. These numbers will remain the +same throughout the experiment but you will <b>not</b> be able to identify which +person in the room has been assigned which number, so your anonymity is guaranteed. +</p> + +<p> +The other four players will appear on the screen as blue dots +<img src="@CODEBASE_URL@/images/gem-other.gif"> with a white +number embedded in the dot. On the top right corner of the screen you can see +how many tokens each player has collected. On the top left corner of the screen you can see +a clock that displays the remaining time in the round.</p> +<p>Since you can only see the resource within your vision you may neither see all +the other participants nor all the resource units. The figure below indicates the +vision range compared to the whole environment</p> +<img src="@CODEBASE_URL@/images/vision-range.jpg"> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +window. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round2.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + + +<!-- enable field of vision for tokens and subjects --> +<entry key='initial-distribution'>.25</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 2 Instructions</h3> +<hr> +<p> +Round 2 is the same as round 1. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round3.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- resource regrowth parameters --> +<entry key="initial-distribution">.25</entry> + + +<entry key="instructions"> +<![CDATA[ +<h3>Round 3 Instructions</h3> +<hr> +<p> +Round 3 is the same as round 2. Except now the resources move. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round4.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">4</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="initial-distribution">.25</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<hr> +<p> + Round 4 is the same as the previous rounds with one exception. You will be able + to communicate with the other participants in your group <b>during</b> the + round. To communicate, hit the enter key, type uour message, and then hit the + enter key again. You must hit the enter key before every message you type, + otherwise control will return to the game screen where you can use the arrow + keys to move around. +</p> + +<p> +The length of this round is four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/indiana-experiments/fall-2011/pretest/round5.xml Wed Sep 28 18:03:07 2011 -0700 @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration... [truncated message content] |
From: Bitbucket <com...@bi...> - 2011-09-29 01:02:09
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/a9ef43ee4298/ changeset: a9ef43ee4298 user: alllee date: 2011-09-29 03:01:58 summary: adding netbeans generated form for survey id panel ui components affected #: 2 files (-1 bytes) 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. |
From: Bitbucket <com...@bi...> - 2011-09-24 01:01:54
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/d5a8038be1d8/ changeset: d5a8038be1d8 user: alllee date: 2011-09-24 03:01:40 summary: refactoring group formation and round logic / workflow. still some issues to work out, namely when group formation should actually occur. affected #: 5 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 22 08:14:50 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Fri Sep 23 18:01:40 2011 -0700 @@ -3,6 +3,7 @@ import java.awt.Dimension; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -632,5 +633,11 @@ public double getQuizCorrectAnswerReward() { return getDoubleProperty("quiz-correct-answer-reward", getParentConfiguration().getQuizCorrectAnswerReward()); } + + @Override + public String toString() { + List<RoundConfiguration> allParameters = getParentConfiguration().getAllParameters(); + return String.format("Round %d of %d -- %s", allParameters.indexOf(this) + 1, allParameters.size(), getProperties()); + } } --- a/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Thu Sep 22 08:14:50 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Fri Sep 23 18:01:40 2011 -0700 @@ -11,12 +11,12 @@ import edu.asu.commons.event.ConfigurationEvent; import edu.asu.commons.event.EndRoundRequest; import edu.asu.commons.event.EventTypeProcessor; +import edu.asu.commons.event.FacilitatorMessageEvent; import edu.asu.commons.event.SetConfigurationEvent; import edu.asu.commons.facilitator.BaseFacilitator; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.conf.ServerConfiguration; import edu.asu.commons.foraging.event.BeginChatRoundRequest; -import edu.asu.commons.foraging.event.FacilitatorCensoredChatRequest; import edu.asu.commons.foraging.event.FacilitatorEndRoundEvent; import edu.asu.commons.foraging.event.FacilitatorSanctionUpdateEvent; import edu.asu.commons.foraging.event.FacilitatorUpdateEvent; @@ -76,6 +76,11 @@ facilitatorWindow.updateDebriefing(event); } }); + addEventProcessor(new EventTypeProcessor<FacilitatorMessageEvent>(FacilitatorMessageEvent.class) { + public void handle(FacilitatorMessageEvent event) { + facilitatorWindow.addMessage(event.getMessage()); + } + }); addEventProcessor(new EventTypeProcessor<QuizCompletedEvent>(QuizCompletedEvent.class) { public void handle(QuizCompletedEvent event) { facilitatorWindow.quizCompleted(event); --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Thu Sep 22 08:14:50 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Fri Sep 23 18:01:40 2011 -0700 @@ -213,7 +213,9 @@ } JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, informationScrollPane, messagePanel); add(splitPane, BorderLayout.CENTER); - splitPane.setDividerLocation(0.3d); + double proportion = 0.6d; + splitPane.setDividerLocation(proportion); + splitPane.setResizeWeight(proportion); } private void setInstructions(String contents) { --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 22 08:14:50 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 23 18:01:40 2011 -0700 @@ -22,6 +22,7 @@ import edu.asu.commons.event.ClientMessageEvent; import edu.asu.commons.event.EndRoundRequest; import edu.asu.commons.event.EventTypeProcessor; +import edu.asu.commons.event.FacilitatorMessageEvent; import edu.asu.commons.event.FacilitatorRegistrationRequest; import edu.asu.commons.event.RoundStartedMarkerEvent; import edu.asu.commons.event.SetConfigurationEvent; @@ -183,7 +184,7 @@ protected StateMachine getStateMachine() { return stateMachine; } - + private RoundConfiguration getCurrentRoundConfiguration() { return getConfiguration().getCurrentParameters(); } @@ -213,6 +214,7 @@ initializeFacilitatorHandlers(); } + // FIXME: remove this as we phase out the 3d environment private void initializeRoundProcessor() { if (serverDataModel.getRoundConfiguration().is2dExperiment()) { roundProcessor = new Command() { @@ -302,10 +304,10 @@ ClientData clientData = clients.get(event.getId()); clientData.addCorrectQuizAnswers(event.getNumberOfCorrectAnswers()); if (numberOfSubmittedQuizzes >= clients.size()) { - // we're done, notify the sleeping queue. + // we're done, notify the quizSignal logger.info("Received all quizzes, notifying quiz signal"); + transmit(new FacilitatorMessageEvent(facilitatorId, "Received all quizzes, ready to start round.")); Utils.notify(quizSignal); - numberOfSubmittedQuizzes = 0; } } @@ -478,78 +480,6 @@ default: logger.severe("tried to sanction with EnforcementMechanism.NONE"); } - - // TODO: reimplement - // - // - // int srcEnforcementType = sourceClient.getEnforcementData().getResultIndex(); - // int tgtEnforcementType = targetClient.getEnforcementData().getResultIndex(); - // - // if(srcEnforcementType == tgtEnforcementType) { - // System.out.println("This condition should be always true"); - // switch(srcEnforcementType) { - // /* - // * No sanctioning just harvest - // */ case NO_SANCTIONS: - // System.out.println("This code should never be reached"); - // - // break; - // - // /* - // * Harvest and sanction - // * Reduce other by 2 but also own by 1 - // */ - // case HARVEST_WITH_SANCTION: - // sourceClient.sanctionCost(); - // targetClient.monitorSanctionPenalty(1); - // // add sanction request to the target client so they can figure out who just sanctioned them - // targetClient.getLatestSanctions().add(request); - // transmit(new ClientMessageEvent(sourceClient.getId(), - // String.format("Subtracting %d tokens from # %d at the cost of %d to yourself." , - // getCurrentRoundConfiguration().getSanctionPenalty(1), - // targetClient.getAssignedNumber(), - // getCurrentRoundConfiguration().getSanctionCost()))); - // transmit(new ClientMessageEvent(targetClient.getId(), - // String.format("# %d subtracted %d tokens from you.", sourceClient.getAssignedNumber(), getCurrentRoundConfiguration().getSanctionPenalty(1)))); - // break; - // - // - // /* - // * One participant is a moniter who sanctions but cannot harvest - // * Moniter can give penalty by subtract 1 from sanctionee - // * Nothing taken from Moniter but receives 25% tokens from each - // */ case RANDOM_SANCTIONER: - // //sourceClient.sanctionCost(); - // targetClient.monitorSanctionPenalty(0); - // // add sanction request to the target client so they can figure out who just sanctioned them - // targetClient.getLatestSanctions().add(request); - // transmit(new ClientMessageEvent(sourceClient.getId(), - // String.format("Subtracting %d tokens from # %d at the cost of 0 to yourself." , - // getCurrentRoundConfiguration().getSanctionPenalty(0), - // targetClient.getAssignedNumber()))); - // transmit(new ClientMessageEvent(targetClient.getId(), - // String.format("# %d subtracted %d tokens from you.", sourceClient.getAssignedNumber(), getCurrentRoundConfiguration().getSanctionPenalty(0)))); - // break; - // - // /* - // * Harvest and sanction for 48 secs in sequence - // * One participant is a moniter who sanctions but cannot harvest - // * Moniter can give penalty by subtract 1 from sanctionee - // * Nothing taken from Moniter but receives 25% tokens from each - // */ case CIRCULAR_MONITERING: - // //sourceClient.sanctionCost(); - // targetClient.monitorSanctionPenalty(0); - // // add sanction request to the target client so they can figure out who just sanctioned them - // targetClient.getLatestSanctions().add(request); - // transmit(new ClientMessageEvent(sourceClient.getId(), - // String.format("Subtracting %d tokens from # %d at the cost of 0 to yourself." , - // getCurrentRoundConfiguration().getSanctionPenalty(), - // targetClient.getAssignedNumber()))); - // transmit(new ClientMessageEvent(targetClient.getId(), - // String.format("# %d subtracted %d tokens from you.", sourceClient.getAssignedNumber(), getCurrentRoundConfiguration().getSanctionPenalty()))); - // break; - // } - // } } private void handleRealTimeSanctionRequest(RealTimeSanctionRequest request) { @@ -642,17 +572,16 @@ addEventProcessor(new EventTypeProcessor<BeginRoundRequest>(BeginRoundRequest.class) { public void handle(BeginRoundRequest event) { if (event.getId().equals(facilitatorId)) { - if (getCurrentRoundConfiguration().isFirstRound()) { - // shuffle groups - // set up the Client Group relationships ONLY IF we are in the first round... - // kind of a hack. - shuffleParticipants(); - initializeResourceDispenser(); + if (isReadyToStartRound()) { + logger.info("Begin round request from facilitator - starting round."); + experimentStarted = true; + Utils.notify(roundSignal); + System.out.println("Notified round signal"); } - logger.info("Begin round request from facilitator - starting round."); - experimentStarted = true; - Utils.notify(roundSignal); - System.out.println("Notified round signal"); + else { + transmit(new FacilitatorMessageEvent(facilitatorId, + String.format("Couldn't start round, waiting on %d of %d quizzes", numberOfSubmittedQuizzes, clients.size()))); + } } else { logger.warning("Ignoring begin round request from id: " + event.getId()); @@ -708,12 +637,13 @@ public void handle(BeginChatRoundRequest request) { if (getCurrentRoundConfiguration().isChatEnabled()) { // FIXME: need to handle properly corner case where chat is enabled before the first round - // at that point the clients haven't been added to any groups yet. - // probably the best way to handle this is to have the clients added - // to groups when the show instructions request is handled. + // - at that point the clients haven't been added to any groups yet. + // another way to handle this is to have the clients added + // to groups when the show instructions request is handled.. + initializeGroups(); + /* if (getCurrentRoundConfiguration().isFirstRound()) { shuffleParticipants(); - initializeResourceDispenser(); } for (Map.Entry<Identifier, ClientData> entry : clients.entrySet()) { @@ -734,12 +664,20 @@ // just store communication traffic in a separate text file. } + */ } } }); // FIXME: handle reconfiguration requests from facilitator } + protected boolean isReadyToStartRound() { + if (getCurrentRoundConfiguration().isQuizEnabled()) { + return numberOfSubmittedQuizzes >= clients.size(); + } + return true; + } + private void relayChatRequest(ChatRequest request) { Identifier source = request.getSource(); Identifier target = request.getTarget(); @@ -795,19 +733,27 @@ Utils.sleep(SERVER_SLEEP_INTERVAL); break; case WAITING: + // FIXME: there is an inherent nastiness going on with this model of control flow + // the problem is this: when we first spin up the server, there are no connected clients. control flow + // enters here, we initialize the round (with no participants, etc.) and then wait on the quiz signal + + // the issue is that we need to initialize the groups at some clear, well-defined time. + // we have to do it after all the clients are connected, so perhaps showInstructions can be the time to do it? + // the previous way which I've been slowly refactoring was to do it on the beginning of the first round (as a special case) + // in the handler for BeginRoundRequest) and to do it at the end of every round. Probably better to do it in round initialization + // initialize persister first so we store all relevant events. // persister MUST be initialized early so that we store pre-round events like QuizResponseEvent, ChatEvent, and the various Ranking // requests. - initializeRound(); - - getLogger().info("Round is initialized: now waiting for facilitator signal to start next round."); + persister.initialize(getCurrentRoundConfiguration()); + getLogger().info("Initialized persister, waiting for facilitator signal to start next round."); if (getCurrentRoundConfiguration().isQuizEnabled()) { getLogger().info("Waiting for all quizzes to be submitted."); Utils.waitOn(quizSignal); } // then wait for the signal from the facilitator to actually start the round (a chat session might occur or a voting session). Utils.waitOn(roundSignal); - // actually start the round once we receive the facilitator signal. + startRound(); break; default: @@ -933,6 +879,7 @@ } private void cleanupRound() { + numberOfSubmittedQuizzes = 0; serverDataModel.cleanupRound(); for (ClientData clientData : clients.values()) { clientData.reset(); @@ -945,17 +892,9 @@ serverState = ServerState.WAITING; return; } - RoundConfiguration currentRoundConfiguration = getCurrentRoundConfiguration(); RoundConfiguration nextRoundConfiguration = getConfiguration().nextRound(); serverDataModel.setRoundConfiguration(nextRoundConfiguration); initializeRoundProcessor(); - // reset the group linkages - if (shouldShuffleParticipants(currentRoundConfiguration, nextRoundConfiguration)) { - shuffleParticipants(); - } - else { - initializeClientPositions(); - } logger.info("Advancing to round # " + getConfiguration().getCurrentRoundNumber()); // send the next round configuration to each client for (Identifier id : clients.keySet()) { @@ -964,14 +903,16 @@ transmit(new SetConfigurationEvent<RoundConfiguration>(facilitatorId, nextRoundConfiguration)); } - private boolean shouldShuffleParticipants(RoundConfiguration currentRoundConfiguration, RoundConfiguration nextRoundConfiguration) { + private boolean shouldShuffleParticipants() { + RoundConfiguration currentRoundConfiguration = getCurrentRoundConfiguration(); + RoundConfiguration previousRoundConfiguration = getConfiguration().getPreviousRoundConfiguration(); // when do we _have_ to shuffle participants? // 1. when randomize-groups is set for the next round // 2. when we move from a private property round to a open access round // 3. in general, when the clients per group in the current round is different from the // clients per group in the next round (FIXME: is this too broad or can #2 just be a special case of this?) - return nextRoundConfiguration.shouldRandomizeGroup() - || (currentRoundConfiguration.getClientsPerGroup() != nextRoundConfiguration.getClientsPerGroup()); + return currentRoundConfiguration.shouldRandomizeGroup() + || (previousRoundConfiguration.getClientsPerGroup() != currentRoundConfiguration.getClientsPerGroup()); } private void shuffleParticipants() { @@ -993,13 +934,19 @@ clientData.initializePosition(); } } - - private void initializeRound() { - persister.initialize(getCurrentRoundConfiguration()); - initializeResourceDispenser(); - } - - private void initializeResourceDispenser() { + + private void initializeGroups() { + // reset group linkages if necessary + if (shouldShuffleParticipants()) { + logger.info("Shuffling participants"); + shuffleParticipants(); + } + else { + logger.info("Didn't need to shuffle participants : " + getCurrentRoundConfiguration()); + // shuffleParticipants automatically initializes the client positions + // if we don't shuffle, we need to manually re-initialize them. + initializeClientPositions(); + } // set up the resource dispenser, generates the initial resource distributions for the // groups, must be done after creating the client group relationships. resourceDispenser.initialize(); @@ -1007,6 +954,10 @@ private void startRound() { RoundConfiguration roundConfiguration = getCurrentRoundConfiguration(); + // actually start the round once we receive the facilitator signal. + getLogger().info("Initializing groups."); + // FIXME: what if we want groups before the round actually begins..? + initializeGroups(); // send RoundStartedEvents to all connected clients for (Map.Entry<Identifier, ClientData> entry : clients.entrySet()) { Identifier id = entry.getKey(); --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Thu Sep 22 08:14:50 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Fri Sep 23 18:01:40 2011 -0700 @@ -15,17 +15,18 @@ <entry key="number-of-rounds">7</entry><entry key="facilitator-instructions"><![CDATA[ -<h2>Facilitator Instructions</h2> -<hr><p> This facilitator interface allows you to control the experiment. In general you - will be invoking this sequence: - + will be following a sequence similar to this: <ol><li>Show instructions</li><li>Start round</li> - <li>Show trust game as necessary</li> - <li>Start standalone chat round, as necessary</li> + <li>After round is over + <ol> + <li>show trust game if necessary</li> + <li>start standalone chat round if necessary</li> + </ol> + </li><li>Goto 1.</li></ol></p> 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. |
From: Bitbucket <com...@bi...> - 2011-09-22 15:14:57
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/f075adea9872/ changeset: f075adea9872 user: alllee date: 2011-09-22 17:14:50 summary: trust game submission wrapper event affected #: 2 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Thu Sep 22 03:50:16 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Thu Sep 22 08:14:50 2011 -0700 @@ -575,6 +575,7 @@ // has begun. update(configuration.getRoundDuration().getTimeLeft()); if (configuration.isInRoundChatEnabled()) { + System.err.println("in round chat was enabled"); ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(dataModel); Dimension chatPanelSize = new Dimension(250, getPanel().getSize().height); @@ -582,9 +583,6 @@ // FIXME: switch to different layout manager gamePanel.add(chatPanel, BorderLayout.EAST); } - else { - gamePanel.remove(getChatPanel()); - } showPanel(GAME_PANEL_NAME); } }; @@ -771,6 +769,10 @@ public void endRound(final EndRoundEvent event) { Runnable runnable = new Runnable() { public void run() { + if (chatPanel != null) { + getPanel().remove(chatPanel); + chatPanel = null; + } if (dataModel.getRoundConfiguration().isPostRoundSanctioningEnabled()) { // add sanctioning text and slap the PostRoundSanctioningPanel in PostRoundSanctioningPanel panel = new PostRoundSanctioningPanel(event, dataModel.getRoundConfiguration(), client); @@ -782,14 +784,8 @@ instructionsEditorPane.setText("Waiting for updated round totals from the server..."); switchInstructionsPane(); } - if (chatPanel != null) { - // FIXME: figure out what to do here. - getPanel().remove(chatPanel); - chatPanel = null; - } // generate debriefing text from data culled from the Event addDebriefingText(event); - // messageTextPane.setText(""); } }; try { 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. |
From: Bitbucket <com...@bi...> - 2011-09-22 10:50:27
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/97c10fcf5dbb/ changeset: 97c10fcf5dbb user: alllee date: 2011-09-22 12:50:16 summary: more ui/ux refactoring, working on improvements to the facilitator interface to receive more updates on what's going on in the experiment and to provide hints to the facilitator about what to do next. affected #: 22 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Thu Sep 22 03:50:16 2011 -0700 @@ -121,12 +121,6 @@ return gameWindow3D; } } - - public static void addStyles(JEditorPane editorPane, int fontSize) { - Font font = UIManager.getFont("Label.font"); - String bodyRule = String.format("body { font-family: %s; font-size: %s pt; }", font.getFamily(), fontSize); - ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); - } public void sendAvatarInfo(boolean male, Color hairColor, Color skinColor, Color shirtColor, Color trouserColor, Color shoesColor) { transmit(new AgentInfoRequest(getId(), male, hairColor, skinColor, shirtColor, trouserColor, shoesColor)); @@ -444,5 +438,7 @@ public void sendTrustGameSubmissionRequest(double playerOneAmountToKeep, double[] playerTwoAmountsToKeep) { transmit(new TrustGameSubmissionRequest(getId(), playerOneAmountToKeep, playerTwoAmountsToKeep)); + // switch back to instructions window + getGameWindow2D().trustGameSubmit(); } } --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Thu Sep 22 03:50:16 2011 -0700 @@ -421,10 +421,14 @@ public int getResourceWorldScale() { return getIntProperty("resource-scale", 32); } + + public boolean isChatRoundEnabled() { + return getBooleanProperty("chat-enabled"); + } // Should always return true for 3d experiments public boolean isChatEnabled() { - return getBooleanProperty("chat-enabled") || isInRoundChatEnabled(); + return isChatRoundEnabled() || isInRoundChatEnabled(); } public int getMaximumResourceAge() { @@ -521,8 +525,11 @@ return getBooleanProperty("censored-chat-enabled", false); } + /** + * Returns true if we should run a trust game before this round actually begins. + */ public boolean isTrustGameEnabled() { - return getBooleanProperty("post-round-trust-game", false); + return getBooleanProperty("trust-game", false); } public boolean isInRoundChatEnabled() { @@ -623,8 +630,7 @@ } public double getQuizCorrectAnswerReward() { - String key = "quiz-correct-answer-reward"; - return getDoubleProperty(key, getParentConfiguration().getDoubleProperty(key)); + return getDoubleProperty("quiz-correct-answer-reward", getParentConfiguration().getQuizCorrectAnswerReward()); } } --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Thu Sep 22 03:50:16 2011 -0700 @@ -46,6 +46,10 @@ return assistant.getBooleanProperty("update-facilitator", false); } + public boolean isCensoredChat() { + return assistant.getBooleanProperty("censored-chat", false); + } + public boolean shouldInitialize3D() { for (RoundConfiguration configuration : getAllParameters()) { if (configuration.is3dExperiment()) { --- a/src/main/java/edu/asu/commons/foraging/event/QuizCompletedEvent.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/QuizCompletedEvent.java Thu Sep 22 03:50:16 2011 -0700 @@ -14,9 +14,16 @@ public class QuizCompletedEvent extends AbstractEvent { private static final long serialVersionUID = -4620951150514838395L; + + private QuizResponseEvent response; - public QuizCompletedEvent(Identifier id) { + public QuizCompletedEvent(Identifier id, QuizResponseEvent response) { super(id); + this.response = response; } + + public String toString() { + return String.format("quiz completed event: %s", response); + } } --- a/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Thu Sep 22 03:50:16 2011 -0700 @@ -23,6 +23,7 @@ import edu.asu.commons.foraging.event.QuizCompletedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; +import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.model.ServerDataModel; /** @@ -65,22 +66,24 @@ } }); addEventProcessor(new EventTypeProcessor<FacilitatorEndRoundEvent>(FacilitatorEndRoundEvent.class) { - public void handle(FacilitatorEndRoundEvent event) { serverDataModel = null; facilitatorWindow.endRound(event); } }); addEventProcessor(new EventTypeProcessor<FacilitatorSanctionUpdateEvent>(FacilitatorSanctionUpdateEvent.class) { - public void handle(FacilitatorSanctionUpdateEvent event) { facilitatorWindow.updateDebriefing(event); } }); addEventProcessor(new EventTypeProcessor<QuizCompletedEvent>(QuizCompletedEvent.class) { - public void handle(QuizCompletedEvent event) { - facilitatorWindow.quizCompleted(); + facilitatorWindow.quizCompleted(event); + } + }); + addEventProcessor(new EventTypeProcessor<TrustGameSubmissionEvent>(TrustGameSubmissionEvent.class) { + public void handle(TrustGameSubmissionEvent event) { + facilitatorWindow.trustGameSubmitted(event); } }); @@ -98,46 +101,46 @@ } } -// public void accept(Identifier id, Object event) { -// if (event instanceof ConfigurationEvent) { -// ConfigurationEvent configEvent = (ConfigurationEvent) event; -// setConfiguration(configEvent.getConfiguration()); -// } -// else if (event instanceof ServerGameStateEvent) { -// ServerGameStateEvent serverGameStateEvent = (ServerGameStateEvent) event; -// if (!stopExperiment) { -// -// if (serverGameState == null) { -// System.err.println("about to display game.."); -// experimentRunning = true; -// // FIXME: could use configuration from this event... serverGameStateEvent.getServerGameState().getConfiguration(); -// serverGameState = serverGameStateEvent.getServerGameState(); -// facilitatorWindow.displayGame(); -// } -// else { -// // synchronous updates -// serverGameState = serverGameStateEvent.getServerGameState(); -// } -// } -// facilitatorWindow.updateWindow(serverGameStateEvent.getTimeLeft()); -//// facilitatorWindow.repaint(); -// } -// else if (event instanceof FacilitatorEndRoundEvent) { -// FacilitatorEndRoundEvent endRoundEvent = (FacilitatorEndRoundEvent) event; -// serverGameState = null; -// facilitatorWindow.endRound(endRoundEvent); -// } -// else if (event instanceof FacilitatorSanctionUpdateEvent) { -// FacilitatorSanctionUpdateEvent fdue = (FacilitatorSanctionUpdateEvent) event; -// facilitatorWindow.updateDebriefing(fdue); -// } -// else if (event instanceof QuizCompletedEvent) { -// facilitatorWindow.quizCompleted(); -// } -// } + // public void accept(Identifier id, Object event) { + // if (event instanceof ConfigurationEvent) { + // ConfigurationEvent configEvent = (ConfigurationEvent) event; + // setConfiguration(configEvent.getConfiguration()); + // } + // else if (event instanceof ServerGameStateEvent) { + // ServerGameStateEvent serverGameStateEvent = (ServerGameStateEvent) event; + // if (!stopExperiment) { + // + // if (serverGameState == null) { + // System.err.println("about to display game.."); + // experimentRunning = true; + // // FIXME: could use configuration from this event... serverGameStateEvent.getServerGameState().getConfiguration(); + // serverGameState = serverGameStateEvent.getServerGameState(); + // facilitatorWindow.displayGame(); + // } + // else { + // // synchronous updates + // serverGameState = serverGameStateEvent.getServerGameState(); + // } + // } + // facilitatorWindow.updateWindow(serverGameStateEvent.getTimeLeft()); + // // facilitatorWindow.repaint(); + // } + // else if (event instanceof FacilitatorEndRoundEvent) { + // FacilitatorEndRoundEvent endRoundEvent = (FacilitatorEndRoundEvent) event; + // serverGameState = null; + // facilitatorWindow.endRound(endRoundEvent); + // } + // else if (event instanceof FacilitatorSanctionUpdateEvent) { + // FacilitatorSanctionUpdateEvent fdue = (FacilitatorSanctionUpdateEvent) event; + // facilitatorWindow.updateDebriefing(fdue); + // } + // else if (event instanceof QuizCompletedEvent) { + // facilitatorWindow.quizCompleted(); + // } + // } /* - * Send a request to server to start an experiment + * Send a request to server to start an experiment */ public void sendBeginExperimentRequest() { transmit(new BeginExperimentRequest(getId())); @@ -149,11 +152,12 @@ */ public void sendShowInstructionsRequest() { transmit(new ShowInstructionsRequest(getId())); - } - + } + void sendShowTrustGameRequest() { transmit(new ShowTrustGameRequest(getId())); } + /* * Send a request to start a round */ @@ -167,11 +171,11 @@ } public void endExperiment() { -// configuration.resetRoundConfiguration(); -// serverGameState = null; -// stopExperiment = true; -// experimentRunning = false; -// facilitatorWindow.updateMenuItems(); + // configuration.resetRoundConfiguration(); + // serverGameState = null; + // stopExperiment = true; + // experimentRunning = false; + // facilitatorWindow.updateMenuItems(); } /* @@ -223,7 +227,7 @@ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(facilitator.getFacilitatorWindow()); frame.setJMenuBar(facilitator.getFacilitatorWindow().getMenuBar()); -// frame.pack(); + // frame.pack(); frame.setVisible(true); } }; --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Thu Sep 22 03:50:16 2011 -0700 @@ -1,18 +1,15 @@ package edu.asu.commons.foraging.facilitator; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Dimension; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeSet; -import javax.swing.Box; -import javax.swing.BoxLayout; import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JMenu; @@ -22,14 +19,18 @@ import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.ScrollPaneConstants; +import javax.swing.text.BadLocationException; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.conf.ServerConfiguration; import edu.asu.commons.foraging.event.FacilitatorEndRoundEvent; import edu.asu.commons.foraging.event.FacilitatorSanctionUpdateEvent; +import edu.asu.commons.foraging.event.QuizCompletedEvent; +import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.model.ClientData; -import edu.asu.commons.foraging.model.GroupDataModel; +import edu.asu.commons.foraging.ui.ForagingInterface; import edu.asu.commons.net.Identifier; +import edu.asu.commons.util.HtmlEditorPane; @@ -41,25 +42,12 @@ private FacilitatorChatPanel facilitatorChatPanel; - // private JFrame frame; - private Dimension windowDimension; - private JScrollPane informationScrollPane; private JEditorPane informationEditorPane; - private JScrollPane viewPane; - private JLabel timeLeftLabel; - private JLabel messageLabel; - - private JPanel informationPanel; - - private Dimension groupViewDimension = new Dimension(400, 400); - - private int viewSpacing = 50; - private JMenuItem showInstructionsMenuItem; private JMenuItem startRoundMenuItem; @@ -75,9 +63,14 @@ private JMenuItem startChatMenuItem; private JMenuItem showTrustGameMenuItem; + private HtmlEditorPane messageEditorPane; + + private StringBuilder instructionsBuilder; + + private int completedTrustGames; + public FacilitatorWindow(Dimension dimension, Facilitator facilitator) { this.facilitator = facilitator; - windowDimension = dimension; initGuiComponents(); createMenu(); // FIXME: only applicable for standalone java app version - also @@ -106,12 +99,10 @@ * This method gets called at the start of each round including start of the experiment */ public void displayGame() { - // switchCenterComponent(informationPanel, viewPane); + startChatMenuItem.setEnabled(false); showInstructionsMenuItem.setEnabled(false); startRoundMenuItem.setEnabled(false); stopRoundMenuItem.setEnabled(true); - // initViewPanel(); - // repaint(); } private JMenuBar createMenu() { @@ -134,6 +125,7 @@ showInstructionsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { facilitator.sendShowInstructionsRequest(); + addMessage("Instructions have been shown."); startRoundMenuItem.setEnabled(true); } }); @@ -189,103 +181,39 @@ return menuBar; } private void initGuiComponents() { - setLayout(new BorderLayout(4, 4)); + setLayout(new BorderLayout(3, 3)); // setBackground(Color.WHITE); - informationEditorPane = new JEditorPane("text/html", - "CSAN Facilitator Instructions"); - informationEditorPane.setPreferredSize(new Dimension(400, 400)); - informationEditorPane.setEditable(false); - - facilitatorChatPanel = new FacilitatorChatPanel(facilitator); + informationEditorPane = ForagingInterface.createInstructionsEditorPane(); - JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - + + informationScrollPane = new JScrollPane(informationEditorPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - informationPanel = new JPanel(new BorderLayout()); - messageLabel = new JLabel("Messages"); - informationPanel.add(messageLabel, BorderLayout.NORTH); - informationPanel.add(informationScrollPane, BorderLayout.CENTER); - setInstructions(facilitator.getServerConfiguration().getFacilitatorInstructions()); - viewPane = new JScrollPane(); - Dimension minimumSize = new Dimension(200, 200); - informationPanel.setMinimumSize(minimumSize); - splitPane.add(informationPanel); - splitPane.add(facilitatorChatPanel.getComponent()); + JPanel messagePanel = new JPanel(new BorderLayout()); + JLabel messagePanelLabel = new JLabel("System messages"); + messagePanelLabel.setFont(ForagingInterface.DEFAULT_FONT_PLAIN); + messagePanel.add(messagePanelLabel, BorderLayout.NORTH); + Dimension minimumSize = new Dimension(600, 200); + messagePanel.setMinimumSize(minimumSize); + informationScrollPane.setMinimumSize(minimumSize); + + if (facilitator.getServerConfiguration().isCensoredChat()) { + facilitatorChatPanel = new FacilitatorChatPanel(facilitator); + messagePanel.add(facilitatorChatPanel.getComponent(), BorderLayout.CENTER); + } + else { + messageEditorPane = ForagingInterface.createInstructionsEditorPane(); + JScrollPane messageScrollPane = new JScrollPane(messageEditorPane); + messagePanel.add(messageScrollPane, BorderLayout.CENTER); + } + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, informationScrollPane, messagePanel); add(splitPane, BorderLayout.CENTER); - } - - public void initViewPanel() { - RoundConfiguration roundConfiguration = facilitator.getCurrentRoundConfiguration(); - System.err.println("round configuration: " + roundConfiguration); - viewPane.getViewport().removeAll(); - - JPanel labelPanel = new JPanel(); - labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS)); - timeLeftLabel = new JLabel("Round has not begun yet."); - labelPanel.add(new JLabel("Round " - + facilitator.getServerConfiguration().getCurrentRoundNumber() - + " ")); - labelPanel.add(timeLeftLabel); - - JPanel gridPanel = new JPanel(); - gridPanel.setForeground(Color.BLACK); - //Display group views based on the window size, group view size and no. of groups - Set<GroupDataModel> groups = facilitator.getServerGameState().getGroups(); - System.out.println("# of groups: " + groups.size()); - int cols = windowDimension.width / (groupViewDimension.width + viewSpacing); - int rows = 1; - if (cols != 0) { - rows = groups.size() / cols; - if ((groups.size() % cols) > 0) - ++rows; - } - gridPanel.setLayout(new GridLayout(rows, cols)); - System.out.println("Rows = " + rows + " Cols = " + cols); - - int groupCounter = 1; - for (GroupDataModel group : groups) { - JPanel groupPanel = new JPanel(new BorderLayout(4, 4)); - GroupView groupView = new GroupView(groupViewDimension, group); - groupView.setup(roundConfiguration); - - JPanel groupViewPanel = new JPanel(); - // groupViewPanel.setBackground(Color.blue); - groupViewPanel.setLayout(new BoxLayout(groupViewPanel, - BoxLayout.Y_AXIS)); - JLabel label = new JLabel("Group " + groupCounter, JLabel.CENTER); - // label.setBackground(Color.RED); - groupViewPanel.add(label); - groupViewPanel.add(groupView); - - groupPanel.add(groupViewPanel, BorderLayout.CENTER); - - Dimension horizFillerDim = new Dimension(groupViewDimension.width - + viewSpacing, viewSpacing / 2); - Dimension vertFillerDim = new Dimension(viewSpacing / 2, - groupViewDimension.height + viewSpacing); - Box.Filler horizontalFiller = new Box.Filler(horizFillerDim, - horizFillerDim, horizFillerDim); - Box.Filler verticalFiller = new Box.Filler(vertFillerDim, - vertFillerDim, vertFillerDim); - groupPanel.add(verticalFiller, BorderLayout.EAST); - groupPanel.add(verticalFiller, BorderLayout.WEST); - groupPanel.add(horizontalFiller, BorderLayout.SOUTH); - groupPanel.add(horizontalFiller, BorderLayout.NORTH); - - gridPanel.add(groupPanel); - ++groupCounter; - } - JPanel viewPanel = new JPanel(); - viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.Y_AXIS)); - viewPanel.add(labelPanel); - viewPanel.add(gridPanel); - viewPane.getViewport().add(viewPanel); + splitPane.setDividerLocation(0.3d); } private void setInstructions(String contents) { @@ -299,98 +227,12 @@ return facilitator; } - public void updateMenuItems() { - startRoundMenuItem.setEnabled(false); - showInstructionsMenuItem.setEnabled(false); - } - - /* - private void centerOnScreen() { - Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension windowDimension = frame.getSize(); - int x = (screenDimension.width - windowDimension.width ) / 2; - int y = (screenDimension.height - windowDimension.height) / 2; - frame.setLocation(x, y); - } - */ - public void updateWindow(long timeLeft) { timeLeftLabel.setText("Time left: " + (timeLeft / 1000)); repaint(); } - - public void displayDebriefing(FacilitatorEndRoundEvent event) { - Map<Identifier, ClientData> clientDataMap = event.getClientDataMap(); - StringBuilder builder = new StringBuilder(); - builder.append(String.format("<h3>Round %d Results</h3>", facilitator.getCurrentRoundConfiguration().getRoundNumber())); - builder.append("<table><thead><th>Participant</th><th>Current tokens</th><th>Current Income</th><th>Total Income</th></thead><tbody>"); - TreeSet<Identifier> orderedSet = new TreeSet<Identifier>(clientDataMap.keySet()); - for (Identifier clientId : orderedSet) { - ClientData data = clientDataMap.get(clientId); - builder.append(String.format( - "<tr><td>%s</td>" + - "<td align='center'>%d</td>" + - "<td align='center'>$%3.2f</td>" + - "<td align='center'>$%3.2f</td></tr>", - clientId.toString(), - data.getCurrentTokens(), - getIncome(data.getCurrentTokens()), - getTotalIncome(data))); - } - builder.append("</tbody></table><hr>"); - if (event.isLastRound()) { - builder.append("<h2><font color='blue'>The experiment is over. Please prepare payments.</font></h2>"); - } - informationEditorPane.setText(builder.toString()); - // switchCenterComponent(viewPane, informationPanel); - //startRoundMenuItem.setEnabled(true); - showInstructionsMenuItem.setEnabled(true); - stopRoundMenuItem.setEnabled(false); - } - - private double getTotalIncome(ClientData data) { - ServerConfiguration serverConfiguration = facilitator.getServerConfiguration(); - double quizEarnings = data.getCorrectQuizAnswers() * serverConfiguration.getQuizCorrectAnswerReward(); - double trustGameEarnings = data.getTrustGameEarnings(); - double totalIncome = data.getTotalIncome() + serverConfiguration.getShowUpPayment() + quizEarnings + trustGameEarnings; - return totalIncome; - } - - private double getIncome(float numTokens) { - RoundConfiguration configuration = facilitator.getCurrentRoundConfiguration(); - if (configuration.isPracticeRound()) { - return 0.0f; - } - return configuration.getDollarsPerToken() * numTokens; - } - - public void endRound(FacilitatorEndRoundEvent endRoundEvent) { - displayDebriefing(endRoundEvent); - if (endRoundEvent.isLastRound()) { - facilitator.endExperiment(); - } - else { - // FIXME: get rid of - facilitator.getServerConfiguration().nextRound(); - } - completedQuizzes = 0; - messageLabel.setText("No messages"); - } - - public void configureForReplay() { - //Enable the replay menus - loadExperimentMenuItem.setEnabled(true); - - //Disable all other menus - startRoundMenuItem.setEnabled(false); - stopRoundMenuItem.setEnabled(false); - } - - public void quizCompleted() { - completedQuizzes++; - messageLabel.setText("Completed quizzes: " + completedQuizzes); - } - + + // FXIME: get rid of duplication here & displayDebriefing.. public void updateDebriefing(FacilitatorSanctionUpdateEvent event) { Map<Identifier, ClientData> clientDataMap = event.getClientDataMap(); StringBuilder buffer = new StringBuilder(); @@ -415,4 +257,120 @@ } informationEditorPane.setText(buffer.toString()); } + + public void displayDebriefing(FacilitatorEndRoundEvent event) { + Map<Identifier, ClientData> clientDataMap = event.getClientDataMap(); + // this is the round that was just played. + RoundConfiguration roundConfiguration = facilitator.getCurrentRoundConfiguration(); + instructionsBuilder = new StringBuilder(); + + instructionsBuilder.append(String.format("<h3>%s Results</h3>", roundConfiguration.isPracticeRound() ? "Practice round" : "Round " + roundConfiguration.getRoundNumber())); + List<String> headers = Arrays.asList("Participant", "Current tokens", "Current income", "Quiz earnings", "Trust game earnings", "Total income"); + instructionsBuilder.append("<table><thead>"); + for (String header : headers) { + instructionsBuilder.append("<th>").append(header).append("</th>"); + } + instructionsBuilder.append("</thead><tbody>"); + TreeSet<Identifier> orderedSet = new TreeSet<Identifier>(clientDataMap.keySet()); + for (Identifier clientId : orderedSet) { + ClientData data = clientDataMap.get(clientId); + instructionsBuilder.append(String.format( + "<tr><td>%s</td>" + + "<td align='center'>%d</td>" + + "<td align='center'>$%3.2f</td>" + + "<td align='center'>$%3.2f</td>" + + "<td align='center'>$%3.2f</td>" + + "<td align='center'>$%3.2f</td>" + + "</tr>", + clientId.toString(), + data.getCurrentTokens(), + getIncome(data.getCurrentTokens()), + getQuizEarnings(data), + data.getTrustGameEarnings(), + getTotalIncome(data))); + } + instructionsBuilder.append("</tbody></table><hr>"); + if (event.isLastRound()) { + instructionsBuilder.append("<h2><font color='blue'>The experiment is over. Please prepare payments.</font></h2>"); + } + + showInstructionsMenuItem.setEnabled(true); + stopRoundMenuItem.setEnabled(false); + } + + private double getTotalIncome(ClientData data) { + ServerConfiguration serverConfiguration = facilitator.getServerConfiguration(); + double quizEarnings = getQuizEarnings(data); + double trustGameEarnings = data.getTrustGameEarnings(); + return data.getTotalIncome() + serverConfiguration.getShowUpPayment() + quizEarnings + trustGameEarnings; + } + + private double getQuizEarnings(ClientData data) { + return data.getCorrectQuizAnswers() * facilitator.getServerConfiguration().getQuizCorrectAnswerReward(); + } + + private double getIncome(float numTokens) { + RoundConfiguration configuration = facilitator.getCurrentRoundConfiguration(); + if (configuration.isPracticeRound()) { + return 0.0f; + } + return configuration.getDollarsPerToken() * numTokens; + } + + public void endRound(FacilitatorEndRoundEvent endRoundEvent) { + displayDebriefing(endRoundEvent); + if (endRoundEvent.isLastRound()) { + facilitator.endExperiment(); + } + else { + // FIXME: doesn't allow for very first round to be chat-enabled or trust-game-enabled + RoundConfiguration roundConfiguration = facilitator.getServerConfiguration().nextRound(); + boolean showInstructionsNext = true; + if (roundConfiguration.isTrustGameEnabled()) { + showTrustGameMenuItem.setEnabled(true); + instructionsBuilder.append("<h2>TRUST GAME: Run a trust game next. Click on the Round menu and select Show Trust Game</h2>"); + showInstructionsNext = false; + } + if (roundConfiguration.isChatRoundEnabled()) { + startChatMenuItem.setEnabled(true); + instructionsBuilder.append("<h2>COMMUNICATION ROUND: There is a communication round configured to run at the end of this round. Click on the Round menu and select Start Chat Round</h2>"); + showInstructionsNext = false; + } + if (showInstructionsNext) { + instructionsBuilder.append("<h2>SHOW INSTRUCTIONS: Click on the Round menu and select Show instructions when ready.</h2>"); + } + informationEditorPane.setText(instructionsBuilder.toString()); + } + completedQuizzes = 0; + completedTrustGames = 0; + } + + public void configureForReplay() { + //Enable the replay menus + loadExperimentMenuItem.setEnabled(true); + + //Disable all other menus + startRoundMenuItem.setEnabled(false); + stopRoundMenuItem.setEnabled(false); + } + + public void addMessage(String message) { + try { + messageEditorPane.getDocument().insertString(0, message + "\n", null); + } + catch (BadLocationException exception) { + exception.printStackTrace(); + } + } + + public void quizCompleted(QuizCompletedEvent event) { + completedQuizzes++; + addMessage(String.format("%d completed quizzes (%s)", completedQuizzes, event)); + } + + public void trustGameSubmitted(TrustGameSubmissionEvent event) { + completedTrustGames++; + addMessage(String.format("%d completed trust games (%s)", completedTrustGames, event)); + } + } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 22 03:50:16 2011 -0700 @@ -58,6 +58,7 @@ import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; +import edu.asu.commons.foraging.event.TrustGameSubmissionEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; import edu.asu.commons.foraging.event.UnlockResourceRequest; import edu.asu.commons.foraging.model.ClientData; @@ -297,7 +298,7 @@ public void handle(final QuizResponseEvent event) { logger.info("Received quiz response: " + event); numberOfSubmittedQuizzes++; - transmit(new QuizCompletedEvent(facilitatorId)); + transmit(new QuizCompletedEvent(facilitatorId, event)); ClientData clientData = clients.get(event.getId()); clientData.addCorrectQuizAnswers(event.getNumberOfCorrectAnswers()); if (numberOfSubmittedQuizzes >= clients.size()) { @@ -677,6 +678,7 @@ clientData.setTrustGamePlayerOneAmountToKeep(request.getPlayerOneAmountToKeep()); clientData.setTrustGamePlayerTwoAmountsToKeep(request.getPlayerTwoAmountsToKeep()); persister.store(request); + transmit(new TrustGameSubmissionEvent(facilitatorId, request)); numberOfSubmissions++; } if (numberOfSubmissions >= clients.size()) { --- a/src/main/java/edu/asu/commons/foraging/ui/ChatPanel.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/ChatPanel.java Thu Sep 22 03:50:16 2011 -0700 @@ -2,6 +2,8 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.List; @@ -21,7 +23,6 @@ import edu.asu.commons.experiment.DataModel; import edu.asu.commons.foraging.client.ForagingClient; import edu.asu.commons.foraging.conf.RoundConfiguration; -import edu.asu.commons.foraging.conf.ServerConfiguration; import edu.asu.commons.net.Identifier; /** @@ -62,11 +63,8 @@ private void initGuiComponents() { setLayout(new BorderLayout(3, 3)); setName("Chat panel"); - messagesEditorPane = new JEditorPane(); - messagesEditorPane.setEditable(false); - messagesEditorPane.setBackground(Color.WHITE); + messagesEditorPane = ForagingInterface.createInstructionsEditorPane(); messageScrollPane = new JScrollPane(messagesEditorPane); - ForagingClient.addStyles(messagesEditorPane, 16); textEntryPanel = new TextEntryPanel(client); add(textEntryPanel, BorderLayout.NORTH); @@ -74,7 +72,7 @@ } public void setTextFieldFocus() { - textEntryPanel.setChatFieldFocus(); + textEntryPanel.chatField.requestFocusInWindow(); } public TextEntryPanel getTextEntryPanel() { @@ -92,9 +90,9 @@ private void displayMessage(Identifier identifier, String message) { try { Document document = messagesEditorPane.getDocument(); - String source = String.format("<b>%s</b> : ", identifier.getChatHandle()); + String source = String.format("%s : ", identifier.getChatHandle()); document.insertString(0, source, null); - document.insertString(source.length(), String.format("<i>%s</i><br>", message), null); + document.insertString(source.length(), String.format("%s\n", message), null); messagesEditorPane.setCaretPosition(0); } catch (BadLocationException e) { e.printStackTrace(); @@ -123,16 +121,23 @@ } } }); + chatField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + chatField.setBackground(Color.YELLOW); + } + @Override + public void focusLost(FocusEvent e) { + chatField.setBackground(Color.WHITE); + } + + }); JLabel headerLabel = new JLabel("Chat"); - headerLabel.setFont(GameWindow.DEFAULT_BOLD_FONT); + headerLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); add(headerLabel, BorderLayout.NORTH); add(chatField, BorderLayout.CENTER); } - void setChatFieldFocus() { - chatField.requestFocusInWindow(); - } - private void sendMessage() { String message = chatField.getText(); System.err.println("sending message: " + message); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow.java Thu Sep 22 03:50:16 2011 -0700 @@ -1,7 +1,5 @@ package edu.asu.commons.foraging.ui; -import java.awt.Font; - import javax.swing.JPanel; import edu.asu.commons.foraging.event.EndRoundEvent; @@ -15,9 +13,7 @@ * @version $Revision: 416 $ */ public interface GameWindow { - public static final Font DEFAULT_PLAIN_FONT = new Font("Trebuchet MS", Font.PLAIN, 16); - public static final Font DEFAULT_BOLD_FONT = new Font("Trebuchet MS", Font.BOLD, 16); - + public void startRound(); public void endRound(EndRoundEvent event); public void init(); --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Thu Sep 22 03:50:16 2011 -0700 @@ -5,7 +5,6 @@ import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -33,12 +32,10 @@ import javax.swing.JViewport; import javax.swing.SwingUtilities; import javax.swing.Timer; -import javax.swing.UIManager; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import javax.swing.text.StyledDocument; -import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; @@ -344,19 +341,6 @@ getPanel().repaint(); } - private HtmlEditorPane createInstructionsEditorPane() { - // JEditorPane pane = new JEditorPane("text/html", - // "Costly Sanctioning Experiment"); - final HtmlEditorPane htmlPane = new HtmlEditorPane(); - htmlPane.setEditable(false); - htmlPane.setDoubleBuffered(true); - htmlPane.setBackground(Color.WHITE); - ForagingClient.addStyles(htmlPane, 16); - return htmlPane; - } - - - private void initGuiComponents(Dimension size) { // FIXME: replace with CardLayout for easier switching between panels cardLayout = new CardLayout(); @@ -366,7 +350,7 @@ subjectView = new SubjectView(subjectViewSize, dataModel); // add instructions panel card - instructionsEditorPane = createInstructionsEditorPane(); + instructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); instructionsScrollPane = new JScrollPane(instructionsEditorPane); instructionsScrollPane.setDoubleBuffered(true); instructionsScrollPane.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); @@ -382,9 +366,9 @@ // add labels to game panel // FIXME: replace with progress bar. timeLeftLabel = new JLabel("Connecting ..."); - timeLeftLabel.setFont(DEFAULT_BOLD_FONT); + timeLeftLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); informationLabel = new JLabel("Tokens collected: 0 "); - informationLabel.setFont(DEFAULT_BOLD_FONT); + informationLabel.setFont(ForagingInterface.DEFAULT_BOLD_FONT); // latencyLabel = new JLabel("Latency: 0"); informationLabel.setBackground(Color.YELLOW); informationLabel.setForeground(Color.BLUE); @@ -401,9 +385,10 @@ messagePanel = new JPanel(new BorderLayout()); // messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS)); messagePanel.add(new JLabel("Messages"), BorderLayout.NORTH); + // FIXME: setFont doesn't work here the way we want it to. messageTextPane = new JTextPane(); messageTextPane.setEditable(false); - messageTextPane.setFont(DEFAULT_BOLD_FONT); + messageTextPane.setFont(ForagingInterface.DEFAULT_BOLD_FONT); messageTextPane.setBackground(Color.WHITE); addStyles(messageTextPane.getStyledDocument()); messageScrollPane = new JScrollPane(messageTextPane); @@ -597,6 +582,9 @@ // FIXME: switch to different layout manager gamePanel.add(chatPanel, BorderLayout.EAST); } + else { + gamePanel.remove(getChatPanel()); + } showPanel(GAME_PANEL_NAME); } }; @@ -631,8 +619,6 @@ // replace this junk Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle( StyleContext.DEFAULT_STYLE); - // Style regularStyle = styledDocument.addStyle("regular", - // defaultStyle); StyleConstants.setFontFamily(defaultStyle, "Helvetica"); StyleConstants.setBold(styledDocument.addStyle("bold", defaultStyle), true); @@ -718,7 +704,7 @@ if (roundConfiguration.isTrustGameEnabled()) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - JEditorPane trustGameInstructionsEditorPane = createInstructionsEditorPane(); + JEditorPane trustGameInstructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); panel.add(scrollPane); @@ -753,6 +739,13 @@ } }); } + + public void trustGameSubmit() { + instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); + setInstructions(instructionsBuilder.toString()); + switchInstructionsPane(); + + } public void switchInstructionsPane() { showPanel(INSTRUCTIONS_PANEL_NAME); --- a/src/main/java/edu/asu/commons/foraging/ui/TrustGamePanel.java Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/TrustGamePanel.java Thu Sep 22 03:50:16 2011 -0700 @@ -504,11 +504,6 @@ playerTwoAmountsToKeep[rowIndex - 1] = (Double) value; } client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); - client.getGameWindow2D().switchInstructionsPane(); - - - - }// GEN-LAST:event_submitButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round0.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round0.xml Thu Sep 22 03:50:16 2011 -0700 @@ -12,7 +12,6 @@ <entry key='subjects-field-of-vision'>true</entry><entry key='in-round-chat-enabled'>true</entry> -<entry key='post-round-trust-game'>true</entry><entry key="quiz">true</entry><entry key="q1">C</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round1.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round1.xml Thu Sep 22 03:50:16 2011 -0700 @@ -8,6 +8,8 @@ <entry key="resource-depth">29</entry><entry key="resource-width">29</entry> +<entry key='trust-game'>true</entry> + <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry><entry key='tokens-field-of-vision'>true</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round3.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round3.xml Thu Sep 22 03:50:16 2011 -0700 @@ -17,7 +17,6 @@ <!-- resource regrowth parameters --><entry key="initial-distribution">.25</entry> -<entry key='post-round-trust-game'>true</entry><entry key="instructions"> --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round4.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/round4.xml Thu Sep 22 03:50:16 2011 -0700 @@ -8,6 +8,8 @@ <entry key="resource-width">29</entry><entry key="duration">240</entry> +<!-- have a trust game before this round begins --> +<entry key='trust-game'>true</entry><!-- enable field of vision for tokens and subjects --><entry key='tokens-field-of-vision'>true</entry><entry key='subjects-field-of-vision'>true</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/server.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/server.xml Thu Sep 22 03:50:16 2011 -0700 @@ -15,15 +15,19 @@ <entry key="number-of-rounds">7</entry><entry key="facilitator-instructions"><![CDATA[ -<h3>Facilitator Instructions</h3> +<h2>Facilitator Instructions</h2> +<hr><p> -Welcome to the facilitator interface. This interface allows you to control -the experiment. You may only modify configuration parameters <b>before</b> -you start the experiment by selecting the Configuration menu. When all the -participants are ready to begin the experiment, you can start the experiment -by selecting Experiment -> Start. After a round has been completed you -will be able to view the statistics for all of the participants. You can -begin the next round by selecting Round -> Start. + This facilitator interface allows you to control the experiment. In general you + will be invoking this sequence: + + <ol> + <li>Show instructions</li> + <li>Start round</li> + <li>Show trust game as necessary</li> + <li>Start standalone chat round, as necessary</li> + <li>Goto 1.</li> + </ol></p> ]]></entry> @@ -56,7 +60,7 @@ </p><p> You can earn more, up to a maximum of about 40 dollars, by participating in this -experiment, which will take about an hour to an hour and a half. The amount of money +experiment which will take about an hour to an hour and a half. The amount of money you earn depends on your decisions AND the decisions of other people in this room over the course of the experiment. </p> @@ -68,7 +72,7 @@ </p><p> 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 + every move of your yellow dot. As you move around you can collect green diamond shaped tokens <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 @@ -109,9 +113,8 @@ The chance that a token will regenerate on an empty cell increases as there are more tokens surrounding it. Therefore, you want to have as many tokens around an empty cell as possible. However, you also need empty cells to benefit from this -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. +regrowth. The best arrangement of tokens that maximizes overall regrowth is the +checkerboard diagram shown below. <br><img src="@CODEBASE_URL@/images/foraging-checkerboard.png" alt="Checkerboard Resource"></img></p> @@ -129,7 +132,7 @@ are randomly paired with another member of your group you may be selected as Player 1 <b>or</b> Player 2. The results of randomly pairing your strategies with the other group member's strategies will be shown to you at the <b>end of - mhe experiment</b>. + the experiment</b>. </p><h2>How to participate</h2> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Thu Sep 22 03:50:16 2011 -0700 @@ -12,7 +12,6 @@ <entry key='subjects-field-of-vision'>true</entry><entry key='in-round-chat-enabled'>true</entry> -<entry key='post-round-trust-game'>true</entry><entry key="quiz">true</entry><entry key="q1">C</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round1.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round1.xml Thu Sep 22 03:50:16 2011 -0700 @@ -8,6 +8,8 @@ <entry key="resource-depth">29</entry><entry key="resource-width">29</entry> +<entry key='trust-game'>true</entry> + <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry><entry key='tokens-field-of-vision'>true</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round3.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round3.xml Thu Sep 22 03:50:16 2011 -0700 @@ -17,7 +17,6 @@ <!-- resource regrowth parameters --><entry key="initial-distribution">.25</entry> -<entry key='post-round-trust-game'>true</entry><entry key="instructions"> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round4.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round4.xml Thu Sep 22 03:50:16 2011 -0700 @@ -8,6 +8,8 @@ <entry key="resource-width">29</entry><entry key="duration">240</entry> +<!-- have a trust game before this round begins --> +<entry key='trust-game'>true</entry><!-- enable field of vision for tokens and subjects --><entry key='tokens-field-of-vision'>true</entry><entry key='subjects-field-of-vision'>true</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Wed Sep 21 21:27:32 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Thu Sep 22 03:50:16 2011 -0700 @@ -15,15 +15,19 @@ <entry key="number-of-rounds">7</entry><entry key="facilitator-instructions"><![CDATA[ -<h3>Facilitator Instructions</h3> +<h2>Facilitator Instructions</h2> +<hr><p> -Welcome to the facilitator interface. This interface allows you to control -the experiment. You may only modify configuration parameters <b>before</b> -you start the experiment by selecting the Configuration menu. When all the -participants are ready to begin the experiment, you can start the experiment -by selecting Experiment -> Start. After a round has been completed you -will be able to view the statistics for all of the participants. You can -begin the next round by selecting Round -> Start. + This facilitator interface allows you to control the experiment. In general you + will be invoking this sequence: + + <ol> + <li>Show instructions</li> + <li>Start round</li> + <li>Show trust game as necessary</li> + <li>Start standalone chat round, as necessary</li> + <li>Goto 1.</li> + </ol></p> ]]></entry> @@ -56,7 +60,7 @@ </p><p> You can earn more, up to a maximum of about 40 dollars, by participating in this -experiment, which will take about an hour to an hour and a half. The amount of money +experiment which will take about an hour to an hour and a half. The amount of money you earn depends on your decisions AND the decisions of other people in this room over the course of the experiment. </p> @@ -68,7 +72,7 @@ </p><p> 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 + every move of your yellow dot. As you move around you can collect green diamond shaped tokens <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 @@ -109,9 +113,8 @@ The chance that a token will regenerate on an empty cell increases as there are more tokens surrounding it. Therefore, you want to have as many tokens around an empty cell as possible. However, you also need empty cells to benefit from this -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. +regrowth. The best arrangement of tokens that maximizes overall regrowth is the +checkerboard diagram shown below. <br><img src="@CODEBASE_URL@/images/foraging-checkerboard.png" alt="Checkerboard Resource"></img></p> @@ -129,7 +132,7 @@ are randomly paired with another member of your group you may be selected as Player 1 <b>or</b> Player 2. The results of randomly pairing your strategies with the other group member's strategies will be shown to you at the <b>end of - mhe experiment</b>. + the experiment</b>. </p><h2>How to participate</h2> 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. |
From: Bitbucket <com...@bi...> - 2011-09-22 04:27:40
|
2 new changesets in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/ef5949ca1dca/ changeset: ef5949ca1dca user: alllee date: 2011-09-22 03:50:33 summary: updating trust exercise instructions affected #: 2 files (-1 bytes) --- a/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/server.xml Wed Sep 21 17:02:05 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/bratislava-pretest/server.xml Wed Sep 21 18:50:33 2011 -0700 @@ -120,15 +120,16 @@ <entry key='trust-game-instructions'><![CDATA[ -<h1>Trust Game Instructions</h1> +<h1>Instructions</h1><hr><p> You will now participate in an exercise where you will be matched with a random - person in your group. In this game there are two roles, Player 1 and Player 2. + person in your group. In this exercise there are two roles, Player 1 and Player 2. Your job is to design strategies for both Player 1 and Player 2 roles. When you are randomly paired with another member of your group you may be selected as - Player 1 <b>or</b> Player 2. The results of your strategies will be shown to - you at the <b>end of the experiment</b>. + Player 1 <b>or</b> Player 2. The results of randomly pairing your strategies + with the other group member's strategies will be shown to you at the <b>end of + mhe experiment</b>. </p><h2>How to participate</h2> --- a/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Wed Sep 21 17:02:05 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Wed Sep 21 18:50:33 2011 -0700 @@ -120,15 +120,16 @@ <entry key='trust-game-instructions'><![CDATA[ -<h1>Trust Game Instructions</h1> +<h1>Instructions</h1><hr><p> You will now participate in an exercise where you will be matched with a random - person in your group. In this game there are two roles, Player 1 and Player 2. + person in your group. In this exercise there are two roles, Player 1 and Player 2. Your job is to design strategies for both Player 1 and Player 2 roles. When you are randomly paired with another member of your group you may be selected as - Player 1 <b>or</b> Player 2. The results of your strategies will be shown to - you at the <b>end of the experiment</b>. + Player 1 <b>or</b> Player 2. The results of randomly pairing your strategies + with the other group member's strategies will be shown to you at the <b>end of + mhe experiment</b>. </p><h2>How to participate</h2> http://bitbucket.org/virtualcommons/foraging/changeset/f2b14b6164da/ changeset: f2b14b6164da user: alllee date: 2011-09-22 06:27:32 summary: moving ui components into ui package, other refactoring alongside csidex snapshot API additions setting up consistent font by adding a static method to ForagingClient that styles a JEditorPane. It feels dirty, should find a better place for it later. affected #: 33 files (-1 bytes) Diff too large to display. 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. |