virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 21)
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...> - 2012-02-15 07:33:22
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/2ebf6e29ed8e/ changeset: 2ebf6e29ed8e user: alllee date: 2012-02-15 08:33:10 summary: adding updated screenshot affected #: 1 file diff -r 2063dc891c99de0530f8c309afb4bef656c64409 -r 2ebf6e29ed8eff347554ba942d2f4b05476b1e4a src/main/resources/images/irrigation-screenshot.jpg Binary file src/main/resources/images/irrigation-screenshot.jpg has changed Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-15 07:26:55
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/9c1df74e0510/ changeset: 9c1df74e0510 branch: stable user: alllee date: 2012-02-15 08:26:35 summary: adding stable branch affected #: 0 files Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-15 07:25:43
|
3 new commits in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/dc8d504e6a2d/ changeset: dc8d504e6a2d user: alllee date: 2012-02-15 08:22:50 summary: un-italicizing chat messages affected #: 1 file diff -r 6ee2823f546279040678104de10375b07897ee04 -r dc8d504e6a2d9fecac08a739586a790fa09cfa2e src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -177,7 +177,7 @@ } try { document.insertString(0, chatHandle, document.getStyle("bold")); - document.insertString(chatHandle.length(), message + "\n", document.getStyle("italic")); + document.insertString(chatHandle.length(), message + "\n", null); messageWindow.setCaretPosition(0); } catch (BadLocationException e) { https://bitbucket.org/virtualcommons/irrigation/changeset/e8e76f4099c3/ changeset: e8e76f4099c3 user: alllee date: 2012-02-15 08:24:56 summary: fixes issue 10 but adds a new requirement for an explicit Show Instructions after all quizzes have been submitted. Also need to consider whether or not to move the quiz earnings out of the debriefing table as it might be inappropriate to show visible participant quiz earnings. affected #: 1 file diff -r dc8d504e6a2d9fecac08a739586a790fa09cfa2e -r e8e76f4099c36f7eb587954e5595314a706c27b5 src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -209,9 +209,11 @@ } else { // this only works in between practice rounds #1 & #2 or after practice round 2 - setInstructions(instructionsBuilder.toString()); + // should just regenerate all the instructions... nextButton.setEnabled(false); disableQuiz(); + showDebriefing(false); +// setInstructions(instructionsBuilder.toString()); } } }); @@ -220,13 +222,7 @@ return nextButton; } -// private CanalAnimationPanel getCanalAnimationPanel() { -// if (canalAnimationPanel == null) { -// canalAnimationPanel = new CanalAnimationPanel(40); -// } -// return canalAnimationPanel; -// } - + // FIXME: replace with StringTemplate private String getQuizPage() { StringBuilder builder = new StringBuilder(); String quizPage = getServerConfiguration().getQuizPage(currentQuizPageNumber); @@ -465,7 +461,10 @@ nextButton.setEnabled(true); } // quizzesAnswered++; - client.transmit(new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers)); + QuizResponseEvent event = new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers); + System.err.println("Correct answers: " + event.getNumberOfCorrectQuizAnswers()); + clientDataModel.getClientData().addCorrectQuizAnswers(event.getNumberOfCorrectQuizAnswers()); + client.transmit(event); setInstructions(getQuizPage(), true); } }; @@ -644,6 +643,11 @@ * Invoked when the show instructions button is pressed. */ public void showInstructions() { - displayInstructions(getServerConfiguration().getInitialInstructions()); + if (clientDataModel == null || clientDataModel.getRoundConfiguration().isFirstRound()) { + displayInstructions(getServerConfiguration().getInitialInstructions()); + } + else { + displayInstructions(clientDataModel.getRoundConfiguration().getInstructions()); + } } } https://bitbucket.org/virtualcommons/irrigation/changeset/2063dc891c99/ changeset: 2063dc891c99 user: alllee date: 2012-02-15 08:25:26 summary: fixing bug, ShowRequest handler needs to accept subtypes affected #: 1 file diff -r e8e76f4099c36f7eb587954e5595314a706c27b5 -r 2063dc891c99de0530f8c309afb4bef656c64409 src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java --- a/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java +++ b/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java @@ -150,7 +150,7 @@ } } }); - addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class) { + addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class, true) { @Override public void handle(ShowRequest request) { if (request.getId().equals(getFacilitatorId())) { @@ -404,8 +404,7 @@ process(group); } catch (RuntimeException exception) { - exception.printStackTrace(); - getLogger().throwing(IrrigationServerStateMachine.class.getName(), "processRound", exception); + sendFacilitatorMessage("Couldn't process group: " + exception.getMessage(), exception); } } // lastTime = System.currentTimeMillis(); Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-15 06:32:10
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/6ee2823f5462/ changeset: 6ee2823f5462 user: alllee date: 2012-02-15 07:31:31 summary: refactoring irrigation server to use csidex ShowRequest affected #: 7 files diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java --- a/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java +++ b/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java @@ -10,6 +10,7 @@ import edu.asu.commons.event.EventChannel; import edu.asu.commons.event.EventChannelFactory; import edu.asu.commons.event.EventTypeProcessor; +import edu.asu.commons.event.ShowInstructionsRequest; import edu.asu.commons.event.SocketIdentifierUpdateRequest; import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.irrigation.conf.ServerConfiguration; @@ -23,7 +24,6 @@ import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; -import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.ShowQuizRequest; import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.net.ClientDispatcher; diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java --- a/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java +++ b/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java @@ -1,15 +1,20 @@ package edu.asu.commons.irrigation.events; import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.event.ShowRequest; import edu.asu.commons.net.Identifier; -public class ShowGameScreenshotRequest extends AbstractEvent implements FacilitatorRequest { +public class ShowGameScreenshotRequest extends AbstractEvent implements ShowRequest<ShowGameScreenshotRequest> { private static final long serialVersionUID = -344715300306788401L; public ShowGameScreenshotRequest(Identifier id) { super(id); } + + @Override + public ShowGameScreenshotRequest copy(Identifier id) { + return new ShowGameScreenshotRequest(id); + } } diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/events/ShowInstructionsRequest.java --- a/src/main/java/edu/asu/commons/irrigation/events/ShowInstructionsRequest.java +++ /dev/null @@ -1,23 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.FacilitatorRequest; -import edu.asu.commons.net.Identifier; - -/** - * $Id$ - * - * Request from the facilitator to display instructions on the client side. - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class ShowInstructionsRequest extends AbstractEvent implements FacilitatorRequest { - - private static final long serialVersionUID = 798700489117350818L; - - public ShowInstructionsRequest(Identifier id){ - super(id); - } - -} diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java --- a/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java +++ b/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java @@ -1,7 +1,7 @@ package edu.asu.commons.irrigation.events; import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.event.ShowRequest; import edu.asu.commons.net.Identifier; /** @@ -12,12 +12,17 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class ShowQuizRequest extends AbstractEvent implements FacilitatorRequest { +public class ShowQuizRequest extends AbstractEvent implements ShowRequest<ShowQuizRequest> { private static final long serialVersionUID = 383560843031641044L; public ShowQuizRequest(Identifier id) { super(id); } + + @Override + public ShowQuizRequest copy(Identifier id) { + return new ShowQuizRequest(id); + } } diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java --- a/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java +++ b/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java @@ -1,14 +1,19 @@ package edu.asu.commons.irrigation.events; import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.event.ShowRequest; import edu.asu.commons.net.Identifier; -public class ShowTokenInvestmentScreenRequest extends AbstractEvent implements FacilitatorRequest { +public class ShowTokenInvestmentScreenRequest extends AbstractEvent implements ShowRequest<ShowTokenInvestmentScreenRequest> { private static final long serialVersionUID = -4133284727930840712L; public ShowTokenInvestmentScreenRequest(Identifier id) { super(id); } + + @Override + public ShowTokenInvestmentScreenRequest copy(Identifier id) { + return new ShowTokenInvestmentScreenRequest(id); + } } diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java --- a/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java @@ -13,10 +13,10 @@ import javax.swing.JScrollPane; import javax.swing.SwingUtilities; +import edu.asu.commons.event.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.BeginChatRoundRequest; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; -import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.ShowQuizRequest; import edu.asu.commons.irrigation.model.ClientData; import edu.asu.commons.irrigation.model.GroupDataModel; diff -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 -r 6ee2823f546279040678104de10375b07897ee04 src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java --- a/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java +++ b/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java @@ -15,6 +15,7 @@ import edu.asu.commons.event.EventTypeProcessor; import edu.asu.commons.event.FacilitatorRegistrationRequest; import edu.asu.commons.event.RoundStartedMarkerEvent; +import edu.asu.commons.event.ShowRequest; import edu.asu.commons.event.SocketIdentifierUpdateRequest; import edu.asu.commons.experiment.AbstractExperiment; import edu.asu.commons.experiment.IPersister; @@ -32,10 +33,6 @@ import edu.asu.commons.irrigation.events.QuizResponseEvent; import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; -import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; -import edu.asu.commons.irrigation.events.ShowInstructionsRequest; -import edu.asu.commons.irrigation.events.ShowQuizRequest; -import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.irrigation.model.ClientData; import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.irrigation.model.ServerDataModel; @@ -88,27 +85,8 @@ initializeClientHandlers(); } + @SuppressWarnings("rawtypes") private void initializeFacilitatorHandlers() { - addEventProcessor(new EventTypeProcessor<ShowGameScreenshotRequest>(ShowGameScreenshotRequest.class) { - public void handle(ShowGameScreenshotRequest request) { - // FIXME: check request id against facilitator id? - synchronized (clients) { - for (Identifier id: clients.keySet()) { - transmit(new ShowGameScreenshotRequest(id)); - } - } - } - }); - addEventProcessor(new EventTypeProcessor<ShowQuizRequest>(ShowQuizRequest.class) { - public void handle(ShowQuizRequest request) { - // FIXME: check request id against facilitator id? - synchronized (clients) { - for (Identifier id: clients.keySet()) { - transmit(new ShowQuizRequest(id)); - } - } - } - }); addEventProcessor(new EventTypeProcessor<FacilitatorRegistrationRequest>(FacilitatorRegistrationRequest.class) { @Override public void handle(FacilitatorRegistrationRequest event) { @@ -172,24 +150,19 @@ } } }); - addEventProcessor(new EventTypeProcessor<ShowInstructionsRequest>(ShowInstructionsRequest.class) { + addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class) { @Override - public void handle(ShowInstructionsRequest request) { - synchronized (clients) { - for (Identifier id: clients.keySet()) { - transmit(new ShowInstructionsRequest(id)); - } - } - } - }); - addEventProcessor(new EventTypeProcessor<ShowTokenInvestmentScreenRequest>(ShowTokenInvestmentScreenRequest.class) { - @Override - public void handle(ShowTokenInvestmentScreenRequest request) { - synchronized (clients) { - for (Identifier id: clients.keySet()) { - transmit(new ShowTokenInvestmentScreenRequest(id)); - } - } + public void handle(ShowRequest request) { + if (request.getId().equals(getFacilitatorId())) { + synchronized (clients) { + for (Identifier id: clients.keySet()) { + transmit(request.copy(id)); + } + } + } + else { + sendFacilitatorMessage("Received invalid show request " + request + " from " + getFacilitatorId()); + } } }); } Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-15 00:11:05
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/7eaca2c05f23/ changeset: 7eaca2c05f23 user: alllee date: 2012-02-15 01:10:53 summary: updating ivy version affected #: 1 file diff -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 -r 7eaca2c05f23ff832a5f7abce61f673c8d3a6965 build.xml --- a/build.xml +++ b/build.xml @@ -13,7 +13,7 @@ uri='antlib:org.apache.ivy.ant' classpathref='ivy.lib.path'/> --> - <property name="ivy.install.version" value="2.1.0" /> + <property name="ivy.install.version" value="2.2.0" /><condition property="ivy.home" value="${env.IVY_HOME}"><isset property="env.IVY_HOME" /></condition> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-15 00:09:06
|
4 new commits in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/171f3e5db642/ changeset: 171f3e5db642 user: alllee date: 2012-02-15 01:05:20 summary: adding convenience methods to QuizResponseEvent affected #: 1 file diff -r 8f20bf11520c339beb0e4de6cdcf9f00475839df -r 171f3e5db642820682965e7756bb87acb27fa1e9 src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java @@ -32,6 +32,10 @@ this.responses = responses; this.incorrectAnswers = incorrectAnswers; } + + public boolean isComplete() { + return quizPage == 2; + } public int getQuizPage(){ return quizPage; @@ -48,4 +52,8 @@ public String toString() { return id + " quiz page response: " + responses + "\n\t incorrect: " + incorrectAnswers; } + + public int getNumberOfCorrectQuizAnswers() { + return responses.size() - 1 - getIncorrectAnswers().size(); + } } https://bitbucket.org/virtualcommons/irrigation/changeset/adf625d46b31/ changeset: adf625d46b31 user: alllee date: 2012-02-15 01:06:17 summary: keeping track of correct quiz answers on ClientData affected #: 1 file diff -r 171f3e5db642820682965e7756bb87acb27fa1e9 -r adf625d46b318d648d8636882a34c68a1dd5e0ff src/main/java/edu/asu/commons/irrigation/model/ClientData.java --- a/src/main/java/edu/asu/commons/irrigation/model/ClientData.java +++ b/src/main/java/edu/asu/commons/irrigation/model/ClientData.java @@ -249,6 +249,10 @@ public void setSelf(boolean current) { this.self = current; } + + public void addCorrectQuizAnswers(int numberOfCorrectQuizAnswers) { + this.correctQuizAnswers += numberOfCorrectQuizAnswers; + } } https://bitbucket.org/virtualcommons/irrigation/changeset/575215407503/ changeset: 575215407503 user: alllee date: 2012-02-15 01:07:48 summary: pushing conditional check from IrrigationServer into GroupDataModel.allocateWater and keeping track of correct quiz answers affected #: 4 files diff -r adf625d46b318d648d8636882a34c68a1dd5e0ff -r 57521540750303c6cf1eff1cc75958f49b918e7f src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -94,7 +94,7 @@ getProperties().list(System.err); } - public boolean shouldResetInfrastructureEfficiency() { + public boolean isInfrastructureEfficiencyReset() { return isFirstRound() || getBooleanProperty("reset-infrastructure-efficiency", false); } @@ -107,14 +107,11 @@ // and refer to them as self.durationInMinutes or self.dollarsPerTokenCurrencyString, etc. template.add("duration", inMinutes(getDuration()) + " minutes"); template.add("dollarsPerToken", toCurrencyString(getDollarsPerToken())); - if (isRestrictedVisibility()) { - template.add("specialInstructions", getRestrictedVisibilityInstructions()); - } return template.render(); } - private String getRestrictedVisibilityInstructions() { - return render(getProperty("restricted-visibility-instructions")); + public String getSpecialInstructions() { + return render(getProperty("special-instructions")); } public boolean shouldDisplayGroupTokens() { @@ -165,7 +162,7 @@ * @return the number of neighbors visible to either side of each participant. */ public int getFieldOfVision() { - return getIntProperty("field-of-vision", -1); + return getIntProperty("field-of-vision", getParentConfiguration().getFieldOfVision()); } public String getClientDebriefingTemplate() { @@ -205,5 +202,9 @@ public int getChatDuration() { return getIntProperty("chat-duration"); } + + public String getRestrictedVisibilityInstructions() { + return render(getProperty("restricted-visibility-instructions")); + } } diff -r adf625d46b318d648d8636882a34c68a1dd5e0ff -r 57521540750303c6cf1eff1cc75958f49b918e7f src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -17,8 +17,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision$ */ -public class ServerConfiguration -extends ExperimentConfiguration.Base<RoundConfiguration> { +public class ServerConfiguration extends ExperimentConfiguration.Base<RoundConfiguration> { private static final double DEFAULT_QUIZ_CORRECT_ANSWER_REWARD = 0.50d; @@ -116,11 +115,20 @@ } public String getRestrictedVisibilityInstructions() { - return getProperty("restrictedVisibilityInstructions"); + return render(getProperty("restricted-visibility-instructions")); } public boolean isRestrictedVisibility() { - return getBooleanProperty("restrictedVisibility"); + return getFieldOfVision() > 0; + } + + /** + * Returns the number of neighbors visible on both sides of the participant. A negative value signifies that + * participants can see everything. + * @return the number of neighbors visible to either side of each participant. + */ + public int getFieldOfVision() { + return getIntProperty("field-of-vision", -1); } public double getQuizCorrectAnswerReward() { @@ -183,7 +191,6 @@ return getIntProperty("chat-duration", 60); } - public String getGameScreenshotInstructions() { return getProperty("game-screenshot-instructions"); } diff -r adf625d46b318d648d8636882a34c68a1dd5e0ff -r 57521540750303c6cf1eff1cc75958f49b918e7f src/main/java/edu/asu/commons/irrigation/model/GroupDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/model/GroupDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/model/GroupDataModel.java @@ -110,7 +110,7 @@ private void updateInfrastructureEfficiency(int totalContributedTokens) { RoundConfiguration roundConfiguration = getRoundConfiguration(); // initialize infrastructure efficiency - if ( roundConfiguration.shouldResetInfrastructureEfficiency() ) { + if ( roundConfiguration.isInfrastructureEfficiencyReset() ) { infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { @@ -191,6 +191,11 @@ } public void allocateWater(ClientData clientData) { + if (clientData.isGateClosed()) { + // reset the available flow to this client + clientData.setAvailableFlowCapacity(getAvailableClientFlowCapacity()); + return; + } int maximumClientFlowCapacity = getRoundConfiguration().getMaximumClientFlowCapacity(); if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; diff -r adf625d46b318d648d8636882a34c68a1dd5e0ff -r 57521540750303c6cf1eff1cc75958f49b918e7f src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java --- a/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java +++ b/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java @@ -13,7 +13,6 @@ import edu.asu.commons.event.ChatRequest; 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.SocketIdentifierUpdateRequest; @@ -72,17 +71,8 @@ private IrrigationPersister persister; - private int numberOfCompletedQuizzes = 0; - private IrrigationServerStateMachine stateMachine = new IrrigationServerStateMachine(); - /** - * this is the variable that would be reset to Bt for - * every loop of the client traversal. - */ - - private Identifier facilitatorId; - public IrrigationServer() { this(new ServerConfiguration()); } @@ -124,10 +114,10 @@ public void handle(FacilitatorRegistrationRequest event) { getLogger().info("facilitator registered: " + event.getId()); // remap the facilitator ID and remove from the clients list. - facilitatorId = event.getId(); + setFacilitatorId(event.getId()); synchronized (clients) { - clients.remove(facilitatorId); - serverDataModel.removeClient(facilitatorId); + clients.remove(getFacilitatorId()); + serverDataModel.removeClient(getFacilitatorId()); } } }); @@ -143,9 +133,9 @@ addEventProcessor(new EventTypeProcessor<BeginRoundRequest>(BeginRoundRequest.class) { @Override public void handle(BeginRoundRequest event) { - if (! event.getId().equals(facilitatorId)) { + if (! event.getId().equals(getFacilitatorId())) { getLogger().warning( - String.format("facilitator is [%s] but received begin round request from non-facilitator [%s]", facilitatorId, event.getId())); + String.format("facilitator is [%s] but received begin round request from non-facilitator [%s]", getFacilitatorId(), event.getId())); return; } // ignore the request if not every group has submit their tokens. @@ -244,9 +234,9 @@ public void handle(DisconnectionRequest request) { getLogger().warning("irrigation server handling disconnection request: " + request); Identifier disconnectedClientId = request.getId(); - if (disconnectedClientId.equals(facilitatorId)) { + if (disconnectedClientId.equals(getFacilitatorId())) { getLogger().warning("Disconnecting facilitator."); - facilitatorId = null; + setFacilitatorId(null); return; } synchronized (clients) { @@ -303,11 +293,19 @@ } }); addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { + private int numberOfCompletedQuizzes = 0; @Override - public void handle(QuizResponseEvent event) { - getLogger().info("Completed quizzes: " + numberOfCompletedQuizzes); - numberOfCompletedQuizzes++; - persister.store(event); + public void handle(QuizResponseEvent quizResponseEvent) { + sendFacilitatorMessage("Received quiz response: " + quizResponseEvent); + clients.get(quizResponseEvent.getId()).addCorrectQuizAnswers(quizResponseEvent.getNumberOfCorrectQuizAnswers()); + if (quizResponseEvent.isComplete()) { + numberOfCompletedQuizzes++; + } + if (numberOfCompletedQuizzes >= clients.size()) { + sendFacilitatorMessage("All quizzes completed: " + numberOfCompletedQuizzes); + numberOfCompletedQuizzes = 0; + } + persister.store(quizResponseEvent); } }); addEventProcessor(new EventTypeProcessor<OpenGateEvent>(OpenGateEvent.class) { @@ -321,10 +319,7 @@ } }); } - private void sendFacilitatorMessage(String message) { - getLogger().info(message); - transmit(new FacilitatorMessageEvent(facilitatorId, message)); - } + private boolean isTokenInvestmentComplete() { return submittedClients >= clients.size(); } @@ -353,31 +348,22 @@ /** - * Processes all the clients message queues. The main loop of the game while - * the server is running, notifies clients of the current state of affairs. + * Processes the given GroupDataModel and re-allocates water to each participant in the group + * based on each participants gate open/closed status. * - * This method is very important as in it tries to process all the clients in one - * group, every second. Then checks the clientData field and transmits the event accordingly - * At present dont know whether this would be a scalable solution, but there is a scope of - * improvement here * @param group */ private void process(GroupDataModel group) { - // reset group's available bandwidth and re-allocate client delivery bandwidths. + // reset group's available flow and re-allocate water to each participant in this group group.resetCurrentlyAvailableFlowCapacity(); int timeLeft = (int) (currentRoundDuration.getTimeLeft() / 1000); - // allocate bandwidth to each client + // allocate flow to each participant for (ClientData clientData : group.getClientDataMap().values()) { // for undisrupted flow extensions, disabled for the time being. // if (clientData.getAvailableFlowCapacity() <= 0 && getConfiguration().isUndisruptedFlowRequired()){ // clientData.init(group.getCurrentlyAvailableFlowCapacity()); // } - if (clientData.isGateOpen()) { - group.allocateWater(clientData); - } - else { - clientData.init(group.getAvailableClientFlowCapacity()); - } + group.allocateWater(clientData); } for (Identifier id: group.getAllClientIdentifiers()) { ClientUpdateEvent clientUpdateEvent = new ClientUpdateEvent(id, group, timeLeft); @@ -482,7 +468,7 @@ getConfiguration().isLastRound())); } } - transmit(new FacilitatorEndRoundEvent(facilitatorId, serverDataModel)); + transmit(new FacilitatorEndRoundEvent(getFacilitatorId(), serverDataModel)); } @@ -521,7 +507,7 @@ } } // send new round configuration to the facilitator - transmit(new RegistrationEvent(facilitatorId, nextRoundConfiguration)); + transmit(new RegistrationEvent(getFacilitatorId(), nextRoundConfiguration)); persister.initialize(nextRoundConfiguration); } https://bitbucket.org/virtualcommons/irrigation/changeset/4a9dbfb7521a/ changeset: 4a9dbfb7521a user: alllee date: 2012-02-15 01:08:45 summary: adding more horrifying conditional checks to already horrifying conditional spaghetti in CanalPanel to try to deal with restricted visibility of the canal. Still needs more testing. affected #: 9 files diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java @@ -19,492 +19,496 @@ * * FIXME: completely rewrite horrifyingly convoluted animation logic * - * @author Sanket Joshi + * @author Sanket Joshi, Allen Lee */ public class CanalPanel extends JPanel { - private static final long serialVersionUID = -6178860067928578812L; + private static final long serialVersionUID = -6178860067928578812L; - // private Graphics2D graphics2D; + // ////////////////animation logic parameters////////////////////////////// + private Timer timer; - // ////////////////animation logic parameters////////////////////////////// - private Timer timer; + private final static int DELAY = 20; - private final static int DELAY = 20; + private Ball[] balls; - private Ball[] balls; + private final static int BALLCOUNT = 500; + private final static int NUMBER_OF_GATES = 6; - private final static int BALLCOUNT = 500; - private final static int NUMBER_OF_GATES = 6; + private Gate[] gates = new Gate[NUMBER_OF_GATES]; - private Gate[] gates = new Gate[NUMBER_OF_GATES]; + private int gateHeight = 20; - private int gateHeight = 20; + private Random generator = new Random(); - private Random generator = new Random(); + private int maximumIrrigationCapacity; - private int maximumIrrigationCapacity; + private ClientDataModel clientDataModel; - private ClientDataModel clientDataModel; + private int reservoirHeight = 100; + private int reservoirWidth = 100; + private double canalHeightMultiplier = 0.8; - private int reservoirHeight = 100; + private int gateBuffer = 20; - private int reservoirWidth = 100; + private boolean restrictedVisibility; - private double canalHeightMultiplier = 0.8; + // ////////////////////////////////////////////////////////////////////////// - private int gateBuffer = 20; + public CanalPanel(ClientDataModel clientDataModel) { + super(); + // when totalContributed bandwidth = 1.0, you dont see the canal line + setClientDataModel(clientDataModel); + initialize(); + } - private boolean restrictedVisibility; + public void setClientDataModel(ClientDataModel clientDataModel) { + this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); + this.clientDataModel = clientDataModel; + this.restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); + } - // ////////////////////////////////////////////////////////////////////////// + private void initialize() { + // this.setSize(new Dimension(1098,150)); + setLayout(new GridBagLayout()); + setBackground(Color.WHITE); + // initialize each gate + initializeGates(); + initializeBalls(); + timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an + // action + // every DELAY times. + timer.start(); // starts the timer. - public CanalPanel(ClientDataModel clientDataModel) { - super(); - // when totalContributed bandwidth = 1.0, you dont see the canal line - setClientDataModel(clientDataModel); - initialize(); - } + } - public void setClientDataModel(ClientDataModel clientDataModel) { - this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); - this.clientDataModel = clientDataModel; - this.restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); - } + private void initializeGates() { + for (int i = 0; i < NUMBER_OF_GATES; i++) { + gates[i] = new Gate(maximumIrrigationCapacity, i); + } + } - /** - * - */ - private void initialize() { - // this.setSize(new Dimension(1098,150)); - setLayout(new GridBagLayout()); - setBackground(Color.WHITE); - // initialize each gate - initializeGates(); - initializeBalls(); - timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an - // action - // every DELAY times. - timer.start(); // starts the timer. + protected void paintComponent(Graphics graphics) { + super.paintComponent(graphics); // needed! + List<ClientData> sortedClientDataList = clientDataModel.getClientDataSortedByPriority(); + updateGates(sortedClientDataList); + checkRestrictedVisibility(sortedClientDataList); + Graphics2D graphics2D = (Graphics2D) graphics; + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(0, 0, reservoirHeight, reservoirWidth); + // draw gates + for (int i = 0; i < NUMBER_OF_GATES - 1; i++) { + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gates[i].getX(), gates[i].getY(), + gates[i].getWidth(), gates[i].getHeight()); + } + // checkRestrictedVisibility(); + for (ClientData clientData : sortedClientDataList) { +// if (restrictedVisibility && !clientDataModel.isImmediateNeighbor(clientData)) { +// continue; +// } + int priority = clientData.getPriority(); + Gate gate = gates[priority]; + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gate.getOpeningsX(), gate.getOpeningsY(), + gate.getOpeningsWidth(), gate.getOpeningsHeight()); + graphics2D.setColor(Gate.DEFAULT_COLOR); + graphics2D.drawLine(gate.getx1(), gate.gety1(), gate.getx2(), + gate.gety2()); + } - } + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gates[5].getX(), gates[5].getY(), 10, + gates[5].getHeight()); - private void initializeGates() { - for (int i = 0; i < NUMBER_OF_GATES; i++) { - gates[i] = new Gate(maximumIrrigationCapacity, i); - } - } + // particle system animation logic for the balls + graphics.setColor(Color.WHITE); + // int ballCounter = 0; + for (int i = 0; i < BALLCOUNT; i++) { + if ((balls[i].getPosition() == 1) || (balls[i].getPosition() == 2) + || (balls[i].getPosition() == 3) + || (balls[i].getPosition() == 4) + || (balls[i].getPosition() == 5)) { + if (!((gates[balls[i].getPosition() - 1].isClosed()) + && balls[i].getY() >= (gates[balls[i].getPosition() - 1].getY() + gates[balls[i].getPosition() - 1].getHeight()))) + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } else { + if (balls[i].getPosition() != 0) { + if (gates[balls[i].getPosition() - 6].getHeight() != 0) + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } else { + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } + } + } + } - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); // needed! - checkRestrictedVisibility(); - updateGates(); - Graphics2D graphics2D = (Graphics2D) graphics; - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(0, 0, reservoirHeight, reservoirWidth); - // draw gates - for (int i = 0; i < NUMBER_OF_GATES - 1; i++) { - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gates[i].getX(), gates[i].getY(), - gates[i].getWidth(), gates[i].getHeight()); - } -// checkRestrictedVisibility(); - for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { - if (restrictedVisibility && ! clientDataModel.isImmediateNeighbor(clientData)) { - continue; - } - int priority = clientData.getPriority(); - Gate gate = gates[priority]; - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gate.getOpeningsX(), gate.getOpeningsY(), - gate.getOpeningsWidth(), gate.getOpeningsHeight()); - graphics2D.setColor(Gate.DEFAULT_COLOR); - graphics2D.drawLine(gate.getx1(), gate.gety1(), gate.getx2(), - gate.gety2()); - } + private void checkRestrictedVisibility(List<ClientData> sortedClients) { + if (!restrictedVisibility) + return; + ClientData thisClient = clientDataModel.getClientData(); + int thisClientIndex = sortedClients.indexOf(thisClient); + int upstreamNeighborIndex = thisClientIndex - 1; + int downstreamNeighborIndex = thisClientIndex + 1; + for (int i = 0; i < gates.length; i++) { + if (i <= upstreamNeighborIndex && upstreamNeighborIndex > 0) { + ClientData upstreamNeighbor = sortedClients.get(upstreamNeighborIndex); + gates[i].setHeight(upstreamNeighbor.getAvailableFlowCapacity()); + gates[i].setOpeningsHeight((maximumIrrigationCapacity * canalHeightMultiplier) - gates[i].getHeight()); + } + else if (i >= downstreamNeighborIndex && downstreamNeighborIndex < sortedClients.size()) { + ClientData downstreamNeighbor = sortedClients.get(downstreamNeighborIndex); + gates[i].setHeight(downstreamNeighbor.getAvailableFlowCapacity()); + gates[i].setOpeningsHeight((maximumIrrigationCapacity * canalHeightMultiplier) - gates[i].getHeight()); + } + } + } - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gates[5].getX(), gates[5].getY(), 10, - gates[5].getHeight()); + /** + * FIXME: needs major refactoring + */ + private void updateGates(List<ClientData> sortedClientDataList) { + ClientData thisClientData= clientDataModel.getClientData(); + for (int i = 1; i < 6; i++) { + if (gates[i - 1].isOpen()) { + if (restrictedVisibility && ! thisClientData.isImmediateNeighbor(sortedClientDataList.get(i-1))) { + continue; + } + if (!(gates[i - 1].getHeight() - gateHeight < 0)) { + gates[i].setHeight(gates[i - 1].getHeight() - gateHeight); - // particle system animation logic for the balls - graphics.setColor(Color.WHITE); - // int ballCounter = 0; - for (int i = 0; i < BALLCOUNT; i++) { - if ((balls[i].getPosition() == 1) || (balls[i].getPosition() == 2) - || (balls[i].getPosition() == 3) - || (balls[i].getPosition() == 4) - || (balls[i].getPosition() == 5)) { - if (!((!gates[balls[i].getPosition() - 1].isOpen()) && balls[i] - .getY() >= (gates[balls[i].getPosition() - 1].getY() + gates[balls[i] - .getPosition() - 1].getHeight()))) - graphics.fillOval(balls[i].x, balls[i].y, - balls[i].getBallSize(), balls[i].getBallSize()); - } else { - if (balls[i].getPosition() != 0) { - if (gates[balls[i].getPosition() - 6].getHeight() != 0) - graphics.fillOval(balls[i].x, balls[i].y, - balls[i].getBallSize(), balls[i].getBallSize()); - } else { - graphics.fillOval(balls[i].x, balls[i].y, - balls[i].getBallSize(), balls[i].getBallSize()); - } - } - } + } else { + gates[i].setHeight(0); + } + } else { + gates[i].setHeight(gates[i - 1].getHeight()); - } - - private void checkRestrictedVisibility() { - // 2 cases to check for: - if (! restrictedVisibility) return; - List<ClientData> sortedClients = clientDataModel.getClientDataSortedByPriority(); - ClientData thisClient = clientDataModel.getClientData(); - int thisClientIndex = sortedClients.indexOf(thisClient); - int upstreamNeighborIndex = thisClientIndex - 1; - int downstreamNeighborIndex = thisClientIndex + 1; - for (int i = 0; i < gates.length; i++) { - if (i < upstreamNeighborIndex && upstreamNeighborIndex > 0) { - ClientData upstreamNeighbor = sortedClients.get(upstreamNeighborIndex); - gates[i].setHeight(upstreamNeighbor.getAvailableFlowCapacity()); - } - else if (i > downstreamNeighborIndex && downstreamNeighborIndex < sortedClients.size()) { - ClientData downstreamNeighbor = sortedClients.get(downstreamNeighborIndex); - gates[i].setHeight(downstreamNeighbor.getAvailableFlowCapacity()); - } - } - } + } + // order matters here + if (!(i == 5)) { + gates[i].setOpeningsHeight((maximumIrrigationCapacity * canalHeightMultiplier) - gates[i].getHeight()); + gates[i].setOpeningsY(gates[i].getOpeningsHeight() - 50); - /** - * FIXME: needs major refactoring - */ - private void updateGates() { - for (int i = 1; i < 6; i++) { - if (gates[i - 1].isOpen()) { - if (!(gates[i - 1].getHeight() - gateHeight < 0)) { - gates[i].setHeight(gates[i - 1].getHeight() - gateHeight); + // opening gate logic + if (gates[i].isOpen()) { + if (restrictedVisibility && ! thisClientData.isImmediateNeighbor(sortedClientDataList.get(i))) { + continue; + } + gates[i].setx1(gates[i].getx2()); + if (!(gates[i].gety2() - gates[i].getGateWidth() < gates[i].getY())) + gates[i].sety1(gates[i].gety2() - gates[i].getGateWidth()); + else + gates[i].sety1(gates[i].getOpeningsY()); + } else { + gates[i].setx1(gates[i].getdefaultx1()); + gates[i].sety1(gates[i].getdefaulty1()); + } - } else { - gates[i].setHeight(0); - } - } else { - gates[i].setHeight(gates[i - 1].getHeight()); + if (gates[0].isOpen()) { + if (restrictedVisibility && ! thisClientData.isImmediateNeighbor(sortedClientDataList.get(0))) { + continue; + } + gates[0].setx1(gates[0].getx2()); + if (!(gates[0].gety2() - gates[0].getGateWidth() < gates[0] + .getY())) + gates[0].sety1(gates[0].gety2() + - gates[0].getGateWidth()); + else + gates[0].sety1(gates[0].getY()); + } else { + gates[0].setx1(gates[0].getdefaultx1()); + gates[0].sety1(gates[0].getdefaulty1()); + } - } - // order matters here - if (!(i == 5)) { - gates[i].setOpeningsHeight((maximumIrrigationCapacity * canalHeightMultiplier) - - gates[i].getHeight()); - gates[i].setOpeningsY(gates[i].getOpeningsHeight() - 50); + } + } + } - // opening gate logic - if (gates[i].isOpen()) { - gates[i].setx1(gates[i].getx2()); - if (!(gates[i].gety2() - gates[i].getGateWidth() < gates[i].getY())) - gates[i].sety1(gates[i].gety2() - gates[i].getGateWidth()); - else - gates[i].sety1(gates[i].getOpeningsY()); - } else { - gates[i].setx1(gates[i].getdefaultx1()); - gates[i].sety1(gates[i].getdefaulty1()); - } + /* + * initialize the Balls + */ + private void initializeBalls() { + balls = new Ball[BALLCOUNT]; + for (int i = 0; i < BALLCOUNT; i++) { + balls[i] = new Ball(generator); + } + } - if (gates[0].isOpen()) { - gates[0].setx1(gates[0].getx2()); - if (!(gates[0].gety2() - gates[0].getGateWidth() < gates[0] - .getY())) - gates[0].sety1(gates[0].gety2() - - gates[0].getGateWidth()); - else - gates[0].sety1(gates[0].getY()); - } else { - gates[0].setx1(gates[0].getdefaultx1()); - gates[0].sety1(gates[0].getdefaulty1()); - } + // this is the private class the Timer will look at every DELAY seconds + private class Rebound implements ActionListener { + public void actionPerformed(ActionEvent e) { + List<ClientData> sortedClients = clientDataModel.getClientDataSortedByPriority(); + ClientData thisClientData = clientDataModel.getClientData(); + for (int i = 0; i < BALLCOUNT; i++) { + // updateGUI(); + balls[i].x += balls[i].moveX; + balls[i].y += balls[i].moveY; + process(i, sortedClients, thisClientData); + } + repaint(); + } + } - } - } - } + /* + * This will process the balls according to their position + */ + private void process(int i, List<ClientData> sortedClients, ClientData thisClientData) { + + switch (balls[i].getPosition()) { - /* - * initialize the Balls - */ - private void initializeBalls() { - balls = new Ball[BALLCOUNT]; - for (int i = 0; i < BALLCOUNT; i++) { - balls[i] = new Ball(generator); - } - } + case 0: + if ((balls[i].x >= (reservoirWidth - gateBuffer) && balls[i].x <= reservoirWidth) + && (balls[i].y >= reservoirHeight - (int) (maximumIrrigationCapacity * canalHeightMultiplier) && balls[i].y <= reservoirHeight)) + { + balls[i].setPosition(1); + setBounds(i); + } + // still in server + else { + setBounds(i); + if (balls[i].x <= balls[i].xLowerBound + || balls[i].x >= balls[i].xUpperBound + - balls[i].getBallSize()) { + balls[i].moveX = balls[i].moveX * -1; + } + if (balls[i].y <= balls[i].yLowerBound + || balls[i].y >= balls[i].yUpperBound + - balls[i].getBallSize()) + balls[i].moveY = balls[i].moveY * -1; + } + break; - // this is the private class the Timer will look at every DELAY seconds - private class Rebound implements ActionListener { - public void actionPerformed(ActionEvent e) { - for (int i = 0; i < BALLCOUNT; i++) { - // updateGUI(); - balls[i].x += balls[i].moveX; - balls[i].y += balls[i].moveY; - process(i); - } - repaint(); - } - } + case 1: + if (gates[0].isOpen() + && (balls[i].x >= gates[0].getOpeningsX() && balls[i].x <= (gates[0].getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) + { + if (restrictedVisibility && sortedClients.get(0).isImmediateNeighbor(thisClientData) || ! restrictedVisibility) + { + // if we are in the restricted visibility condition AND gate 0 is an immediate neighbor of this client OR we are not in a restricted visibility condition at all, put this ball in the + // gate (or at least I *think* this is what Sanket's god-awful code is doing). + balls[i].setPosition(7); + // directly pass in the information + setBounds(i); + break; + } + } + // otherwise the gate is closed or we don't know enough about the gate, pass it on down + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(2); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; - /* - * This will process the balls according to their position - */ - private void process(int i) { - switch (balls[i].getPosition()) { + case 2: + if (gates[1].isOpen() + && (balls[i].x >= gates[1].getOpeningsX() && balls[i].x <= (gates[1] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) + { + if (!restrictedVisibility || (restrictedVisibility && sortedClients.get(1).isImmediateNeighbor(thisClientData))) { + balls[i].setPosition(8); + // directly pass in the information + setBounds(i); + break; + } + } + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(3); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; + case 3: + if (gates[2].isOpen() + && (balls[i].x >= gates[2].getOpeningsX() && balls[i].x <= (gates[2] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) + { + if (!restrictedVisibility || (restrictedVisibility && sortedClients.get(2).isImmediateNeighbor(thisClientData))) { + balls[i].setPosition(9); + // directly pass in the information + setBounds(i); + break; + } + } + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(4); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; + case 4: + if (gates[3].isOpen() + && (balls[i].x >= gates[3].getOpeningsX() && balls[i].x <= (gates[3] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) + { + if (!restrictedVisibility || (restrictedVisibility && !sortedClients.get(3).isImmediateNeighbor(thisClientData))) { + balls[i].setPosition(10); + // directly pass in the information + setBounds(i); + break; + } + } + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(5); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; + case 5: + if (gates[4].isOpen() + && (balls[i].x >= gates[4].getOpeningsX() && balls[i].x <= (gates[4] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) + { + if (!restrictedVisibility || (restrictedVisibility && !sortedClients.get(4).isImmediateNeighbor(thisClientData))) { + balls[i].setPosition(11); + // directly pass in the information + setBounds(i); + break; + } + } + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(6); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; + case 6: + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + setBallInServer(i); + } - case 0: - if ((balls[i].x >= (reservoirWidth - gateBuffer) && balls[i].x <= reservoirWidth) - && (balls[i].y >= reservoirHeight - - (int) (maximumIrrigationCapacity * canalHeightMultiplier) && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(1); - setBounds(i); - } - // still in server - else { - setBounds(i); - if (balls[i].x <= balls[i].xLowerBound - || balls[i].x >= balls[i].xUpperBound - - balls[i].getBallSize()) { - balls[i].moveX = balls[i].moveX * -1; - } - if (balls[i].y <= balls[i].yLowerBound - || balls[i].y >= balls[i].yUpperBound - - balls[i].getBallSize()) - balls[i].moveY = balls[i].moveY * -1; - } - break; + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + break; + } - case 1: - if (gates[0].isOpen() - && (balls[i].x >= gates[0].getOpeningsX() && balls[i].x <= (gates[0] - .getOpeningsX() + gateBuffer)) - && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(7); - // directly pass in the information - setBounds(i); - } else { - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - balls[i].setPosition(2); - } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - } + // set balls back to the server when they complete their flow in the + // gates + if ((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) + || (balls[i].getPosition() == 8) + || (balls[i].getPosition() == 9) + || (balls[i].getPosition() == 10)) { + if (balls[i].getY() >= 150) { + setBallInServer(i); + } else { + setBounds(i); + } + } + } - break; + private void setBallInServer(int i) { + generator.setSeed(i * (i + 1)); + balls[i].setX(generator.nextInt(reservoirWidth)); + balls[i].setY(generator.nextInt(reservoirHeight)); + balls[i].setPosition(0); + if (balls[i].moveX == 0) + balls[i].moveX = generator.nextInt(15); + setBounds(i); + } - case 2: - if (gates[1].isOpen() - && (balls[i].x >= gates[1].getOpeningsX() && balls[i].x <= (gates[1] - .getOpeningsX() + gateBuffer)) - && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(8); - // directly pass in the information - setBounds(i); - } else { - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - balls[i].setPosition(3); - } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - } - break; + private void setBounds(int ballIndex) { + // TODO Auto-generated method stub + // ball is in the server + if (balls[ballIndex].getPosition() == 0) { + balls[ballIndex].xUpperBound = reservoirWidth; + balls[ballIndex].xLowerBound = 0; + balls[ballIndex].yUpperBound = reservoirHeight; + balls[ballIndex].yLowerBound = 0; + // balls[ballIndex].moveX = generator.nextInt(6); + // balls[ballIndex].moveY = generator.nextInt(6); + // balls[ballIndex].moveX = 3; + // balls[ballIndex].moveY = 3; + } else { + if ((balls[ballIndex].getPosition() == 1) + || (balls[ballIndex].getPosition() == 2) + || (balls[ballIndex].getPosition() == 3) + || (balls[ballIndex].getPosition() == 4) + || (balls[ballIndex].getPosition() == 5) + || (balls[ballIndex].getPosition() == 6)) { - case 3: - if (gates[2].isOpen() - && (balls[i].x >= gates[2].getOpeningsX() && balls[i].x <= (gates[2] - .getOpeningsX() + gateBuffer)) - && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(9); - // directly pass in the information - setBounds(i); - /* - * balls[i].xBOUNDSUPPER = 420; balls[i].xLowerBound = 400; - * balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; - * balls[i].moveX = 0; balls[i].moveY = 3; - */ - } else { - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - balls[i].setPosition(4); - } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - } - break; + balls[ballIndex].xUpperBound = gates[balls[ballIndex].getPosition() - 1].getX() + + gates[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gates[balls[ballIndex].getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gates[balls[ballIndex].getPosition() - 1].getY() + /* + * +gate[balls[ballIndex]. + * getPosition() - + * 1].getHeight() + */; + balls[ballIndex].yLowerBound = gates[balls[ballIndex].getPosition() - 1].getY(); + } + // the ball is in one of the openings + else { + balls[ballIndex].xUpperBound = gates[balls[ballIndex] + .getPosition() - 7].getOpeningsX() + + gates[balls[ballIndex].getPosition() - 7].getGateWidth(); + balls[ballIndex].xLowerBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsY() + + gates[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); + balls[ballIndex].yLowerBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsY(); + // X change in motion + balls[ballIndex].moveX = 0; + // Y change in motion + balls[ballIndex].moveY = 3; + } + } + } - case 4: - if (gates[3].isOpen() - && (balls[i].x >= gates[3].getOpeningsX() && balls[i].x <= (gates[3] - .getOpeningsX() + gateBuffer)) - && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(10); - // directly pass in the information - setBounds(i); - } else { - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - balls[i].setPosition(5); - } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - } - break; + public void openGate(int priority) { + gates[priority].open(); + } - case 5: - if (gates[4].isOpen() - && (balls[i].x >= gates[4].getOpeningsX() && balls[i].x <= (gates[4] - .getOpeningsX() + gateBuffer)) - && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { - balls[i].setPosition(11); - // directly pass in the information - setBounds(i); - } else { - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - balls[i].setPosition(6); - } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - } - break; + public void closeGate(int priority) { + gates[priority].close(); + } - case 6: - setBounds(i); - if (balls[i].getX() > balls[i].xUpperBound) { - setBallInServer(i); - } + public void startRound() { + initializeGates(); + timer.start(); + } - if (balls[i].getY() >= balls[i].yUpperBound - - balls[i].getBallSize() - || balls[i].getY() <= balls[i].yLowerBound) { - balls[i].moveY = balls[i].moveY * -1; - } - break; - } + public void endRound() { + timer.stop(); + closeAllGates(); + } - // set balls back to the server when they complete their flow in the - // gates - if ((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) - || (balls[i].getPosition() == 8) - || (balls[i].getPosition() == 9) - || (balls[i].getPosition() == 10)) { - if (balls[i].getY() >= 150) { - setBallInServer(i); - } else { - setBounds(i); - } - } - } - - private void setBallInServer(int i) { - generator.setSeed(i * (i + 1)); - balls[i].setX(generator.nextInt(reservoirWidth)); - balls[i].setY(generator.nextInt(reservoirHeight)); - balls[i].setPosition(0); - if (balls[i].moveX == 0) - balls[i].moveX = generator.nextInt(15); - setBounds(i); - } - - private void setBounds(int ballIndex) { - // TODO Auto-generated method stub - // ball is in the server - if (balls[ballIndex].getPosition() == 0) { - balls[ballIndex].xUpperBound = reservoirWidth; - balls[ballIndex].xLowerBound = 0; - balls[ballIndex].yUpperBound = reservoirHeight; - balls[ballIndex].yLowerBound = 0; - // balls[ballIndex].moveX = generator.nextInt(6); - // balls[ballIndex].moveY = generator.nextInt(6); - // balls[ballIndex].moveX = 3; - // balls[ballIndex].moveY = 3; - } else { - if ((balls[ballIndex].getPosition() == 1) - || (balls[ballIndex].getPosition() == 2) - || (balls[ballIndex].getPosition() == 3) - || (balls[ballIndex].getPosition() == 4) - || (balls[ballIndex].getPosition() == 5) - || (balls[ballIndex].getPosition() == 6)) { - - balls[ballIndex].xUpperBound = gates[balls[ballIndex] - .getPosition() - 1].getX() - + gates[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xLowerBound = gates[balls[ballIndex] - .getPosition() - 1].getX(); - balls[ballIndex].yUpperBound = gates[balls[ballIndex] - .getPosition() - 1].getY()/* - * +gate[balls[ballIndex]. - * getPosition() - - * 1].getHeight() - */; - balls[ballIndex].yLowerBound = gates[balls[ballIndex] - .getPosition() - 1].getY(); - } - // the ball is in one of the openings - else { - balls[ballIndex].xUpperBound = gates[balls[ballIndex] - .getPosition() - 7].getOpeningsX() - + gates[balls[ballIndex].getPosition() - 7] - .getGateWidth(); - balls[ballIndex].xLowerBound = gates[balls[ballIndex] - .getPosition() - 7].getOpeningsX(); - balls[ballIndex].yUpperBound = gates[balls[ballIndex] - .getPosition() - 7].getOpeningsY() - + gates[balls[ballIndex].getPosition() - 7] - .getOpeningsHeight(); - balls[ballIndex].yLowerBound = gates[balls[ballIndex] - .getPosition() - 7].getOpeningsY(); - // X change in motion - balls[ballIndex].moveX = 0; - // Y change in motion - balls[ballIndex].moveY = 3; - } - } - } - - public void openGate(int priority) { - gates[priority].open(); - } - - public void closeGate(int priority) { - gates[priority].close(); - } - - public void startRound() { - initializeGates(); - timer.start(); - } - - public void endRound() { - timer.stop(); - closeAllGates(); - } - - private void closeAllGates() { - for (ClientData clientData : clientDataModel.getClientDataMap() - .values()) { - closeGate(clientData.getPriority()); - } - } + private void closeAllGates() { + for (ClientData clientData : clientDataModel.getClientDataMap().values()) { + closeGate(clientData.getPriority()); + } + } } diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -55,8 +55,20 @@ private JTextField chatField; public ChatPanel(IrrigationClient irrigationClient) { + this.irrigationClient = irrigationClient; initGuiComponents(); - setIrrigationClient(irrigationClient); + chatInstructionsPane.setText(irrigationClient.getServerConfiguration().getChatInstructions()); + irrigationClient.getEventChannel().add(this, new EventTypeProcessor<ChatEvent>(ChatEvent.class) { + public void handle(final ChatEvent chatEvent) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + displayMessage(getChatHandle(chatEvent.getSource()), + chatEvent.toString()); + } + }); + } + + }); } private class TextEntryPanel extends JPanel { @@ -81,7 +93,8 @@ // } // }); JPanel timeLeftPanel = new JPanel(); - timeLeftProgressBar = new JProgressBar(0, 60); + int chatDuration = irrigationClient.getServerConfiguration().getChatDuration(); + timeLeftProgressBar = new JProgressBar(0, chatDuration); timeLeftProgressBar.setStringPainted(true); timeLeftPanel.setLayout(new BorderLayout()); timeLeftPanel.add(timeLeftProgressBar, BorderLayout.CENTER); @@ -180,7 +193,7 @@ HANDLES = new String[participants.size()]; // FIXME: shuffle handles? for (int i = HANDLES.length; --i >= 0;) { - HANDLES[i] = " " + HANDLE_STRING.charAt(i) + " "; + HANDLES[i] = String.valueOf(HANDLE_STRING.charAt(i)); chatHandles.put(participants.get(i), HANDLES[i]); } } @@ -189,22 +202,6 @@ return irrigationClient.getId(); } - public void setIrrigationClient(IrrigationClient client) { - this.irrigationClient = client; - chatInstructionsPane.setText(irrigationClient.getServerConfiguration().getChatInstructions()); - client.getEventChannel().add(this, new EventTypeProcessor<ChatEvent>(ChatEvent.class) { - public void handle(final ChatEvent chatEvent) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - displayMessage(getChatHandle(chatEvent.getSource()), - chatEvent.toString()); - } - }); - } - - }); - } - public void setFocusInChatField() { chatField.requestFocusInWindow(); } diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -84,7 +84,7 @@ private HtmlEditorPane tokenInstructionsEditorPane; - private int quizzesAnswered = 0; +// private int quizzesAnswered = 0; private TokenContributionChartPanel tokenContributionChartPanel; @@ -464,7 +464,7 @@ if (currentQuizPageNumber <= getServerConfiguration().getNumberOfQuizPages()) { nextButton.setEnabled(true); } - quizzesAnswered++; +// quizzesAnswered++; client.transmit(new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers)); setInstructions(getQuizPage(), true); } @@ -519,7 +519,7 @@ GroupDataModel group = clientDataModel.getGroupDataModel(); RoundConfiguration roundConfiguration = clientDataModel.getRoundConfiguration(); int infrastructureEfficiency = 0; - if (roundConfiguration.shouldResetInfrastructureEfficiency()) { + if (roundConfiguration.isInfrastructureEfficiencyReset()) { infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { @@ -543,11 +543,12 @@ SwingUtilities.invokeLater(runnable); } + // FIXME: replace with StringTemplate public void updateRoundInstructions(RoundConfiguration roundConfiguration) { if (! roundConfiguration.isFirstRound()) { instructionsBuilder.append(roundConfiguration.getInstructions()); instructionsBuilder.append("<hr>"); - if (roundConfiguration.shouldResetInfrastructureEfficiency()) { + if (roundConfiguration.isInfrastructureEfficiencyReset()) { int initialInfrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); instructionsBuilder.append( String.format("The irrigation infrastructure efficiency has been reset to %d%% with a corresponding water delivery capacity of %d cfps.", diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/Gate.java --- a/src/main/java/edu/asu/commons/irrigation/client/Gate.java +++ b/src/main/java/edu/asu/commons/irrigation/client/Gate.java @@ -146,6 +146,10 @@ return open; } + public boolean isClosed() { + return ! open; + } + public void open() { setOpen(true); } diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java --- a/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java +++ b/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java @@ -223,10 +223,6 @@ return clientDataModel.getRoundConfiguration(); } - public void setRoundConfiguration(RoundConfiguration roundConfiguration) { - clientDataModel.setRoundConfiguration(roundConfiguration); - } - public ServerConfiguration getServerConfiguration() { return serverConfiguration; } diff -r 57521540750303c6cf1eff1cc75958f49b918e7f -r 4a9dbfb7521afe08e9cbcf2947843078f4090749 src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java @@ -12,6 +12,7 @@ import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PlotOrientation; @@ -55,12 +56,10 @@ private JFreeChart createChart(ClientDataModel clientDataModel) { boolean restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); if (restrictedVisibility) { - final CategoryDataset dataset = createCategoryDataset(clientDataModel); - return createBarChart(dataset); + return createBarChart(clientDataModel); } else { - final PieDataset dataset = createPieDataset(clientDataModel); - return createPieChart(dataset); + return createPieChart(clientDataModel); } } @@ -93,17 +92,20 @@ return defaultPieDataset; } - private JFreeChart createBarChart(final CategoryDataset dataset) { - JFreeChart chart = ChartFactory.createBarChart("Tokens Contributed", "Participant", "Tokens Invested", dataset, + private JFreeChart createBarChart(ClientDataModel clientDataModel) { + final CategoryDataset dataset = createCategoryDataset(clientDataModel); + JFreeChart chart = ChartFactory.createBarChart("Tokens Contributed by your Neighbors", "Participant", "Tokens Invested", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); - plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());... [truncated message content] |
From: Bitbucket <com...@bi...> - 2012-02-14 19:46:38
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/8f20bf11520c/ changeset: 8f20bf11520c user: hg date: 2012-02-14 20:34:25 summary: fixes issue 8 - renaming getNeighbors to reflect what its actually returning (ordered visible client data, including this client) affected #: 3 files diff -r 1bf48421a184f562f675a2f0db08b66a45c32f36 -r 8f20bf11520c339beb0e4de6cdcf9f00475839df src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java @@ -144,23 +144,28 @@ return serverConfiguration; } - public List<ClientData> getNeighbors() { - // FIXME: replace hard-coded immediate neighbor check with field of vision radius from RoundConfiguration - ArrayList<ClientData> neighbors = new ArrayList<ClientData>(); - List<ClientData> sortedClients = getClientDataSortedByPriority(); - ClientData thisClientData = getClientData(); - int thisClientIndex = sortedClients.indexOf(thisClientData); - if (thisClientIndex > 0) { - // upstream neighbor - neighbors.add(sortedClients.get(thisClientIndex - 1)); - } - // this is needed for the charts, but probably weird for general-purpose usage - neighbors.add(thisClientData); - if (thisClientIndex < sortedClients.size() - 1) { - // downstream neighbor - neighbors.add(sortedClients.get(thisClientIndex + 1)); - } - return neighbors; + public List<ClientData> getOrderedVisibleClients() { + if (getRoundConfiguration().isRestrictedVisibility()) { + // FIXME: replace hard-coded immediate neighbor check with field of vision radius from RoundConfiguration + ArrayList<ClientData> neighbors = new ArrayList<ClientData>(); + List<ClientData> sortedClients = getClientDataSortedByPriority(); + ClientData thisClientData = getClientData(); + int thisClientIndex = sortedClients.indexOf(thisClientData); + if (thisClientIndex > 0) { + // upstream neighbor + neighbors.add(sortedClients.get(thisClientIndex - 1)); + } + // this is needed for the charts, but probably weird for general-purpose usage + neighbors.add(thisClientData); + if (thisClientIndex < sortedClients.size() - 1) { + // downstream neighbor + neighbors.add(sortedClients.get(thisClientIndex + 1)); + } + return neighbors; + } + else { + return getClientDataSortedByPriority(); + } } diff -r 1bf48421a184f562f675a2f0db08b66a45c32f36 -r 8f20bf11520c339beb0e4de6cdcf9f00475839df src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java @@ -66,7 +66,7 @@ private CategoryDataset createCategoryDataset(ClientDataModel clientDataModel) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - List<ClientData> neighbors = clientDataModel.getNeighbors(); + List<ClientData> neighbors = clientDataModel.getOrderedVisibleClients(); for (ClientData neighbor: neighbors) { dataset.addValue(neighbor.getInvestedTokens(), "Tokens Invested", neighbor.getPriorityString()); } diff -r 1bf48421a184f562f675a2f0db08b66a45c32f36 -r 8f20bf11520c339beb0e4de6cdcf9f00475839df src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -376,7 +376,7 @@ <th>Quiz earnings</th><th>Total dollars earned</th></tr> - {dataModel.clientDataSortedByPriority: {clientData| + {dataModel.orderedVisibleClients: {clientData| <tr align='center' bgcolor='{if (clientData.self)}#FFFFCC{else}#CCCCCC{endif}'><td>{clientData.priorityString}</td><td>{self.tokenEndowment}</td> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-13 23:41:15
|
2 new commits in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/4709732f981a/ changeset: 4709732f981a user: alllee date: 2012-02-14 00:40:38 summary: fixing range errors in upstream/downstream check affected #: 1 file diff -r a00ac8fd4f1039a7d84e5d31ed75f513f35b5f3a -r 4709732f981a7ec93c5b5fabdb115c89c23a6f4c src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java @@ -112,6 +112,9 @@ } // checkRestrictedVisibility(); for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + if (restrictedVisibility && ! clientDataModel.isImmediateNeighbor(clientData)) { + continue; + } int priority = clientData.getPriority(); Gate gate = gates[priority]; graphics2D.setColor(Color.BLUE); @@ -162,11 +165,11 @@ int upstreamNeighborIndex = thisClientIndex - 1; int downstreamNeighborIndex = thisClientIndex + 1; for (int i = 0; i < gates.length; i++) { - if (i < upstreamNeighborIndex) { + if (i < upstreamNeighborIndex && upstreamNeighborIndex > 0) { ClientData upstreamNeighbor = sortedClients.get(upstreamNeighborIndex); gates[i].setHeight(upstreamNeighbor.getAvailableFlowCapacity()); } - else if (i > downstreamNeighborIndex) { + else if (i > downstreamNeighborIndex && downstreamNeighborIndex < sortedClients.size()) { ClientData downstreamNeighbor = sortedClients.get(downstreamNeighborIndex); gates[i].setHeight(downstreamNeighbor.getAvailableFlowCapacity()); } https://bitbucket.org/virtualcommons/irrigation/changeset/1bf48421a184/ changeset: 1bf48421a184 user: alllee date: 2012-02-14 00:40:54 summary: minor chart refinement affected #: 1 file diff -r 4709732f981a7ec93c5b5fabdb115c89c23a6f4c -r 1bf48421a184f562f675a2f0db08b66a45c32f36 src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java @@ -1,6 +1,7 @@ package edu.asu.commons.irrigation.client; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Font; import java.util.List; import java.util.Map; @@ -10,6 +11,8 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; @@ -92,7 +95,10 @@ private JFreeChart createBarChart(final CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Tokens Contributed", "Participant", "Tokens Invested", dataset, - PlotOrientation.HORIZONTAL, false, false, false); + PlotOrientation.VERTICAL, false, false, false); + CategoryPlot plot = chart.getCategoryPlot(); + plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + plot.getRenderer().setSeriesPaint(0, Color.BLUE); return chart; } Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-13 22:42:06
|
3 new commits in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/9602c8d8a26e/ changeset: 9602c8d8a26e user: alllee date: 2012-02-13 22:55:42 summary: fixes issue 5 but need to investigate why group data model was null for a given client id affected #: 1 file diff -r 7a29c06f067ac552ae7d2dd065a04e7bc2d4d8f5 -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Logger; import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; @@ -24,6 +25,8 @@ public class ServerDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = -2633842942700901843L; + + private final Logger logger = Logger.getLogger(getClass().getName()); // maps client Identifiers to the Group that client belongs to. private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); @@ -87,6 +90,10 @@ public void removeClient(Identifier id) { GroupDataModel groupDataModel = clientsToGroups.remove(id); + if (groupDataModel == null) { + logger.warning("No group data model associated with id: " + id); + return; + } groupDataModel.removeClient(id); } https://bitbucket.org/virtualcommons/irrigation/changeset/626e2bfc95ab/ changeset: 626e2bfc95ab user: alllee date: 2012-02-13 22:57:02 summary: changes for restricted visibility while minimizing the urge to entirely rewrite the spaghetti mess that is CanalPanel + Gate + Ball animation affected #: 8 files diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java @@ -6,6 +6,7 @@ import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; import java.util.Random; import javax.swing.JPanel; @@ -16,24 +17,27 @@ /** * $Id$ * - * @author Allen Lee, Sanket Joshi + * FIXME: completely rewrite horrifyingly convoluted animation logic + * + * @author Sanket Joshi */ public class CanalPanel extends JPanel { private static final long serialVersionUID = -6178860067928578812L; -// private Graphics2D graphics2D; + // private Graphics2D graphics2D; - //////////////////animation logic parameters////////////////////////////// + // ////////////////animation logic parameters////////////////////////////// private Timer timer; private final static int DELAY = 20; - private Ball balls[]; + private Ball[] balls; private final static int BALLCOUNT = 500; + private final static int NUMBER_OF_GATES = 6; - private Gate gates[] = new Gate[6]; + private Gate[] gates = new Gate[NUMBER_OF_GATES]; private int gateHeight = 20; @@ -43,150 +47,174 @@ private ClientDataModel clientDataModel; - private int numberOfGates = 6; - private int serverHeight = 100; - private int serverWidth = 100; + private int reservoirHeight = 100; - private double bandWidthCanalHeightMapping = 0.8; + private int reservoirWidth = 100; + + private double canalHeightMultiplier = 0.8; private int gateBuffer = 20; - private boolean restrictedVisibility; + private boolean restrictedVisibility; - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// public CanalPanel(ClientDataModel clientDataModel) { super(); - //when totalContributed bandwidth = 1.0, you dont see the canal line + // when totalContributed bandwidth = 1.0, you dont see the canal line setClientDataModel(clientDataModel); initialize(); } - + public void setClientDataModel(ClientDataModel clientDataModel) { - this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); - this.clientDataModel = clientDataModel; - restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); + this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); + this.clientDataModel = clientDataModel; + this.restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); } /** * */ private void initialize() { -// this.setSize(new Dimension(1098,150)); + // this.setSize(new Dimension(1098,150)); setLayout(new GridBagLayout()); setBackground(Color.WHITE); - //initialize each gate + // initialize each gate initializeGates(); initializeBalls(); - timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an action + timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an + // action // every DELAY times. - timer.start(); // starts the timer. + timer.start(); // starts the timer. + + } + + private void initializeGates() { + for (int i = 0; i < NUMBER_OF_GATES; i++) { + gates[i] = new Gate(maximumIrrigationCapacity, i); + } + } + + protected void paintComponent(Graphics graphics) { + super.paintComponent(graphics); // needed! + updateGates(); + Graphics2D graphics2D = (Graphics2D) graphics; + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(0, 0, reservoirHeight, reservoirWidth); + // draw gates + for (int i = 0; i < NUMBER_OF_GATES - 1; i++) { + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gates[i].getX(), gates[i].getY(), + gates[i].getWidth(), gates[i].getHeight()); + } + checkRestrictedVisibility(); + for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + int priority = clientData.getPriority(); + Gate gate = gates[priority]; + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gate.getOpeningsX(), gate.getOpeningsY(), + gate.getOpeningsWidth(), gate.getOpeningsHeight()); + graphics2D.setColor(Gate.DEFAULT_COLOR); + graphics2D.drawLine(gate.getx1(), gate.gety1(), gate.getx2(), + gate.gety2()); + } + + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gates[5].getX(), gates[5].getY(), 10, + gates[5].getHeight()); + + // particle system animation logic for the balls + graphics.setColor(Color.WHITE); + // int ballCounter = 0; + for (int i = 0; i < BALLCOUNT; i++) { + if ((balls[i].getPosition() == 1) || (balls[i].getPosition() == 2) + || (balls[i].getPosition() == 3) + || (balls[i].getPosition() == 4) + || (balls[i].getPosition() == 5)) { + if (!((!gates[balls[i].getPosition() - 1].isOpen()) && balls[i] + .getY() >= (gates[balls[i].getPosition() - 1].getY() + gates[balls[i] + .getPosition() - 1].getHeight()))) + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } else { + if (balls[i].getPosition() != 0) { + if (gates[balls[i].getPosition() - 6].getHeight() != 0) + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } else { + graphics.fillOval(balls[i].x, balls[i].y, + balls[i].getBallSize(), balls[i].getBallSize()); + } + } + } } - private void initializeGates() { - for(int i=0;i<numberOfGates ;i++){ - gates[i] = new Gate(maximumIrrigationCapacity,i); - } + private void checkRestrictedVisibility() { + // 2 cases to check for: + if (! restrictedVisibility) return; + List<ClientData> sortedClients = clientDataModel.getClientDataSortedByPriority(); + ClientData thisClient = clientDataModel.getClientData(); + int thisClientIndex = sortedClients.indexOf(thisClient); + int upstreamNeighborIndex = thisClientIndex - 1; + int downstreamNeighborIndex = thisClientIndex + 1; + for (int i = 0; i < gates.length; i++) { + if (i < upstreamNeighborIndex) { + ClientData upstreamNeighbor = sortedClients.get(upstreamNeighborIndex); + gates[i].setHeight(upstreamNeighbor.getAvailableFlowCapacity()); + } + else if (i > downstreamNeighborIndex) { + ClientData downstreamNeighbor = sortedClients.get(downstreamNeighborIndex); + gates[i].setHeight(downstreamNeighbor.getAvailableFlowCapacity()); + } + } } - protected void paintComponent(Graphics graphics){ - super.paintComponent(graphics); // needed! - updateGUI(); - Graphics2D graphics2D = (Graphics2D) graphics; - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(0,0,serverHeight,serverWidth); - //draw the other gates - for(int i=0;i<numberOfGates-1;i++){ - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gates[i].getX(), gates[i].getY(), gates[i].getWidth(),gates[i].getHeight()); - } - for (ClientData clientData: clientDataModel.getClientDataSortedByPriority()) { - // FIXME: this conditional preventing canalPanel.openGate has the unintended side effect of not updating the canal width properly. - if (restrictedVisibility && ! clientDataModel.isImmediateNeighbor(clientData)) { - continue; - } - int priority = clientData.getPriority(); - Gate gate = gates[priority]; + /** + * FIXME: needs major refactoring + */ + private void updateGates() { + for (int i = 1; i < 6; i++) { + if (gates[i - 1].isOpen()) { + if (!(gates[i - 1].getHeight() - gateHeight < 0)) { + gates[i].setHeight(gates[i - 1].getHeight() - gateHeight); - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gate.getOpeningsX(), gate.getOpeningsY(),gate.getOpeningsWidth(), - gate.getOpeningsHeight()); - graphics2D.setColor(Gate.DEFAULT_COLOR); - graphics2D.drawLine(gate.getx1(),gate.gety1(),gate.getx2(),gate.gety2()); - } - - graphics2D.setColor(Color.BLUE); - graphics2D.fillRect(gates[5].getX(), gates[5].getY(),10,gates[5].getHeight()); - - //////////////////////Animation Logic//////////////////////////// - graphics.setColor(Color.white); - // int ballCounter = 0; - for(int i=0;i<BALLCOUNT;i++){ - if((balls[i].getPosition() == 1)||(balls[i].getPosition() == 2) || (balls[i].getPosition()==3) - || (balls[i].getPosition() == 4) || (balls[i].getPosition() == 5)){ - if(!((!gates[balls[i].getPosition()-1].isOpen())&& balls[i].getY() >= (gates[balls[i].getPosition()-1].getY()+gates[balls[i].getPosition()-1].getHeight()))) - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - else{ - if(balls[i].getPosition() != 0){ - if(gates[balls[i].getPosition() - 6].getHeight() != 0) - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - else{ - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - } - } - - } - - - - private void updateGUI() { - for(int i=1;i<6;i++){ - if(gates[i-1].isOpen()){ - if(!(gates[i-1].getHeight() - gateHeight < 0)){ - gates[i].setHeight(gates[i-1].getHeight() - gateHeight ); - - } - else{ + } else { gates[i].setHeight(0); } - } - else{ - gates[i].setHeight(gates[i-1].getHeight()); + } else { + gates[i].setHeight(gates[i - 1].getHeight()); } - //order matters here - if(!(i == 5)){ - gates[i].setOpeningsHeight((maximumIrrigationCapacity*bandWidthCanalHeightMapping) + // order matters here + if (!(i == 5)) { + gates[i].setOpeningsHeight((maximumIrrigationCapacity * canalHeightMultiplier) - gates[i].getHeight()); gates[i].setOpeningsY(gates[i].getOpeningsHeight() - 50); - //opening the lid logic - if(gates[i].isOpen()){ + // opening gate logic + if (gates[i].isOpen()) { gates[i].setx1(gates[i].getx2()); - if(!(gates[i].gety2()- gates[i].getGateWidth() < gates[i].getY())) - gates[i].sety1(gates[i].gety2()- gates[i].getGateWidth()); + if (!(gates[i].gety2() - gates[i].getGateWidth() < gates[i].getY())) + gates[i].sety1(gates[i].gety2() - gates[i].getGateWidth()); else gates[i].sety1(gates[i].getOpeningsY()); - } - else{ + } else { gates[i].setx1(gates[i].getdefaultx1()); gates[i].sety1(gates[i].getdefaulty1()); } - if(gates[0].isOpen()){ + if (gates[0].isOpen()) { gates[0].setx1(gates[0].getx2()); - if(!(gates[0].gety2()- gates[0].getGateWidth() < gates[0].getY())) - gates[0].sety1(gates[0].gety2()- gates[0].getGateWidth()); + if (!(gates[0].gety2() - gates[0].getGateWidth() < gates[0] + .getY())) + gates[0].sety1(gates[0].gety2() + - gates[0].getGateWidth()); else gates[0].sety1(gates[0].getY()); - } - else{ + } else { gates[0].setx1(gates[0].getdefaultx1()); gates[0].sety1(gates[0].getdefaulty1()); } @@ -200,7 +228,7 @@ */ private void initializeBalls() { balls = new Ball[BALLCOUNT]; - for(int i=0;i<BALLCOUNT;i++){ + for (int i = 0; i < BALLCOUNT; i++) { balls[i] = new Ball(generator); } } @@ -208,10 +236,10 @@ // this is the private class the Timer will look at every DELAY seconds private class Rebound implements ActionListener { public void actionPerformed(ActionEvent e) { - for(int i=0;i<BALLCOUNT;i++){ - //updateGUI(); + for (int i = 0; i < BALLCOUNT; i++) { + // updateGUI(); balls[i].x += balls[i].moveX; - balls[i].y += balls[i].moveY; + balls[i].y += balls[i].moveY; process(i); } repaint(); @@ -221,183 +249,231 @@ /* * This will process the balls according to their position */ - private void process(int i){ - switch(balls[i].getPosition()) { + private void process(int i) { + switch (balls[i].getPosition()) { - case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(maximumIrrigationCapacity*bandWidthCanalHeightMapping) && - balls[i].y <= serverHeight)){ - balls[i].setPosition(1); + case 0: + if ((balls[i].x >= (reservoirWidth - gateBuffer) && balls[i].x <= reservoirWidth) + && (balls[i].y >= reservoirHeight + - (int) (maximumIrrigationCapacity * canalHeightMultiplier) && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(1); + setBounds(i); + } + // still in server + else { + setBounds(i); + if (balls[i].x <= balls[i].xLowerBound + || balls[i].x >= balls[i].xUpperBound + - balls[i].getBallSize()) { + balls[i].moveX = balls[i].moveX * -1; + } + if (balls[i].y <= balls[i].yLowerBound + || balls[i].y >= balls[i].yUpperBound + - balls[i].getBallSize()) + balls[i].moveY = balls[i].moveY * -1; + } + break; + + case 1: + if (gates[0].isOpen() + && (balls[i].x >= gates[0].getOpeningsX() && balls[i].x <= (gates[0] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(7); + // directly pass in the information + setBounds(i); + } else { + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(2); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + } + + break; + + case 2: + if (gates[1].isOpen() + && (balls[i].x >= gates[1].getOpeningsX() && balls[i].x <= (gates[1] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(8); + // directly pass in the information + setBounds(i); + } else { + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(3); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + } + break; + + case 3: + if (gates[2].isOpen() + && (balls[i].x >= gates[2].getOpeningsX() && balls[i].x <= (gates[2] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(9); + // directly pass in the information + setBounds(i); + /* + * balls[i].xBOUNDSUPPER = 420; balls[i].xLowerBound = 400; + * balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; + * balls[i].moveX = 0; balls[i].moveY = 3; + */ + } else { + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(4); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + } + break; + + case 4: + if (gates[3].isOpen() + && (balls[i].x >= gates[3].getOpeningsX() && balls[i].x <= (gates[3] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(10); + // directly pass in the information + setBounds(i); + } else { + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(5); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + } + break; + + case 5: + if (gates[4].isOpen() + && (balls[i].x >= gates[4].getOpeningsX() && balls[i].x <= (gates[4] + .getOpeningsX() + gateBuffer)) + && (balls[i].y >= reservoirHeight - gateBuffer && balls[i].y <= reservoirHeight)) { + balls[i].setPosition(11); + // directly pass in the information + setBounds(i); + } else { + setBounds(i); + if (balls[i].getX() > balls[i].xUpperBound) { + balls[i].setPosition(6); + } + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { + balls[i].moveY = balls[i].moveY * -1; + } + } + break; + + case 6: setBounds(i); - } - //still in server - else{ - setBounds(i); - if(balls[i].x <= balls[i].xLowerBound || balls[i].x >= balls[i].xUpperBound-balls[i].getBallSize()){ - balls[i].moveX = balls[i].moveX * -1; + if (balls[i].getX() > balls[i].xUpperBound) { + setBallInServer(i); } - if(balls[i].y <= balls[i].yLowerBound || balls[i].y >= balls[i].yUpperBound-balls[i].getBallSize()) + + if (balls[i].getY() >= balls[i].yUpperBound + - balls[i].getBallSize() + || balls[i].getY() <= balls[i].yLowerBound) { balls[i].moveY = balls[i].moveY * -1; - } - break; - - case 1: if(gates[0].isOpen() && (balls[i].x >= gates[0].getOpeningsX() && balls[i].x <= (gates[0].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(7); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - balls[i].setPosition(2); } - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } + break; } - break; - - case 2: if(gates[1].isOpen() && (balls[i].x >= gates[1].getOpeningsX() && balls[i].x <= (gates[1].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(8); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - balls[i].setPosition(3); - } - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - - - case 3: if(gates[2].isOpen() && (balls[i].x >= gates[2].getOpeningsX() && balls[i].x <= (gates[2].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(9); - //directly pass in the information - setBounds(i); - /* balls[i].xBOUNDSUPPER = 420; - balls[i].xLowerBound = 400; - balls[i].yBOUNDSUPPER = 150; - balls[i].yBOUNDSLOWER = 80; - balls[i].moveX = 0; - balls[i].moveY = 3;*/ - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - balls[i].setPosition(4); - } - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - - case 4: if(gates[3].isOpen() && (balls[i].x >= gates[3].getOpeningsX() && balls[i].x <= (gates[3].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(10); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - balls[i].setPosition(5); - } - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - - case 5: if(gates[4].isOpen() && (balls[i].x >= gates[4].getOpeningsX() && balls[i].x <= (gates[4].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(11); - //directly pass in the information - setBounds(i); - } - else { - setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - balls[i].setPosition(6); - } - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - - case 6: setBounds(i); - if(balls[i].getX() > balls[i].xUpperBound){ - setBallInServer(i); - } - - if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ - balls[i].moveY = balls[i].moveY*-1; - } - break; - } - - //set balls back to the server when they complete their flow in the gates - if((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) || (balls[i].getPosition() == 8) - || (balls[i].getPosition() == 9) || (balls[i].getPosition() == 10)){ - if(balls[i].getY() >= 150){ + // set balls back to the server when they complete their flow in the + // gates + if ((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) + || (balls[i].getPosition() == 8) + || (balls[i].getPosition() == 9) + || (balls[i].getPosition() == 10)) { + if (balls[i].getY() >= 150) { setBallInServer(i); - } - else{ + } else { setBounds(i); } } } - private void setBallInServer(int i) { - generator.setSeed(i*(i+1)); - balls[i].setX(generator.nextInt(serverWidth)); - balls[i].setY(generator.nextInt(serverHeight)); + generator.setSeed(i * (i + 1)); + balls[i].setX(generator.nextInt(reservoirWidth)); + balls[i].setY(generator.nextInt(reservoirHeight)); balls[i].setPosition(0); - if(balls[i].moveX == 0) + if (balls[i].moveX == 0) balls[i].moveX = generator.nextInt(15); setBounds(i); } private void setBounds(int ballIndex) { // TODO Auto-generated method stub - //ball is in the server - if(balls[ballIndex].getPosition() == 0){ - balls[ballIndex].xUpperBound = serverWidth; + // ball is in the server + if (balls[ballIndex].getPosition() == 0) { + balls[ballIndex].xUpperBound = reservoirWidth; balls[ballIndex].xLowerBound = 0; - balls[ballIndex].yUpperBound = serverHeight; + balls[ballIndex].yUpperBound = reservoirHeight; balls[ballIndex].yLowerBound = 0; - //balls[ballIndex].moveX = generator.nextInt(6); - //balls[ballIndex].moveY = generator.nextInt(6); - //balls[ballIndex].moveX = 3; - //balls[ballIndex].moveY = 3; - } - else{ - if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) - || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ + // balls[ballIndex].moveX = generator.nextInt(6); + // balls[ballIndex].moveY = generator.nextInt(6); + // balls[ballIndex].moveX = 3; + // balls[ballIndex].moveY = 3; + } else { + if ((balls[ballIndex].getPosition() == 1) + || (balls[ballIndex].getPosition() == 2) + || (balls[ballIndex].getPosition() == 3) + || (balls[ballIndex].getPosition() == 4) + || (balls[ballIndex].getPosition() == 5) + || (balls[ballIndex].getPosition() == 6)) { - balls[ballIndex].xUpperBound = gates[balls[ballIndex].getPosition() - 1].getX()+gates[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xLowerBound = gates[balls[ballIndex].getPosition() - 1].getX(); - balls[ballIndex].yUpperBound = gates[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; - balls[ballIndex].yLowerBound = gates[balls[ballIndex].getPosition() - 1].getY(); + balls[ballIndex].xUpperBound = gates[balls[ballIndex] + .getPosition() - 1].getX() + + gates[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gates[balls[ballIndex] + .getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gates[balls[ballIndex] + .getPosition() - 1].getY()/* + * +gate[balls[ballIndex]. + * getPosition() - + * 1].getHeight() + */; + balls[ballIndex].yLowerBound = gates[balls[ballIndex] + .getPosition() - 1].getY(); } - //the ball is in one of the openings - else{ - balls[ballIndex].xUpperBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsX()+gates[balls[ballIndex].getPosition() - 7].getGateWidth(); - balls[ballIndex].xLowerBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsX(); - balls[ballIndex].yUpperBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsY()+gates[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); - balls[ballIndex].yLowerBound = gates[balls[ballIndex].getPosition() - 7].getOpeningsY(); - //X change in motion + // the ball is in one of the openings + else { + balls[ballIndex].xUpperBound = gates[balls[ballIndex] + .getPosition() - 7].getOpeningsX() + + gates[balls[ballIndex].getPosition() - 7] + .getGateWidth(); + balls[ballIndex].xLowerBound = gates[balls[ballIndex] + .getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gates[balls[ballIndex] + .getPosition() - 7].getOpeningsY() + + gates[balls[ballIndex].getPosition() - 7] + .getOpeningsHeight(); + balls[ballIndex].yLowerBound = gates[balls[ballIndex] + .getPosition() - 7].getOpeningsY(); + // X change in motion balls[ballIndex].moveX = 0; - //Y change in motion + // Y change in motion balls[ballIndex].moveY = 3; } } @@ -410,21 +486,21 @@ public void closeGate(int priority) { gates[priority].close(); } - + public void startRound() { - initializeGates(); - timer.start(); + initializeGates(); + timer.start(); } public void endRound() { - timer.stop(); + timer.stop(); closeAllGates(); } - + private void closeAllGates() { - for (ClientData clientData: clientDataModel.getClientDataMap().values()) { - closeGate(clientData.getPriority()); - } + for (ClientData clientData : clientDataModel.getClientDataMap() + .values()) { + closeGate(clientData.getPriority()); + } } } - diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/ChartWindowPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChartWindowPanel.java +++ /dev/null @@ -1,197 +0,0 @@ - -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2004, by Object Refinery Limited and Contributors. - * - * Project Info: http://www.jfree.org/jfreechart/index.html - * - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation; - * either version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this - * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * ----------------- - * XYSeriesDemo.java - * ----------------- - * (C) Copyright 2002-2004, by Object Refinery Limited and Contributors. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; - * - * $Id$ - * - * Changes - * ------- - * 08-Apr-2002 : Version 1 (DG); - * 11-Jun-2002 : Inserted value out of order to see that it works (DG); - * 11-Oct-2002 : Fixed issues reported by Checkstyle (DG); - * - */ - -package edu.asu.commons.irrigation.client; - -import java.awt.CardLayout; -import java.awt.Dimension; -import java.awt.GridLayout; - -import javax.swing.JPanel; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.xy.XYSeries; -import org.jfree.data.xy.XYSeriesCollection; - - -/** - * A simple demo showing a dataset created using the {@link XYSeriesCollection} class. - * - */ -public class ChartWindowPanel extends JPanel { - - private static final long serialVersionUID = 5555080117985336199L; - - private JPanel jPanel; - - /** - * A demonstration application showing an XY series containing a null value. - * - * @param title the frame title. - */ - public ChartWindowPanel(int numberofFilesDownloaded) { - initialize(numberofFilesDownloaded); - } - - public void initialize(int numberofFilesDownloaded) { - setLayout(new CardLayout()); - setSize(new Dimension(530/2, 326/2)); - //this.setSize(screenSize.width, screenSize.height); - add(getJPanel(numberofFilesDownloaded), getJPanel(numberofFilesDownloaded).getName()); - repaint(); - - } - - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel(int numberofFilesDownloaded) { - if (jPanel == null) { - jPanel = new JPanel(); - GridLayout gridLayout = new GridLayout(); - gridLayout.setColumns(2); - jPanel.setLayout(gridLayout); - jPanel.add(getchartPanel(numberofFilesDownloaded)); - //jPanel.add(getchartPanel1()); - jPanel.setName("jPanel"); - } - return jPanel; - } - - private ChartPanel getchartPanel(int xUnit) { - final XYSeries series = new XYSeries("Crops Grown Award Function"); - double x,y; - for(x= 0;x<=xUnit;x++){ - y = fileAwardFunction((int)x); - series.add(x,y); - repaint(); - } - final XYSeriesCollection data = new XYSeriesCollection(series); - final JFreeChart chart = ChartFactory.createXYLineChart( - "Irrigation Infrastructure", - "Crops Grown", - "Tokens Earned", - data, - PlotOrientation.VERTICAL, - true, - true, - false - ); - final ChartPanel chartPanel = new ChartPanel(chart); - chartPanel.setLayout(new CardLayout()); - chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); - return chartPanel; - } - - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - - // **************************************************************************** - // * JFREECHART DEVELOPER GUIDE * - // * The JFreeChart Developer Guide, written by David Gilbert, is available * - // * to purchase from Object Refinery Limited: * - // * * - // * http://www.object-refinery.com/jfreechart/guide.html * - // * * - // * Sales are used to provide funding for the JFreeChart project - please * - // * support us so that we can continue developing free software. * - // **************************************************************************** - private int fileAwardFunction(final int infrastructureEfficiency) { - if (infrastructureEfficiency <= 45) { - return 0; - } - else if (infrastructureEfficiency <= 51) { - return 5; - } - else if (infrastructureEfficiency <= 55) { - return 10; - } - else if (infrastructureEfficiency <= 58) { - return 15; - } - else if (infrastructureEfficiency <= 61) { - return 20; - } - else if (infrastructureEfficiency <= 65) { - return 25; - } - else if (infrastructureEfficiency <= 70) { - return 30; - } - else if (infrastructureEfficiency <= 80) { - return 35; - } - else if (infrastructureEfficiency <= 100) { - return 40; - } - return 40; -// double B = 0; -// double alpha,b,a,num,deno; -// /** -// * This would be taken by a proper configuration file -// */ -// //alpha = getCurrentRoundConfiguration().getAlpha(); -// //a = getCurrentRoundConfiguration().getA(); -// //b = getCurrentRoundConfiguration().getB(); -// -// alpha = 20; -// a = 5; -// b = 6; -// -// num = alpha * Math.pow((double)totalTokens,b); -// deno = Math.pow(a,b)+Math.pow(totalTokens,b); -// -// //num = alpha; -// //deno = 1+java.lang.Math.exp(-b*(totalTokens - a)); -// B = num/deno; -// //Bt = totalTokens; -// return Math.round(B); - } -} diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java @@ -52,7 +52,6 @@ return getClientData().getPriorityString(); } - public Identifier getId() { return client.getId(); } @@ -105,12 +104,15 @@ } public Map<Identifier, ClientData> getClientDataMap() { - return groupDataModel.getClientDataMap(); + Map<Identifier, ClientData> clientDataMap = groupDataModel.getClientDataMap(); + // used by StringTemplate to determine whether or not the ClientData it's rendering values for + // is this client. + getClientData().setSelf(true); + return clientDataMap; } public List<ClientData> getClientDataSortedByPriority() { - Map<Identifier, ClientData> clientDataMap = getGroupDataModel().getClientDataMap(); - clientDataMap.get(getId()).setSelf(true); + Map<Identifier, ClientData> clientDataMap = getClientDataMap(); ArrayList<ClientData> clientDataList = new ArrayList<ClientData>(clientDataMap.values()); // sort by priority Collections.sort(clientDataList, new Comparator<ClientData>() { @@ -142,5 +144,24 @@ return serverConfiguration; } + public List<ClientData> getNeighbors() { + // FIXME: replace hard-coded immediate neighbor check with field of vision radius from RoundConfiguration + ArrayList<ClientData> neighbors = new ArrayList<ClientData>(); + List<ClientData> sortedClients = getClientDataSortedByPriority(); + ClientData thisClientData = getClientData(); + int thisClientIndex = sortedClients.indexOf(thisClientData); + if (thisClientIndex > 0) { + // upstream neighbor + neighbors.add(sortedClients.get(thisClientIndex - 1)); + } + // this is needed for the charts, but probably weird for general-purpose usage + neighbors.add(thisClientData); + if (thisClientIndex < sortedClients.size() - 1) { + // downstream neighbor + neighbors.add(sortedClients.get(thisClientIndex + 1)); + } + return neighbors; + } + } diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -86,7 +86,7 @@ private int quizzesAnswered = 0; - private TokenInvestmentPieChartPanel pieChart; + private TokenContributionChartPanel tokenContributionChartPanel; // private CanalAnimationPanel canalAnimationPanel; @@ -473,12 +473,13 @@ } public void displayContributionInformation(final ClientData clientData) { - final String contributionSummary = clientDataModel.getRoundConfiguration().generateContributionSummary(clientData); + final RoundConfiguration configuration = clientDataModel.getRoundConfiguration(); + final String contributionSummary = configuration.generateContributionSummary(clientData); SwingUtilities.invokeLater(new Runnable() { public void run() { contributionInformationEditorPane.setText(contributionSummary); infrastructureEfficiencyChartPanel.initialize(); - pieChart.initialize(clientData); + tokenContributionChartPanel.initialize(clientDataModel); addCenterComponent(getContributionInformationPanel()); } }); @@ -490,7 +491,7 @@ contributionInformationPanel = new JPanel(); contributionInformationPanel.setName("Graph panel"); contributionInformationPanel.setLayout(new BoxLayout(contributionInformationPanel, BoxLayout.Y_AXIS)); - contributionInformationPanel.add(createPieChartPanel()); + contributionInformationPanel.add(createTokenContributionChartPanel()); contributionInformationPanel.add(Box.createVerticalStrut(15)); contributionInformationEditorPane = UserInterfaceUtils.createInstructionsEditorPane(); contributionInformationPanel.add(contributionInformationEditorPane); @@ -498,16 +499,16 @@ return contributionInformationPanel; } - private JPanel createPieChartPanel() { + private JPanel createTokenContributionChartPanel() { JPanel panel = new JPanel(); infrastructureEfficiencyChartPanel = new InfrastructureEfficiencyChartPanel(client); - pieChart = new TokenInvestmentPieChartPanel(); + tokenContributionChartPanel = new TokenContributionChartPanel(); GridLayout gridLayout = new GridLayout(); gridLayout.setRows(1); gridLayout.setColumns(2); panel.setLayout(gridLayout); panel.add(infrastructureEfficiencyChartPanel); - panel.add(pieChart); + panel.add(tokenContributionChartPanel); return panel; } diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/GamePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java @@ -30,9 +30,9 @@ /** * $Id$ * - * Primary in-round game interface window for the irrigation game. Displays the + * Primary in-round game interface window for the irrigation game * - * FIXME: refactor layout, currently a hodge podge of fixed sizes... + * FIXME: refactor layout, currently a hodge podge of fixed sizes * * @author <a href='mailto:All...@as...'>Allen Lee</a>, Sanket Joshi * @version $Rev$ diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java @@ -71,8 +71,6 @@ for (int y = 0; y <= irrigationCapacityBeforeInvestment; y++) { preInvestmentInfrastructureEfficiencySeries.add(infrastructureEfficiencyBeforeInvestment, y); } - - final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(potentialInfrastructureEfficiencySeries); data.addSeries(waterSupplySeries); diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java --- /dev/null +++ b/src/main/java/edu/asu/commons/irrigation/client/TokenContributionChartPanel.java @@ -0,0 +1,118 @@ +package edu.asu.commons.irrigation.client; + +import java.awt.BorderLayout; +import java.awt.Font; +import java.util.List; +import java.util.Map; + +import javax.swing.JPanel; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; + +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Presents the group contributions as a pie chart. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class TokenContributionChartPanel extends JPanel { + + private static final long serialVersionUID = -5382293105043214105L; + + private ChartPanel chartPanel; + + public TokenContributionChartPanel() { + setLayout(new BorderLayout()); + } + + public void initialize(final ClientDataModel clientDataModel) { + JFreeChart chart = createChart(clientDataModel); + if (chartPanel != null) { + remove(chartPanel); + } + chartPanel = new ChartPanel(chart); + add(chartPanel, BorderLayout.CENTER); + revalidate(); + } + + private JFreeChart createChart(ClientDataModel clientDataModel) { + boolean restrictedVisibility = clientDataModel.getRoundConfiguration().isRestrictedVisibility(); + if (restrictedVisibility) { + final CategoryDataset dataset = createCategoryDataset(clientDataModel); + return createBarChart(dataset); + } + else { + final PieDataset dataset = createPieDataset(clientDataModel); + return createPieChart(dataset); + } + } + + private CategoryDataset createCategoryDataset(ClientDataModel clientDataModel) { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + List<ClientData> neighbors = clientDataModel.getNeighbors(); + for (ClientData neighbor: neighbors) { + dataset.addValue(neighbor.getInvestedTokens(), "Tokens Invested", neighbor.getPriorityString()); + } + return dataset; + } + + /** + * Creates and returns a pie dataset from the token contributions for the entire group. + * @return a pie dataset + */ + private PieDataset createPieDataset(ClientDataModel clientDataModel) { + final DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); + GroupDataModel groupDataModel = clientDataModel.getGroupDataModel(); + Map<Identifier,ClientData> clientDataMap = groupDataModel.getClientDataMap(); + for (ClientData clientData : clientDataMap.values()) { + StringBuilder labelBuilder = new StringBuilder(); + labelBuilder.append(clientData.getPriorityString()); + if (clientData.getId().equals(clientDataModel.getId())) { + labelBuilder.append(" (You)"); + } + labelBuilder.append(" invested ").append(clientData.getInvestedTokens()).append(" token(s)"); + defaultPieDataset.setValue(labelBuilder.toString(), clientData.getInvestedTokens()); + } + return defaultPieDataset; + } + + private JFreeChart createBarChart(final CategoryDataset dataset) { + JFreeChart chart = ChartFactory.createBarChart("Tokens Contributed", "Participant", "Tokens Invested", dataset, + PlotOrientation.HORIZONTAL, false, false, false); + return chart; + } + + private JFreeChart createPieChart(final PieDataset dataset) { + + final JFreeChart chart = ChartFactory.createPieChart( + "Tokens Contributed", // chart title + dataset, // data + false, // include legend + true, + false + ); + + final PiePlot plot = (PiePlot) chart.getPlot(); + //plot.setLabelGenerator(new CustomLabelGenerator()); + plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); + plot.setNoDataMessage("No contributions were made."); + plot.setCircular(false); + plot.setLabelGap(0.02); + return chart; + } + +} diff -r 9602c8d8a26e8ae77bdab206ae7a281ebc25063e -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java +++ /dev/null @@ -1,88 +0,0 @@ -package edu.asu.commons.irrigation.client; - -import java.awt.BorderLayout; -import java.awt.Font; -import java.util.Map; - -import javax.swing.JPanel; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PiePlot; -import org.jfree.data.general.DefaultPieDataset; -import org.jfree.data.general.PieDataset; - -import edu.asu.commons.irrigation.model.ClientData; -import edu.asu.commons.irrigation.model.GroupDataModel; -import edu.asu.commons.net.Identifier; - -/** - * $Id$ - * - * Presents the group contributions as a pie chart. - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class TokenInvestmentPieChartPanel extends JPanel { - - private static final long serialVersionUID = -5382293105043214105L; - - private ChartPanel chartPanel; - - public TokenInvestmentPieChartPanel() { - setLayout(new BorderLayout()); - } - - public void initialize(final ClientData clientData) { - final PieDataset dataset = createPieDataset(clientData); - final JFreeChart chart = createChart(dataset); - if (chartPanel != null) { - remove(chartPanel); - } - chartPanel = new ChartPanel(chart); - add(chartPanel, BorderLayout.CENTER); - revalidate(); - } - - /** - * Creates a pie dataset out of the client - * @return a sample dataset. - */ - private PieDataset createPieDataset(ClientData thisClientData) { - final DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); - GroupDataModel groupDataModel = thisClientData.getGroupDataModel(); - Map<Identifier,ClientData>clientDataMap = groupDataModel.getClientDataMap(); - for (ClientData clientData : clientDataMap.values()) { - StringBuilder labelBuilder = new StringBuilder(); - labelBuilder.append(clientData.getPriorityString()); - if (clientData.getId().equals(thisClientData.getId())) { - labelBuilder.append(" (You)"); - } - labelBuilder.append(" invested ").append(clientData.getInvestedTokens()).append(" token(s)"); - defaultPieDataset.setValue(labelBuilder.toString(), clientData.getInvestedTokens()); - } - return defaultPieDataset; - } - - private JFreeChart createChart(final PieDataset dataset) { - - final JFreeChart chart = ChartFactory.createPieChart( - "Tokens Contributed", // chart title - dataset, // data - false, // include legend - true, - false - ); - - final PiePlot plot = (PiePlot) chart.getPlot(); - //plot.setLabelGenerator(new CustomLabelGenerator()); - plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); - plot.setNoDataMessage("No contributions were made."); - plot.setCircular(false); - plot.setLabelGap(0.02); - return chart; - } - -} https://bitbucket.org/virtualcommons/irrigation/changeset/a00ac8fd4f10/ changeset: a00ac8fd4f10 user: alllee date: 2012-02-13 23:41:46 summary: - marking logger as transient to avoid serializability issues - fixing client-debriefing template, was missing a closing endif, and adding clientData explicitly to template attribute set affected #: 4 files diff -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce -r a00ac8fd4f1039a7d84e5d31ed75f513f35b5f3a src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java @@ -99,6 +99,7 @@ protected void paintComponent(Graphics graphics) { super.paintComponent(graphics); // needed! + checkRestrictedVisibility(); updateGates(); Graphics2D graphics2D = (Graphics2D) graphics; graphics2D.setColor(Color.BLUE); @@ -109,7 +110,7 @@ graphics2D.fillRect(gates[i].getX(), gates[i].getY(), gates[i].getWidth(), gates[i].getHeight()); } - checkRestrictedVisibility(); +// checkRestrictedVisibility(); for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { int priority = clientData.getPriority(); Gate gate = gates[priority]; diff -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce -r a00ac8fd4f1039a7d84e5d31ed75f513f35b5f3a src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -184,6 +184,7 @@ for (ClientData clientData: clientDataModel.getClientDataMap().values()) { populateClientEarnings(clientData, getParentConfiguration(), formatter); } + st.add("clientData", clientDataModel.getClientData()); st.add("dataModel", clientDataModel); st.add("showUpPayment", formatter.format(getParentConfiguration().getShowUpPayment())); st.add("showExitInstructions", showExitInstructions); @@ -200,5 +201,9 @@ private String getContributionSummaryTemplate() { return getProperty("contribution-summary"); } + + public int getChatDuration() { + return getIntProperty("chat-duration"); + } } diff -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce -r a00ac8fd4f1039a7d84e5d31ed75f513f35b5f3a src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java @@ -26,7 +26,7 @@ private static final long serialVersionUID = -2633842942700901843L; - private final Logger logger = Logger.getLogger(getClass().getName()); + private transient final Logger logger = Logger.getLogger(getClass().getName()); // maps client Identifiers to the Group that client belongs to. private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); diff -r 626e2bfc95abbd5ad01281f98db7ef2417cdd9ce -r a00ac8fd4f1039a7d84e5d31ed75f513f35b5f3a src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -377,7 +377,7 @@ <th>Total dollars earned</th></tr> {dataModel.clientDataSortedByPriority: {clientData| - <tr align='center' bgcolor='#{if (clientData.self)}FFFFCC{else}CCCCCC{endif}'> + <tr align='center' bgcolor='{if (clientData.self)}#FFFFCC{else}#CCCCCC{endif}'><td>{clientData.priorityString}</td><td>{self.tokenEndowment}</td><td>{clientData.investedTokens}</td> @@ -410,6 +410,7 @@ and <b>bring all your belongings with you</b> when you come up to receive your payment to help us speed up the payment process. </p> + {endif} ]]></entry><entry key="same-as-previous-round-instructions"> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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 <iss...@bi...> - 2012-02-09 04:04:03
|
--- you can reply above this line --- New issue 34: upgrade to qtip2 https://bitbucket.org/virtualcommons/vcweb/issue/34/upgrade-to-qtip2 A Lee / alllee on Thu, 9 Feb 2012 05:03:57 +0100: Description: http://craigsworks.com/projects/qtip2/ Responsible: alllee -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. |
From: Bitbucket <com...@bi...> - 2012-02-09 02:02:55
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/7a29c06f067a/ changeset: 7a29c06f067a user: alllee date: 2012-02-09 03:02:50 summary: adding instruction script LaTeX file from Marty and fixing logic in isRestrictedVisibility affected #: 3 files diff -r 5751595194cba562f21cdd240242f966b0ba25d7 -r 7a29c06f067ac552ae7d2dd065a04e7bc2d4d8f5 src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -107,8 +107,15 @@ // and refer to them as self.durationInMinutes or self.dollarsPerTokenCurrencyString, etc. template.add("duration", inMinutes(getDuration()) + " minutes"); template.add("dollarsPerToken", toCurrencyString(getDollarsPerToken())); + if (isRestrictedVisibility()) { + template.add("specialInstructions", getRestrictedVisibilityInstructions()); + } return template.render(); - } + } + + private String getRestrictedVisibilityInstructions() { + return render(getProperty("restricted-visibility-instructions")); + } public boolean shouldDisplayGroupTokens() { return getBooleanProperty("display-group-tokens"); @@ -149,7 +156,7 @@ } public boolean isRestrictedVisibility() { - return getFieldOfVision() < 0; + return getFieldOfVision() > 0; } /** diff -r 5751595194cba562f21cdd240242f966b0ba25d7 -r 7a29c06f067ac552ae7d2dd065a04e7bc2d4d8f5 src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -311,7 +311,7 @@ <![CDATA[ <p> You have been endowed with {self.tokenEndowment} tokens to invest. You must make a decision about -how much you wish to invest in the irrigation infrastructure (choosing a number +how much you wish to invest in the irrigation infrastructure by choosing a number between 0 and {self.tokenEndowment}. You can see the relationship between total investment and irrigation infrastructure in the table below. After you have entered the number of tokens you'd like to invest, hit the enter key or click the submit @@ -417,6 +417,7 @@ <h3>Round {self.roundNumber} Instructions</h3><hr><p>Round {self.roundNumber} is the same as the previous round.</p> + <p>{self.specialInstructions}</p><p>The length of this round is {duration}.</p><p><b>Do you have any questions?</b> If you have any questions at this time please raise your hand and someone will come over to your station and @@ -445,4 +446,7 @@ </table> ]]></entry> +<entry key="restricted-visibility-instructions"> + <![CDATA[<p><b>You can only communicate with and observe the actions of your immediate neighbors.</b></p>]]> +</entry></properties> diff -r 5751595194cba562f21cdd240242f966b0ba25d7 -r 7a29c06f067ac552ae7d2dd065a04e7bc2d4d8f5 src/main/resources/tex/instruction_script.tex --- /dev/null +++ b/src/main/resources/tex/instruction_script.tex @@ -0,0 +1,317 @@ +\documentclass[11pt]{article} + +\textwidth=6.5in +\textheight=9in +\oddsidemargin=0in + +\usepackage{graphicx} +\usepackage{epic} +\usepackage{eepic} + +\begin{document} + + +\section*{Overall scheme of instructions and practice} + +\begin{itemize} + +\item[-] Introduction to experiment [text] +\item[-] chat [``type in hi''] +\item[-] investment page [``explain and type in 7''] +\item[-] result investments [explain] +\item[-] screenshot crop growing [explain] +\item[-] 50 seconds crop growing +\item[-] results view of practice round 1 +\item[-] quiz questions +\item[-] give answers to questions [store answers from participants] +\item[-] do practice round 2 +\item[-] Experiment start 10 rounds + 10 rounds +\end{itemize} + +\newpage + +\section*{General Introduction} + + +{\bf [WHEN PEOPLE COME IN THE SCREEN GIVES A WELCOME MESSAGE. WHEN + EVERYBODY IS READY ALLEN WILL START THE GAME]}\\ + +Welcome, I am Dr. Anderies, a professor here at ASU and we will conduct a +decision-making exercise today. Allen Lee will assist me during the +exercise. Before we go to the instructions, I will ask you to turn +off any mobile phones and other mobile devices that might disrupt +the exercise. I also ask that you not speak during the exercise. If +you have a question, raise your hand, and I will address your +question.\\ + +This exercise consists of two practice rounds and twenty rounds for +real. Each round is about two minutes.\\ + +\noindent{\bf [TELL ALLEN: START INSTRUCTION SCREEN]}\\ + +Carefully read the instructions on the screen. Because it is important +for the results that you understand the instructions, I will also read +the instructions out loud. You will be able to earn money in this +exercise based on the decisions you are making and the decisions the +participants in your group are making. + +\newpage + +\section{General Instructions} + + +You have already earned 5 dollars by showing up for this exercise. You +can earn more, up to an extra 30 dollars. \\ + +You will participate in this exercise as a part of a group of five +participants. Your group has been formed by randomly assigning you to +FOUR other participants in +the room.\\ + +The amount of money you earn will depend on the decisions made by you +and the other members of your group.\\ + +This exercise mimics decisions people make in irrigation systems. \\ + +In each round you will receive 10 tokens which you can invest in the +irrigation infrastructure. Based on the water delivery capacity of the +irrigation infrastructure and the availability of water you will be able to grow crops. \\ + +Tokens earned in a round is the sum of tokens not invested plus tokens +earned by growing crops. Each token is worth 5 cents. \\ + +In each round you will first decide how much to invest in the +irrigation infrastructure. Based on the combined contributions of all +5 participants in your group in each round, your group can maintain +the capacity of the irrigation infrastructure for growing crops. \\ + + +Before each round in this experiment you will have a chat period of 60 +seconds where you can send text messages to the other participants. + +In this experiment you can only communicate with and observe the actions of your +immediate neighbors. This will become more clear after we begin the practice round. + + +You may discuss any aspect of the exercise with two important +exceptions: You are not allowed to promise the other participants +side-payments or threaten them with any consequence after the +experiment is finished. You are not allowed to reveal your real +identity. We will be monitoring the chat traffic. If we detect any +violation of these rules, we will have to remove all members of the +group where the violation occurred from the experiment. That group +will have to wait until the entire experiment is finished to receive +payment. \\ + +We will now start a practice round to help illustrate the experiment. \\ + +These practice rounds will not contribute to your earnings. They are only intended +to acquaint you with the functioning of the experimental environment.\\ + + +\noindent{\bf[TELL ALLEN: START CHAT ROUND]} + +\newpage + +\newcommand{\xdim}{65} +\newcommand{\ydim}{50} +\setlength{\unitlength}{0.1in} +\begin{picture}(\xdim,\ydim) + \put(0,0){\includegraphics[width=6.5in]{chat.eps}} + \put(20,20){\fbox{\parbox[t]{4in}{\bf Instructions to subjects: \\ + You will see a text box appear on your screen when a chat + period starts. Enter text in the text box at the bottom. The + time left in the chat period is shown just above the text + box.\\[0mm] + [TELL SUBJECTS: JUST SAY HI TO OTHER PEOPLE IN YOUR GROUP]}}} + %\input{graphpaper.tex} +\end{picture} + +\hfill \\ + +\noindent{\bf[MOVE ON TO INVESTMENT PAGE]} \\ + +\noindent{\bf[Explain investment table to subjects]}\\ + +At the beginning of each round, each participant will be given 10 +tokens. You must then decide what to do with these tokens. You may +decide to invest some tokens in the irrigation infrastructure or to keep +the tokens. For example, if you keep the tokens, you will earn 10 +tokens in that round. On the other hand, if you invest some tokens in +the irrigation infrastructure, you may be able to earn more than this +amount by growing crops. In fact, by growing crops you can triple your +earnings compared to doing nothing. But note that the actual earnings +depend on what you and the other participants in the experiment do. + +\newpage + + +\renewcommand{\xdim}{75} +\renewcommand{\ydim}{90} +\setlength{\unitlength}{0.1in} +\begin{picture}(\xdim,\ydim) + \put(0,35){\includegraphics[width=6.5in]{invest.eps}} + \put(40,33){\includegraphics[width=2.7in,height=3in]{white_square.eps}} + \put(39,40){\vector(-2,1){11.5}} + \put(40,60){\fbox{\parbox[t]{2.7in}{\bf 2. Instructions to subjects: + \\The investment of all five participants is added together + and will amount to between 0 and 50 tokens. Each token + invested will increase the efficiency of the system by + one percentage point up to a maximum of 100\%. In the table + you will see the water delivery capacity measured in water + units per second as a function of condition of the irrigation + infrastructure. When the infrastructure is at 100\% + efficiency, 40 cubic feet per second will be available. If + system efficiency falls below 45\%, no capacity for + transporting water will be available. }}} + \put(36,75.5){\vector(-2,0){12}} + \put(37,70){\includegraphics[width=3in,height=2in]{white_square.eps}} + \put(37,90){\fbox{\parbox[t]{3in}{\bf 1. Instructions to subjects: + \\After each round the condition of the irrigation system + declines such that its water delivery efficiency drops by + 25\%. Investment is necessary to keep the irrigation + infrastructure from deteriorating. If you decide to invest in + irrigation infrastructure, you must decide on the amount, as + you will need a certain level of irrigation infrastructure + before you can grow crops.}}} + \put(5,32){\vector(-1,2){2.6}} + \put(0,30){\fbox{\parbox[t]{3.7in}{\bf 3. Instructions to subjects: + \\Before the growing crops component of the exercise starts, + each participant independently makes a decision as to how much + to invest in irrigation infrastructure maintenance. After + everybody has made their decision, the condition of the + infrastructure and the associated total maximum capacity to + distribute water that will be available during the crop + growing component of the exercise is announced.\\[5mm] For + this practice round we just ask you to type in 7, hit + return, or click the investment button.}}} + %\input{graphpaper.tex} +\end{picture} + + + + +\noindent{\bf[TELL ALLEN: MOVE ON TO INVESTMENT RESULTS PAGE]} \\ +\renewcommand{\xdim}{65} +\renewcommand{\ydim}{45} +\setlength{\unitlength}{0.1in} +\begin{picture}(\xdim,\ydim) + \put(0,0){\includegraphics[width=6.5in]{infrastructure.eps}} + %\input{graphpaper.tex} +\end{picture} +\hfill\\ +\hfill\\ + +You now see a table summarizing the results of group investment. The +infrastructure had an efficiency of 50\% and you as a group invested +35. Now the infrastructure is 85\%. Reading to the left where the +yellow line hits the red, stair-stepped curve, shows the water +delivery capacity, in this case 40 cfps. The blue line shows the +amount of water available - in this case, 30 cfps.\\ + +In the diagram on the right you see how much your immediate neighbors contributed to +the public infrastructure. Example: If you are in position C, you will see the +contributions of participants in positions B and D. If you are in position A, you +will only see the contributions of the participant in position B. + +\newpage + +\noindent{\bf[TELL ALLEN: MOVE ON TO GAME INTERFACE PAGE]} \\ +\renewcommand{\xdim}{65} +\renewcommand{\ydim}{45} +\setlength{\unitlength}{0.1in} +\begin{picture}(\xdim,\ydim) + \put(0,0){\includegraphics[width=6.5in]{crops.eps}} + %\input{graphpaper.tex} +\end{picture} +\hfill\\ +\hfill\\ + +There are FIVE participants, each of which is randomly assigned to one +of the five positions, A, B, C, D or E. Water comes from the box to the +left and the five players are located from upstream to downstream. To +illustrate the game, assume you are in position A. The black lines +represent gates that you control (i.e open and close). Right now, +your gate is closed, and player B's gate is open.\\ + +If you were in position C, you would only see the information for your neighbors, positions B and D. + +Each round will take 50 seconds and the amount of time left in the +round is indicated at the top of the screen.\\ + +During this round you can irrigate your field. The earnings depend on +the amount of water you put on your field as will be explained in the +next screen. How fast you can grow a crop depends only on the amount +of water that is available to you. The maximum flow capacity of the +main canal shared by A, B, C, D, and E is 40 cubic feet per second +(cfps).\\ + +The actual amount of water that is available for the group depends on +the amount of water entering the system. Your group might have created +an irrigation infrastructure with a capacity of 40 cfps, but due to +lack of rainfall only 30 cfps is available. On the other hand, if +infrastructure capacity is 30 cfps and 40 cfps of water is available +to the system, only 30 cfps can be delivered. The maximum capacity +that can flow through your gate when it is opened is 25 cubic feet per +second. If other people are using the canal, the water flow available +to you might be less, and it may take longer to get water to your +field.\\ + +The water flow capacity available for your field is shown as a number. +If somebody upstream uses water, less water is available for you. The +thickness of the blue bar is the relative amount of water available. +To start growing crops, click on the large button ``open your +gate''. This will open your irrigation gate and water will begin to +flow to your field. The text on the button will turn to ``close your +gate''. If you would like to close the gate, click on the yellow +button again. The gate closes and the text on the button returns back +to ``open your gate''. The amount of water units (cubic feet) your +field has received is shown on the screen, as well as the resulting +amount of tokens earned from growing a crop. The number of tokens +earned in each round depends on how much water you have diverted to +your field. If you receive less than 150 cubic feet (cf) the crop has +not received enough water to grow a crop and you will thus not receive +any tokens. The maximum earnings are received when between 500 cf and +549 cf are diverted to your field. If more than 549 cf water is +diverted to your field, this will negatively affect the growth of the +crop (i.e. overwatering) and less tokens will be earned. In the graph +in the right bottom of the screen you can see the amount of tokens +earned as a result of the amount of water +applied to your field.\\ + +Your earnings at the end of the round depend on your investment and +the number of tokens received for the crop. We will now start a crop +season for 50 seconds. Just try out what happens when you open and +close the gate on your earnings. See the table on your handout.\\ + +\noindent{\bf[TELL ALLEN: START 50 SECOND CROPPING ROUND]} \\ + + +You see now a table summarizing how much you and other group members have earned +if this round was for real. You see how much you have invested or not, +and how many tokens you earned from growing a crop. \\ + +If you have any questions feel free to raise your hand and to ask your +question. Do you have any questions so far?\\ + +We will now ask you to answer a number of quiz questions which gives +us a better idea how well you understood the instructions. \\ + + +\noindent{\bf Instructions for Round 11 - Treatment 1} \\ + +In the past rounds the infrastructure efficiency declined from +one round to the next at a constant amount of 25\%. In the +following rounds the average decline of the infrastructure +efficiency will remain the same, but the actual amount of +decline can vary from round to round. This means that in some +rounds the decline will be larger than 25\% and some rounds the +decline will be smaller than 25\%. Before each round begins you +will continue to make a decision on how much to invest in the +irrigation infrastructure. After all of your investment +contributions have been submitted the resulting level of +infrastructure efficiency will be displayed and then the round +will begin. If you have any questions, please ask them now. + + +\end{document} Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-09 01:58:03
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/d95ed5c0ebd9/ changeset: d95ed5c0ebd9 branch: stable user: alllee date: 2012-02-09 02:57:58 summary: merging default back into stable, switching to csidex-0.4 affected #: 14 files diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 ivy.xml --- a/ivy.xml +++ b/ivy.xml @@ -5,7 +5,7 @@ <ivy-module version="2.0"><info organisation="edu.asu.commons" module="foraging"/><dependencies> - <dependency org="edu.asu.commons" name="csidex" rev="0.3-SNAPSHOT" /> + <dependency org="edu.asu.commons" name="csidex" rev="0.4-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="javax.jnlp" name="javaws" rev="1.6.0_30"/> diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 pom.xml --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ <dependency><groupId>edu.asu.commons</groupId><artifactId>csidex</artifactId> - <version>0.3-SNAPSHOT</version> + <version>0.4-SNAPSHOT</version></dependency><dependency><groupId>net.java.dev.jogl</groupId> diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java @@ -285,8 +285,4 @@ throw new UnsupportedOperationException("3D support is currently unavailable"); } - public String getLastRoundDebriefing() { - return getRoundConfiguration().getLastRoundDebriefing(getId()); - } - } diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/client/ForagingClient.java --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java @@ -49,6 +49,7 @@ import edu.asu.commons.foraging.ui.GameWindow2D; import edu.asu.commons.foraging.ui.GameWindow3D; import edu.asu.commons.net.SocketIdentifier; +import edu.asu.commons.ui.UserInterfaceUtils; import edu.asu.commons.util.Duration; import edu.asu.commons.util.Utils; @@ -424,10 +425,7 @@ client.connect(); frame.setTitle("Client Window: " + client.getId()); frame.add(client.clientPanel); - frame.pack(); - frame.setExtendedState(Frame.MAXIMIZED_BOTH); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.setVisible(true); + UserInterfaceUtils.maximize(frame); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java @@ -330,12 +330,6 @@ return getProperty("regulation-instructions"); } - public String getLastRoundDebriefing(Identifier id) { - ST template = createStringTemplate(getProperty("last-round-debriefing")); - template.add("id", id); - return template.render(); - } - /** * FIXME: quiz instructions and quiz enabled should be tightly coupled.. * diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java @@ -48,15 +48,15 @@ } public String getLogFileDestination() { - return assistant.getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); + return getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); } public boolean shouldUpdateFacilitator() { - return assistant.getBooleanProperty("update-facilitator", false); + return getBooleanProperty("update-facilitator", false); } public boolean isCensoredChat() { - return assistant.getBooleanProperty("censored-chat-enabled", false); + return getBooleanProperty("censored-chat-enabled", false); } public boolean shouldInitialize3D() { @@ -77,19 +77,19 @@ } public double getShowUpPayment() { - return assistant.getDoubleProperty("show-up-payment", DEFAULT_SHOW_UP_PAYMENT); + return getDoubleProperty("show-up-payment", DEFAULT_SHOW_UP_PAYMENT); } public double getQuizCorrectAnswerReward() { - return assistant.getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); + return getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); } public String getWelcomeInstructions() { - return assistant.getStringProperty("welcome-instructions", "Please wait quietly and do not open or close any programs on this computer."); + return getStringProperty("welcome-instructions", "Please wait quietly and do not open or close any programs on this computer."); } public String getGeneralInstructions() { - ST st = createStringTemplate(assistant.getStringProperty("general-instructions")); + ST st = createStringTemplate(getStringProperty("general-instructions")); NumberFormat formatter = NumberFormat.getCurrencyInstance(); st.add("showUpPayment", formatter.format(getShowUpPayment())); st.add("dollarsPerToken", formatter.format(getDollarsPerToken())); @@ -97,11 +97,11 @@ } public String getSameAsPreviousRoundInstructions() { - return assistant.getStringProperty("same-as-previous-round-instructions", SAME_ROUND_AS_PREVIOUS_INSTRUCTIONS); + return getStringProperty("same-as-previous-round-instructions", SAME_ROUND_AS_PREVIOUS_INSTRUCTIONS); } public String getFieldOfVisionInstructions() { - return assistant.getProperty("field-of-vision-instructions", + return getProperty("field-of-vision-instructions", "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } @@ -114,20 +114,20 @@ } public String getFinalRoundFacilitatorInstructions() { - return assistant.getProperty("facilitator-payment-instructions", + return getProperty("facilitator-payment-instructions", "<h3>The experiment has ended and participant payments are listed above. We recommend that you copy and paste it into a text editor for your records.</h3>"); } public String getSurveyInstructions() { - return assistant.getProperty("survey-instructions"); + return getProperty("survey-instructions"); } public String getFacilitatorDebriefing() { - return assistant.getProperty("facilitator-debriefing"); + return getProperty("facilitator-debriefing"); } public String getClientDebriefing() { - return assistant.getProperty("client-debriefing"); + return getProperty("client-debriefing"); } public double getTotalIncome(ClientData data) { @@ -144,19 +144,19 @@ } public String getInitialVotingInstructions() { - return assistant.getProperty("initial-voting-instructions"); + return getProperty("initial-voting-instructions"); } public String getVotingResults() { - return assistant.getProperty("voting-results"); + return getProperty("voting-results"); } public int getServerSleepInterval() { - return assistant.getIntProperty("server-sleep-interval", 50); + return getIntProperty("server-sleep-interval", 50); } public String getWaitingRoomInstructions() { - return assistant.getProperty("waiting-room-instructions", "<h1>Please wait</h1><hr><p>Please wait while the rest of the participants complete the task.</p>"); + return getProperty("waiting-room-instructions", "<h1>Please wait</h1><hr><p>Please wait while the rest of the participants complete the task.</p>"); } } diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java @@ -6,7 +6,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeSet; import edu.asu.commons.event.PersistableEvent; @@ -29,7 +28,7 @@ import edu.asu.commons.util.Utils; /** - * $Id: AggregateTimeIntervalProcessor.java 526 2010-08-06 01:25:27Z alllee $ + * $Id$ * * Generates aggregate statistics * @@ -50,7 +49,7 @@ } RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); - List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); List<String> movementHeader = new ArrayList<String>(); List<String> collectedTokensHeader = new ArrayList<String>(); @@ -60,17 +59,17 @@ } // headers for average probability of a token for each group - // List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); + List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); // headers for tokens left in each group - // List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); + List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); List<String> distanceHeader = new ArrayList<String>(); - for (int groupIndex = 0; groupIndex < groups.size(); groupIndex++) { - String groupNumber = "Group-" + groupIndex; - // tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); - // tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); + for (GroupDataModel group: groups) { + String groupNumber = group.toString(); + tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); + tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); - List<Identifier> ids = new ArrayList<Identifier>(groups.get(groupIndex).getOrderedClientIdentifiers()); + List<Identifier> ids = new ArrayList<Identifier>(group.getOrderedClientIdentifiers()); for (int i = 0; i < ids.size(); i++) { Identifier id = ids.get(i); for (int j = i+1; j < ids.size(); j++) { @@ -87,9 +86,9 @@ // tokens Utils.join(',', collectedTokensHeader), // group token probabilities - // Utils.join(',', tokenProbabilityGroupNumberHeader), + Utils.join(',', tokenProbabilityGroupNumberHeader), // group total tokens left - // Utils.join(',', tokensLeftGroupNumberHeader), + Utils.join(',', tokensLeftGroupNumberHeader), // distance between participants Utils.join(',', distanceHeader) ); @@ -190,15 +189,15 @@ return distances; } - private List<Double> getExpectedTokenProbabilities(ServerDataModel state) { + private List<Double> getExpectedTokenProbabilities(ServerDataModel serverDataModel) { List<Double> expectedTokens = new ArrayList<Double>(); - Set<GroupDataModel> groups = state.getGroups(); - ResourceDispenser dispenser = new ResourceDispenser(state); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); + ResourceDispenser dispenser = new ResourceDispenser(serverDataModel); StochasticGenerator generator = dispenser.getDensityDependentGenerator(); for (GroupDataModel group: groups) { double tokenProbabilitySum = 0; - for (int x = 0; x < state.getBoardWidth(); x++) { - for (int y = 0; y < state.getBoardHeight(); y++) { + for (int x = 0; x < serverDataModel.getBoardWidth(); x++) { + for (int y = 0; y < serverDataModel.getBoardHeight(); y++) { if (! group.getResourcePositions().contains(new Point(x, y))) { tokenProbabilitySum += generator.getProbabilityForCell(group, x, y); } diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java @@ -3,8 +3,8 @@ import java.awt.Dimension; import java.awt.Point; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -62,9 +62,8 @@ ServerDataModel serverDataModel, Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { -// String groupLabel = "Group # " + groups.indexOf(group); String groupLabel = group.toString(); writer.println("Time, Identifier, Group, # tokens, row stdev, column stdev"); double groupWeightedSpatialMetric = 0.0d; diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java @@ -3,8 +3,8 @@ import java.awt.Dimension; import java.awt.Point; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -55,9 +55,8 @@ PrintWriter writer, ServerDataModel serverDataModel, Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { -// String groupLabel = "Group #" + groups.indexOf(group); String groupLabel = group.toString(); writer.println("Identifier, Group, # tokens, row stdev, column stdev"); double groupWeightedSpatialMetric = 0.0d; diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java @@ -29,7 +29,7 @@ @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); - List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { int totalConsumedGroupTokens = 0; ArrayList<String> clientTokens = new ArrayList<String>(); @@ -49,9 +49,8 @@ group, Utils.join(',', clientTokens), group.getResourceDistributionSize(), - totalConsumedGroupTokens, - Utils.join(',', group.getResourceDistribution().keySet()) - )); + totalConsumedGroupTokens) + ); } Map<GroupDataModel, SortedSet<ChatRequest>> chatRequestMap = new HashMap<GroupDataModel, SortedSet<ChatRequest>>(); SortedSet<ChatRequest> allChatRequests = savedRoundData.getChatRequests(); diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java @@ -7,7 +7,6 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; @@ -16,6 +15,7 @@ import java.util.Queue; import java.util.Random; import java.util.Set; +import java.util.TreeSet; import java.util.logging.Logger; import edu.asu.commons.event.Event; @@ -251,15 +251,11 @@ } public Set<GroupDataModel> getGroups() { - Set<GroupDataModel> groups = new LinkedHashSet<GroupDataModel>(); - groups.addAll(clientsToGroups.values()); - return groups; + return new LinkedHashSet<GroupDataModel>(clientsToGroups.values()); } public List<GroupDataModel> getOrderedGroups() { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(clientsToGroups.values()); - Collections.sort(groups); - return groups; + return new ArrayList<GroupDataModel>(new TreeSet<GroupDataModel>(clientsToGroups.values())); } protected ClientData getClientData(Identifier id) { diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/server/ForagingServer.java --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java @@ -13,10 +13,6 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; -import java.util.logging.FileHandler; -import java.util.logging.Handler; -import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; import edu.asu.commons.event.BeginRoundRequest; import edu.asu.commons.event.ChatEvent; @@ -99,8 +95,6 @@ */ public class ForagingServer extends AbstractExperiment<ServerConfiguration, RoundConfiguration> { - private final Logger logger = Logger.getLogger(getClass().getName()); - private final Map<Identifier, ClientData> clients = new HashMap<Identifier, ClientData>(); private final HashSet<Identifier> syncSet = new HashSet<Identifier>(); @@ -138,14 +132,6 @@ public ForagingServer(ServerConfiguration configuration) { super(configuration); persister = new ForagingPersister(getEventChannel(), configuration); - try { - Handler logHandler = new FileHandler(configuration.getLogFileDestination(), true); - logHandler.setFormatter(new SimpleFormatter()); - logger.addHandler(logHandler); - } catch (IOException e) { - e.printStackTrace(); - logger.severe("Unable to log to file : " + configuration.getLogFileDestination()); - } } @Override @@ -258,6 +244,7 @@ // reassociation of clients to ids and data. should be // logged however so we can remember the context of the data transmit(new ClientMessageEvent(event.getId(), "The experiment has already started, we cannot add you at this time.")); + sendFacilitatorMessage(String.format("Experiment was already started, not adding %s", event.getId())); return; } Identifier identifier = event.getId(); @@ -273,7 +260,7 @@ public void handle(DisconnectionRequest event) { synchronized (clients) { Identifier id = event.getId(); - logger.warning("Disconnecting client, removing " + id + " from clients " + clients.keySet()); + getLogger().warning("Disconnecting client, removing " + id + " from clients " + clients.keySet()); clients.remove(id); serverDataModel.removeClient(id); } @@ -330,7 +317,7 @@ }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionRequest>(PostRoundSanctionRequest.class) { public void handle(PostRoundSanctionRequest event) { - logger.info("Received post round sanction request"); + getLogger().info("Received post round sanction request"); clients.get(event.getId()).getGroupDataModel().handleSanctionRequest(event); // postRoundSanctionLatch.countDown(); numberOfCompletedSanctions++; @@ -495,7 +482,7 @@ GroupDataModel group = sourceClient.getGroupDataModel(); if (!group.equals(targetClient.getGroupDataModel())) { - logger.severe("source client and target client groups are different: " + sourceClient + targetClient); + getLogger().severe("source client and target client groups are different: " + sourceClient + targetClient); return; } EnforcementMechanism enforcementMechanism = group.getActiveEnforcementMechanism(); @@ -530,7 +517,7 @@ break; case NONE: default: - logger.severe("tried to sanction with EnforcementMechanism.NONE"); + getLogger().severe("tried to sanction with EnforcementMechanism.NONE"); } } @@ -543,7 +530,7 @@ || sourceClient.getGroupDataModel().isResourceDistributionEmpty(); if (invalidSanctionRequest) { // ignore the sanction request, send a message to the sanctioner. - logger.warning("Ignoring token reduction request, sending new client error message event to : " + sourceClient.getId()); + getLogger().warning("Ignoring token reduction request, sending new client error message event to : " + sourceClient.getId()); if (getCurrentRoundConfiguration().isSanctioningEnabled()) { transmit(new ClientMessageEvent(sourceClient.getId(), String.format("Ignoring token reduction request: # %d does not have any tokens to reduce.", targetClient.getAssignedNumber()))); @@ -570,7 +557,7 @@ // add sanction request to the target client so they can figure out who just sanctioned them sourceClient.getLatestSanctions().add(request); targetClient.getLatestSanctions().add(request); - logger.info("target client " + targetClient.getId() + " has sanctions: " + targetClient.getLatestSanctions()); + getLogger().info("target client " + targetClient.getId() + " has sanctions: " + targetClient.getLatestSanctions()); transmit(new ClientMessageEvent(sourceClient.getId(), String.format("Subtracting %d tokens from # %d at the cost of %d to yourself.", subtractedTokens, @@ -616,7 +603,7 @@ public void handle(BeginRoundRequest event) { if (event.getId().equals(facilitatorId)) { if (isReadyToStartRound()) { - logger.info("Begin round request from facilitator - starting round."); + getLogger().info("Begin round request from facilitator - starting round."); experimentStarted = true; Utils.notify(roundSignal); } @@ -707,7 +694,7 @@ for (GroupDataModel group : serverDataModel.getGroups()) { LinkedList<ClientData> clientList = new LinkedList<ClientData>(group.getClientDataMap().values()); Collections.shuffle(clientList); - logger.info("TRUST GAME shuffled client list: " + clientList); + getLogger().info("TRUST GAME shuffled client list: " + clientList); ClientData first = clientList.getFirst(); // using an iterator to consume both players and ensure that a player doesn't @@ -726,7 +713,7 @@ // why doesn't listIterator offer a currentIndex() method as well? // playerTwo = clientList.get(random.nextInt(iter.previousIndex() + 1)); // } - logger.info("TRUST GAME: about to pair " + playerOne + " with " + playerTwo); + getLogger().info("TRUST GAME: about to pair " + playerOne + " with " + playerTwo); TrustGameResult trustGameLog = serverDataModel.calculateTrustGame(playerOne, playerTwo); allTrustGameResults.add(trustGameLog); sendFacilitatorMessage(String.format("Pairing %s with %s for trust game resulted in:\n%s", playerOne, playerTwo, @@ -785,14 +772,14 @@ } private void sendFacilitatorMessage(String message) { - logger.info(message); + getLogger().info(message); if (facilitatorId != null) { transmit(new FacilitatorMessageEvent(facilitatorId, message)); } } private void warnFacilitator(String message) { - logger.warning(message); + getLogger().warning(message); if (facilitatorId != null) { transmit(new FacilitatorMessageEvent(facilitatorId, "!. " + message)); } @@ -899,7 +886,7 @@ } RoundConfiguration nextRoundConfiguration = getConfiguration().nextRound(); serverDataModel.setRoundConfiguration(nextRoundConfiguration); - logger.info("Advancing to round # " + getConfiguration().getCurrentRoundNumber()); + getLogger().info("Advancing to round # " + getConfiguration().getCurrentRoundNumber()); // send the next round configuration to each client for (Identifier id : clients.keySet()) { transmit(new SetConfigurationEvent<RoundConfiguration>(id, nextRoundConfiguration)); @@ -928,7 +915,7 @@ // } for (ClientData data: clients.values()) { if (shouldSynchronize(data)) { - logger.info("Sending full sync to: " + data); + getLogger().info("Sending full sync to: " + data); transmit(new SynchronizeClientEvent(data, currentRoundDuration.getTimeLeft())); syncSet.add(data.getId()); } @@ -1035,11 +1022,11 @@ private void initializeGroups() { // reset group linkages if necessary if (shouldShuffleParticipants()) { - logger.info("Shuffling participants"); + getLogger().info("Shuffling participants"); shuffleParticipants(); } else { - logger.info("Didn't need to shuffle participants : " + getCurrentRoundConfiguration()); + getLogger().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(); @@ -1064,7 +1051,7 @@ currentRoundDuration = roundConfiguration.getRoundDuration(); if (roundConfiguration.isVotingAndRegulationEnabled()) { monitorRotationInterval = Math.max(Duration.toSeconds(currentRoundDuration.getTimeLeft()) / roundConfiguration.getClientsPerGroup(), 1); - logger.info("monitor rotation interval: " + monitorRotationInterval); + getLogger().info("monitor rotation interval: " + monitorRotationInterval); } currentRoundDuration.start(); transmit(new FacilitatorUpdateEvent(facilitatorId, serverDataModel, currentRoundDuration.getTimeLeft())); diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java @@ -637,31 +637,31 @@ // FIXME: replace with StringTemplate private void postSanctionDebriefingText(final PostRoundSanctionUpdateEvent event) { - instructionsBuilder.delete(0, instructionsBuilder.length()); - ClientData clientData = event.getClientData(); - // FIXME: split into tokens used to sanction others and tokens taken - // away by other people. - instructionsBuilder.append( - String.format("<h3>Your statistics from the last round have been updated as follows:</h3>" + - "<ul>" + - "<li>Tokens collected last round: %d</li>" + - "<li>Tokens subtracted by other players: %d</li>" + - "<li>Tokens used to subtract tokens from other players: %d</li>" + - "<li>Net earned tokens in the last round: %d</li>" + - "<li>Net income from the last round: $%3.2f</li>" + - "</ul>", - clientData.getTokensCollectedLastRound(), - clientData.getSanctionPenalties(), - clientData.getSanctionCosts(), - clientData.getCurrentTokens(), - getIncome(clientData.getCurrentTokens())) - ); - instructionsBuilder.append(String.format("Your <b>total income</b> so far is: $%3.2f<hr>", - getIncome(clientData.getTotalTokens()))); - if (event.isLastRound()) { - instructionsBuilder.append(client.getDataModel().getLastRoundDebriefing()); - } - setInstructions(instructionsBuilder.toString()); +// instructionsBuilder.delete(0, instructionsBuilder.length()); +// ClientData clientData = event.getClientData(); +// // FIXME: split into tokens used to sanction others and tokens taken +// // away by other people. +// instructionsBuilder.append( +// String.format("<h3>Your statistics from the last round have been updated as follows:</h3>" + +// "<ul>" + +// "<li>Tokens collected last round: %d</li>" + +// "<li>Tokens subtracted by other players: %d</li>" + +// "<li>Tokens used to subtract tokens from other players: %d</li>" + +// "<li>Net earned tokens in the last round: %d</li>" + +// "<li>Net income from the last round: $%3.2f</li>" + +// "</ul>", +// clientData.getTokensCollectedLastRound(), +// clientData.getSanctionPenalties(), +// clientData.getSanctionCosts(), +// clientData.getCurrentTokens(), +// getIncome(clientData.getCurrentTokens())) +// ); +// instructionsBuilder.append(String.format("Your <b>total income</b> so far is: $%3.2f<hr>", +// getIncome(clientData.getTotalTokens()))); +// if (event.isLastRound()) { +// instructionsBuilder.append(client.getDataModel().getLastRoundDebriefing()); +// } +// setInstructions(instructionsBuilder.toString()); } diff -r 570cb75dcb0c7feeabcb03b238ddc0155250f92e -r d95ed5c0ebd91cbeae7c1f529a2d1fe3255e7107 src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java --- a/src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java +++ b/src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java @@ -46,27 +46,28 @@ } public void debrief(ClientDataModel dataModel, boolean lastRound) { - RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); - instructionsBuilder.delete(0, instructionsBuilder.length()); - instructionsBuilder.append( - String.format("<h3>Your stats in this round:</h3>" + - "<ul>" + - "<li>Tokens collected: %d</li>" + - "<li>Income: $%3.2f</li>" + - "</ul>", - dataModel.getCurrentTokens(), - dataModel.getCurrentIncome()) - ); - if (roundConfiguration.isPracticeRound()) { - instructionsBuilder.append("<h3>Note - since this was a practice round you did not earn any income this round.</h3>"); - } - double showUpPayment = roundConfiguration.getParentConfiguration().getShowUpPayment(); - instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", - showUpPayment, dataModel.getTotalIncome() + showUpPayment)); - if (lastRound) { - instructionsBuilder.append(dataModel.getLastRoundDebriefing()); - } - setInstructions(instructionsBuilder.toString()); + throw new UnsupportedOperationException("Deprecated"); +// RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); +// instructionsBuilder.delete(0, instructionsBuilder.length()); +// instructionsBuilder.append( +// String.format("<h3>Your stats in this round:</h3>" + +// "<ul>" + +// "<li>Tokens collected: %d</li>" + +// "<li>Income: $%3.2f</li>" + +// "</ul>", +// dataModel.getCurrentTokens(), +// dataModel.getCurrentIncome()) +// ); +// if (roundConfiguration.isPracticeRound()) { +// instructionsBuilder.append("<h3>Note - since this was a practice round you did not earn any income this round.</h3>"); +// } +// double showUpPayment = roundConfiguration.getParentConfiguration().getShowUpPayment(); +// instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", +// showUpPayment, dataModel.getTotalIncome() + showUpPayment)); +// if (lastRound) { +// instructionsBuilder.append(dataModel.getLastRoundDebriefing()); +// } +// setInstructions(instructionsBuilder.toString()); } /** 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...> - 2012-02-09 01:11:42
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/95fcd4147fe8/ changeset: 95fcd4147fe8 user: alllee date: 2012-02-09 02:11:37 summary: updating ivy dependency on default branch to csidex 0.4 affected #: 1 file diff -r 8c507be94b2416a58a68a1a743e3218854baea27 -r 95fcd4147fe8170445a5b5bf54c23c6e7b47bd4d ivy.xml --- a/ivy.xml +++ b/ivy.xml @@ -5,7 +5,7 @@ <ivy-module version="2.0"><info organisation="edu.asu.commons" module="foraging"/><dependencies> - <dependency org="edu.asu.commons" name="csidex" rev="0.3-SNAPSHOT" /> + <dependency org="edu.asu.commons" name="csidex" rev="0.4-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="javax.jnlp" name="javaws" rev="1.6.0_30"/> 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...> - 2012-02-09 01:08:12
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/8c507be94b24/ changeset: 8c507be94b24 user: alllee date: 2012-02-09 02:08:06 summary: minor hygiene, log handling is performed at the AbstractExperiment level now, removing duplicate logger instance from ForagingServer entirely affected #: 2 files diff -r af8aa758cc48ca793b69cf5eba8e6f20256eb332 -r 8c507be94b2416a58a68a1a743e3218854baea27 src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java @@ -251,9 +251,7 @@ } public Set<GroupDataModel> getGroups() { - Set<GroupDataModel> groups = new LinkedHashSet<GroupDataModel>(); - groups.addAll(clientsToGroups.values()); - return groups; + return new LinkedHashSet<GroupDataModel>(clientsToGroups.values()); } public List<GroupDataModel> getOrderedGroups() { diff -r af8aa758cc48ca793b69cf5eba8e6f20256eb332 -r 8c507be94b2416a58a68a1a743e3218854baea27 src/main/java/edu/asu/commons/foraging/server/ForagingServer.java --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java @@ -13,10 +13,6 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; -import java.util.logging.FileHandler; -import java.util.logging.Handler; -import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; import edu.asu.commons.event.BeginRoundRequest; import edu.asu.commons.event.ChatEvent; @@ -99,8 +95,6 @@ */ public class ForagingServer extends AbstractExperiment<ServerConfiguration, RoundConfiguration> { - private final Logger logger = Logger.getLogger(getClass().getName()); - private final Map<Identifier, ClientData> clients = new HashMap<Identifier, ClientData>(); private final HashSet<Identifier> syncSet = new HashSet<Identifier>(); @@ -138,14 +132,6 @@ public ForagingServer(ServerConfiguration configuration) { super(configuration); persister = new ForagingPersister(getEventChannel(), configuration); - try { - Handler logHandler = new FileHandler(configuration.getLogFileDestination(), true); - logHandler.setFormatter(new SimpleFormatter()); - logger.addHandler(logHandler); - } catch (IOException e) { - e.printStackTrace(); - logger.severe("Unable to log to file : " + configuration.getLogFileDestination()); - } } @Override @@ -274,7 +260,7 @@ public void handle(DisconnectionRequest event) { synchronized (clients) { Identifier id = event.getId(); - logger.warning("Disconnecting client, removing " + id + " from clients " + clients.keySet()); + getLogger().warning("Disconnecting client, removing " + id + " from clients " + clients.keySet()); clients.remove(id); serverDataModel.removeClient(id); } @@ -331,7 +317,7 @@ }); addEventProcessor(new EventTypeProcessor<PostRoundSanctionRequest>(PostRoundSanctionRequest.class) { public void handle(PostRoundSanctionRequest event) { - logger.info("Received post round sanction request"); + getLogger().info("Received post round sanction request"); clients.get(event.getId()).getGroupDataModel().handleSanctionRequest(event); // postRoundSanctionLatch.countDown(); numberOfCompletedSanctions++; @@ -496,7 +482,7 @@ GroupDataModel group = sourceClient.getGroupDataModel(); if (!group.equals(targetClient.getGroupDataModel())) { - logger.severe("source client and target client groups are different: " + sourceClient + targetClient); + getLogger().severe("source client and target client groups are different: " + sourceClient + targetClient); return; } EnforcementMechanism enforcementMechanism = group.getActiveEnforcementMechanism(); @@ -531,7 +517,7 @@ break; case NONE: default: - logger.severe("tried to sanction with EnforcementMechanism.NONE"); + getLogger().severe("tried to sanction with EnforcementMechanism.NONE"); } } @@ -544,7 +530,7 @@ || sourceClient.getGroupDataModel().isResourceDistributionEmpty(); if (invalidSanctionRequest) { // ignore the sanction request, send a message to the sanctioner. - logger.warning("Ignoring token reduction request, sending new client error message event to : " + sourceClient.getId()); + getLogger().warning("Ignoring token reduction request, sending new client error message event to : " + sourceClient.getId()); if (getCurrentRoundConfiguration().isSanctioningEnabled()) { transmit(new ClientMessageEvent(sourceClient.getId(), String.format("Ignoring token reduction request: # %d does not have any tokens to reduce.", targetClient.getAssignedNumber()))); @@ -571,7 +557,7 @@ // add sanction request to the target client so they can figure out who just sanctioned them sourceClient.getLatestSanctions().add(request); targetClient.getLatestSanctions().add(request); - logger.info("target client " + targetClient.getId() + " has sanctions: " + targetClient.getLatestSanctions()); + getLogger().info("target client " + targetClient.getId() + " has sanctions: " + targetClient.getLatestSanctions()); transmit(new ClientMessageEvent(sourceClient.getId(), String.format("Subtracting %d tokens from # %d at the cost of %d to yourself.", subtractedTokens, @@ -617,7 +603,7 @@ public void handle(BeginRoundRequest event) { if (event.getId().equals(facilitatorId)) { if (isReadyToStartRound()) { - logger.info("Begin round request from facilitator - starting round."); + getLogger().info("Begin round request from facilitator - starting round."); experimentStarted = true; Utils.notify(roundSignal); } @@ -708,7 +694,7 @@ for (GroupDataModel group : serverDataModel.getGroups()) { LinkedList<ClientData> clientList = new LinkedList<ClientData>(group.getClientDataMap().values()); Collections.shuffle(clientList); - logger.info("TRUST GAME shuffled client list: " + clientList); + getLogger().info("TRUST GAME shuffled client list: " + clientList); ClientData first = clientList.getFirst(); // using an iterator to consume both players and ensure that a player doesn't @@ -727,7 +713,7 @@ // why doesn't listIterator offer a currentIndex() method as well? // playerTwo = clientList.get(random.nextInt(iter.previousIndex() + 1)); // } - logger.info("TRUST GAME: about to pair " + playerOne + " with " + playerTwo); + getLogger().info("TRUST GAME: about to pair " + playerOne + " with " + playerTwo); TrustGameResult trustGameLog = serverDataModel.calculateTrustGame(playerOne, playerTwo); allTrustGameResults.add(trustGameLog); sendFacilitatorMessage(String.format("Pairing %s with %s for trust game resulted in:\n%s", playerOne, playerTwo, @@ -786,14 +772,14 @@ } private void sendFacilitatorMessage(String message) { - logger.info(message); + getLogger().info(message); if (facilitatorId != null) { transmit(new FacilitatorMessageEvent(facilitatorId, message)); } } private void warnFacilitator(String message) { - logger.warning(message); + getLogger().warning(message); if (facilitatorId != null) { transmit(new FacilitatorMessageEvent(facilitatorId, "!. " + message)); } @@ -900,7 +886,7 @@ } RoundConfiguration nextRoundConfiguration = getConfiguration().nextRound(); serverDataModel.setRoundConfiguration(nextRoundConfiguration); - logger.info("Advancing to round # " + getConfiguration().getCurrentRoundNumber()); + getLogger().info("Advancing to round # " + getConfiguration().getCurrentRoundNumber()); // send the next round configuration to each client for (Identifier id : clients.keySet()) { transmit(new SetConfigurationEvent<RoundConfiguration>(id, nextRoundConfiguration)); @@ -929,7 +915,7 @@ // } for (ClientData data: clients.values()) { if (shouldSynchronize(data)) { - logger.info("Sending full sync to: " + data); + getLogger().info("Sending full sync to: " + data); transmit(new SynchronizeClientEvent(data, currentRoundDuration.getTimeLeft())); syncSet.add(data.getId()); } @@ -1036,11 +1022,11 @@ private void initializeGroups() { // reset group linkages if necessary if (shouldShuffleParticipants()) { - logger.info("Shuffling participants"); + getLogger().info("Shuffling participants"); shuffleParticipants(); } else { - logger.info("Didn't need to shuffle participants : " + getCurrentRoundConfiguration()); + getLogger().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(); @@ -1065,7 +1051,7 @@ currentRoundDuration = roundConfiguration.getRoundDuration(); if (roundConfiguration.isVotingAndRegulationEnabled()) { monitorRotationInterval = Math.max(Duration.toSeconds(currentRoundDuration.getTimeLeft()) / roundConfiguration.getClientsPerGroup(), 1); - logger.info("monitor rotation interval: " + monitorRotationInterval); + getLogger().info("monitor rotation interval: " + monitorRotationInterval); } currentRoundDuration.start(); transmit(new FacilitatorUpdateEvent(facilitatorId, serverDataModel, currentRoundDuration.getTimeLeft())); 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...> - 2012-02-08 22:41:31
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/5751595194cb/ changeset: 5751595194cb user: alllee date: 2012-02-08 23:41:27 summary: updated base configurations for 2011/2012 irrigation experiments affected #: 22 files diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round0.xml --- a/src/main/resources/configuration/asu/2011/pretest/round0.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round0.xml @@ -6,6 +6,7 @@ <entry key="practice-round">true</entry><entry key='reset-infrastructure-efficiency'>true</entry><entry key='initial-infrastructure-efficiency'>50</entry> +<entry key='field-of-vision'>1</entry><entry key="instructions"> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round1.xml --- a/src/main/resources/configuration/asu/2011/pretest/round1.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round1.xml @@ -3,6 +3,7 @@ <properties><comment>Irrigation experiment round configuration</comment><entry key="practice-round">true</entry> +<entry key='field-of-vision'>1</entry><entry key="instructions"><![CDATA[ diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round10.xml --- a/src/main/resources/configuration/asu/2011/pretest/round10.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round10.xml @@ -2,13 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 9 Instructions</h3> -<p> -This round is the same as the previous round. -</p> -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round11.xml --- a/src/main/resources/configuration/asu/2011/pretest/round11.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round11.xml @@ -2,14 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 10 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round12.xml --- a/src/main/resources/configuration/asu/2011/pretest/round12.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round12.xml @@ -2,14 +2,13 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - +<entry key='field-of-vision'>1</entry><entry key='initial-infrastructure-efficiency'>75</entry><entry key='reset-infrastructure-efficiency'>true</entry><entry key='infrastructure-degradation-factor'>20</entry> - <entry key="instructions"><![CDATA[ -<h3>Round 11 Instructions</h3> +<h3>Round {self.roundNumber} Instructions</h3><p> In the past rounds the infrastructure efficiency declined from one round to the next at a constant amount of 25%. In the following rounds the <b>average @@ -22,7 +21,6 @@ infrastructure efficiency will be displayed and then the round will begin. If you have any questions, please ask them now. </p> - ]]></entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round13.xml --- a/src/main/resources/configuration/asu/2011/pretest/round13.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round13.xml @@ -2,16 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - +<entry key='field-of-vision'>1</entry><entry key='infrastructure-degradation-factor'>30</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 12 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round14.xml --- a/src/main/resources/configuration/asu/2011/pretest/round14.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round14.xml @@ -2,16 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - +<entry key='field-of-vision'>1</entry><entry key='infrastructure-degradation-factor'>25</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 13 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round15.xml --- a/src/main/resources/configuration/asu/2011/pretest/round15.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round15.xml @@ -2,15 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> +<entry key='field-of-vision'>1</entry><entry key='infrastructure-degradation-factor'>20</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 14 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round16.xml --- a/src/main/resources/configuration/asu/2011/pretest/round16.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round16.xml @@ -3,15 +3,5 @@ <properties><comment>Irrigation experiment round configuration</comment><entry key='infrastructure-degradation-factor'>35</entry> - - -<entry key="instructions"> -<![CDATA[ -<h3>Round 15 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round17.xml --- a/src/main/resources/configuration/asu/2011/pretest/round17.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round17.xml @@ -3,13 +3,5 @@ <properties><comment>Irrigation experiment round configuration</comment><entry key='infrastructure-degradation-factor'>20</entry> -<entry key="instructions"> -<![CDATA[ -<h3>Round 16 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round18.xml --- a/src/main/resources/configuration/asu/2011/pretest/round18.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round18.xml @@ -3,14 +3,5 @@ <properties><comment>Irrigation experiment round configuration</comment><entry key='infrastructure-degradation-factor'>15</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 17 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round19.xml --- a/src/main/resources/configuration/asu/2011/pretest/round19.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round19.xml @@ -3,15 +3,5 @@ <properties><comment>Irrigation experiment round configuration</comment><entry key='infrastructure-degradation-factor'>30</entry> - - -<entry key="instructions"> -<![CDATA[ -<h3>Round 18 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round2.xml --- a/src/main/resources/configuration/asu/2011/pretest/round2.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round2.xml @@ -4,17 +4,17 @@ <comment>Irrigation experiment round configuration</comment><entry key='reset-infrastructure-efficiency'>true</entry> +<entry key='field-of-vision'>1</entry><entry key="instructions"><![CDATA[ -<h3>Round 1 Instructions</h3> +<h3>Round {self.roundNumber} Instructions</h3><p> -This is the first actual round of the experiment. Before this round begins -you will have the opportunity to text chat with the other participants in your -group, then decide on your level of investment in the irrigation -infrastructure. After the total irrigation infrastructure investment has been -determined you will begin the experiment and make decisions on when to open -your irrigation gates and grow crops. +This is the first actual round of the experiment. Before this round begins you will +have the opportunity to text chat with the other participants in your group, then +decide on your level of investment in the irrigation infrastructure. After the +total irrigation infrastructure investment has been determined you will begin the +experiment and make decisions on when to open your irrigation gates and grow crops. </p> ]]></entry> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round20.xml --- a/src/main/resources/configuration/asu/2011/pretest/round20.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round20.xml @@ -2,16 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - +<entry key='field-of-vision'>1</entry><entry key='infrastructure-degradation-factor'>30</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 19 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round21.xml --- a/src/main/resources/configuration/asu/2011/pretest/round21.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round21.xml @@ -2,15 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - +<entry key='field-of-vision'>1</entry><entry key='infrastructure-degradation-factor'>25</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 20 Instructions</h3> -<p> -This is the final round. -</p> -]]> -</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round3.xml --- a/src/main/resources/configuration/asu/2011/pretest/round3.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round3.xml @@ -2,14 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 2 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round4.xml --- a/src/main/resources/configuration/asu/2011/pretest/round4.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round4.xml @@ -2,13 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 3 Instructions</h3> -<p> -This round is the same as the previous round. -</p> -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round5.xml --- a/src/main/resources/configuration/asu/2011/pretest/round5.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round5.xml @@ -2,13 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 4 Instructions</h3> -<p> -This round is the same as the previous round. -</p> -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round6.xml --- a/src/main/resources/configuration/asu/2011/pretest/round6.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round6.xml @@ -2,14 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 5 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round7.xml --- a/src/main/resources/configuration/asu/2011/pretest/round7.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round7.xml @@ -2,14 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 6 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round8.xml --- a/src/main/resources/configuration/asu/2011/pretest/round8.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round8.xml @@ -2,13 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 7 Instructions</h3> -<p> -This round is the same as the previous round. -</p> -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> diff -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae -r 5751595194cba562f21cdd240242f966b0ba25d7 src/main/resources/configuration/asu/2011/pretest/round9.xml --- a/src/main/resources/configuration/asu/2011/pretest/round9.xml +++ b/src/main/resources/configuration/asu/2011/pretest/round9.xml @@ -2,14 +2,5 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>Irrigation experiment round configuration</comment> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 8 Instructions</h3> -<p> -This round is the same as the previous round. -</p> - -]]> -</entry> +<entry key='field-of-vision'>1</entry></properties> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-08 05:07:55
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/9d793c8a8b8f/ changeset: 9d793c8a8b8f user: alllee date: 2012-02-08 06:07:49 summary: adding field of vision property in the event that we ever want extended a field of vision past 1 immediate neighbor. affected #: 1 file diff -r 1a9b96f825b53d32e52d87c251e384611ea7f88a -r 9d793c8a8b8fefa0838944ae607a2ad74ee128ae src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -84,7 +84,7 @@ * @return */ public double getDollarsPerToken() { - return getDoubleProperty("dollars-per-token", getParentConfiguration().getDollarsPerToken()); + return getDoubleProperty("dollars-per-token"); } /** @@ -149,11 +149,20 @@ } public boolean isRestrictedVisibility() { - return getBooleanProperty("restricted-visibility-enabled", getParentConfiguration().isRestrictedVisibility()); + return getFieldOfVision() < 0; + } + + /** + * Returns the number of neighbors visible on both sides of the participant. A negative value signifies that + * participants can see everything. + * @return the number of neighbors visible to either side of each participant. + */ + public int getFieldOfVision() { + return getIntProperty("field-of-vision", -1); } public String getClientDebriefingTemplate() { - return getProperty("client-debriefing", getParentConfiguration().getClientDebriefingTemplate()); + return getProperty("client-debriefing"); } private void populateClientEarnings(ClientData data, ServerConfiguration serverConfiguration, NumberFormat currencyFormatter) { Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-07 00:08:58
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/1a9b96f825b5/ changeset: 1a9b96f825b5 user: alllee date: 2012-02-07 01:08:53 summary: replacing contribution information with StringTemplate version and fixing template affected #: 2 files diff -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a -r 1a9b96f825b53d32e52d87c251e384611ea7f88a src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -472,30 +472,11 @@ } - // FIXME: replace with StringTemplate public void displayContributionInformation(final ClientData clientData) { - GroupDataModel groupDataModel = clientData.getGroupDataModel(); - int totalContributedTokens = groupDataModel.getTotalContributedTokens(); - final StringBuilder builder = new StringBuilder(); - builder.append("<ul><li>Infrastructure efficiency before investment: ") - .append(groupDataModel.getInfrastructureEfficiencyBeforeInvestment()) - .append("%</li>"); - builder.append("<li>Water delivery capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second</li>"); - builder.append( - String.format( - "<li>Total group investment: %d tokens, increasing the infrastructure efficiency to %d%%</li>", - totalContributedTokens, groupDataModel.getInfrastructureEfficiency())); - if (groupDataModel.getIrrigationCapacity() > groupDataModel.getIrrigationCapacityBeforeInvestment()) { - builder.append("<li><b>Your group's investment has increased the water delivery capacity to "); - } - else { - builder.append("<li>Your group's investment was not enough to increase the water delivery capacity. Your group's water delivery capacity is still "); - } - builder.append(groupDataModel.getIrrigationCapacity()).append(" cubic feet of water per second.</li><li>The amount of water available to pass through your irrigation canal is ") - .append(groupDataModel.getActualWaterDeliveryCapacity()).append(" cubic feet per second</li>"); + final String contributionSummary = clientDataModel.getRoundConfiguration().generateContributionSummary(clientData); SwingUtilities.invokeLater(new Runnable() { public void run() { - contributionInformationEditorPane.setText(builder.toString()); + contributionInformationEditorPane.setText(contributionSummary); infrastructureEfficiencyChartPanel.initialize(); pieChart.initialize(clientData); addCenterComponent(getContributionInformationPanel()); diff -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a -r 1a9b96f825b53d32e52d87c251e384611ea7f88a src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -430,7 +430,7 @@ <hr><p> Your group invested a total of <b>{groupDataModel.totalContributedTokens} tokens</b> this round, resulting in an infrastructure efficiency of <b>{groupDataModel.infrastructureEfficiency}%</b> and a water delivery capacity of <b>{groupDataModel.irrigationCapacity} cubic feet per second</b>. -The amount of water available to pass through your canal is {groupDataModel.actualWaterDeliveryCapacity cubic feet per second}. +The amount of water available to pass through your canal is <b>{groupDataModel.actualWaterDeliveryCapacity} cubic feet per second</b>. </p><table border=2 cellspacing=2 cellpadding=3><tr> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-06 23:11:19
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/af8aa758cc48/ changeset: af8aa758cc48 user: alllee date: 2012-02-07 00:11:14 summary: removing duplicates from getOrderedGroups through Set conversion affected #: 2 files diff -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 -r af8aa758cc48ca793b69cf5eba8e6f20256eb332 src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java @@ -49,9 +49,8 @@ group, Utils.join(',', clientTokens), group.getResourceDistributionSize(), - totalConsumedGroupTokens, - Utils.join(',', group.getResourceDistribution().keySet()) - )); + totalConsumedGroupTokens) + ); } Map<GroupDataModel, SortedSet<ChatRequest>> chatRequestMap = new HashMap<GroupDataModel, SortedSet<ChatRequest>>(); SortedSet<ChatRequest> allChatRequests = savedRoundData.getChatRequests(); diff -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 -r af8aa758cc48ca793b69cf5eba8e6f20256eb332 src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java @@ -7,7 +7,6 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; @@ -16,6 +15,7 @@ import java.util.Queue; import java.util.Random; import java.util.Set; +import java.util.TreeSet; import java.util.logging.Logger; import edu.asu.commons.event.Event; @@ -257,9 +257,7 @@ } public List<GroupDataModel> getOrderedGroups() { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(clientsToGroups.values()); - Collections.sort(groups); - return groups; + return new ArrayList<GroupDataModel>(new TreeSet<GroupDataModel>(clientsToGroups.values())); } protected ClientData getClientData(Identifier id) { 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...> - 2012-02-06 22:46:00
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/312ce9ac8bef/ changeset: 312ce9ac8bef user: alllee date: 2012-02-06 23:45:55 summary: adding missing headers back to AggregateTimeIntervalProcessor and changing save file processing to use predictable group iteration order affected #: 6 files diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/client/ForagingClient.java --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java @@ -49,6 +49,7 @@ import edu.asu.commons.foraging.ui.GameWindow2D; import edu.asu.commons.foraging.ui.GameWindow3D; import edu.asu.commons.net.SocketIdentifier; +import edu.asu.commons.ui.UserInterfaceUtils; import edu.asu.commons.util.Duration; import edu.asu.commons.util.Utils; @@ -424,10 +425,7 @@ client.connect(); frame.setTitle("Client Window: " + client.getId()); frame.add(client.clientPanel); - frame.pack(); - frame.setExtendedState(Frame.MAXIMIZED_BOTH); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.setVisible(true); + UserInterfaceUtils.maximize(frame); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/AggregateTimeIntervalProcessor.java @@ -6,7 +6,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeSet; import edu.asu.commons.event.PersistableEvent; @@ -29,7 +28,7 @@ import edu.asu.commons.util.Utils; /** - * $Id: AggregateTimeIntervalProcessor.java 526 2010-08-06 01:25:27Z alllee $ + * $Id$ * * Generates aggregate statistics * @@ -50,7 +49,7 @@ } RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); - List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); List<String> movementHeader = new ArrayList<String>(); List<String> collectedTokensHeader = new ArrayList<String>(); @@ -60,17 +59,17 @@ } // headers for average probability of a token for each group - // List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); + List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); // headers for tokens left in each group - // List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); + List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); List<String> distanceHeader = new ArrayList<String>(); - for (int groupIndex = 0; groupIndex < groups.size(); groupIndex++) { - String groupNumber = "Group-" + groupIndex; - // tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); - // tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); + for (GroupDataModel group: groups) { + String groupNumber = group.toString(); + tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); + tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); - List<Identifier> ids = new ArrayList<Identifier>(groups.get(groupIndex).getOrderedClientIdentifiers()); + List<Identifier> ids = new ArrayList<Identifier>(group.getOrderedClientIdentifiers()); for (int i = 0; i < ids.size(); i++) { Identifier id = ids.get(i); for (int j = i+1; j < ids.size(); j++) { @@ -87,9 +86,9 @@ // tokens Utils.join(',', collectedTokensHeader), // group token probabilities - // Utils.join(',', tokenProbabilityGroupNumberHeader), + Utils.join(',', tokenProbabilityGroupNumberHeader), // group total tokens left - // Utils.join(',', tokensLeftGroupNumberHeader), + Utils.join(',', tokensLeftGroupNumberHeader), // distance between participants Utils.join(',', distanceHeader) ); @@ -190,15 +189,15 @@ return distances; } - private List<Double> getExpectedTokenProbabilities(ServerDataModel state) { + private List<Double> getExpectedTokenProbabilities(ServerDataModel serverDataModel) { List<Double> expectedTokens = new ArrayList<Double>(); - Set<GroupDataModel> groups = state.getGroups(); - ResourceDispenser dispenser = new ResourceDispenser(state); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); + ResourceDispenser dispenser = new ResourceDispenser(serverDataModel); StochasticGenerator generator = dispenser.getDensityDependentGenerator(); for (GroupDataModel group: groups) { double tokenProbabilitySum = 0; - for (int x = 0; x < state.getBoardWidth(); x++) { - for (int y = 0; y < state.getBoardHeight(); y++) { + for (int x = 0; x < serverDataModel.getBoardWidth(); x++) { + for (int y = 0; y < serverDataModel.getBoardHeight(); y++) { if (! group.getResourcePositions().contains(new Point(x, y))) { tokenProbabilitySum += generator.getProbabilityForCell(group, x, y); } diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/AggregateTokenSpatialDistributionProcessor.java @@ -3,8 +3,8 @@ import java.awt.Dimension; import java.awt.Point; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -62,9 +62,8 @@ ServerDataModel serverDataModel, Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { -// String groupLabel = "Group # " + groups.indexOf(group); String groupLabel = group.toString(); writer.println("Time, Identifier, Group, # tokens, row stdev, column stdev"); double groupWeightedSpatialMetric = 0.0d; diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/CollectedTokenSpatialDistributionProcessor.java @@ -3,8 +3,8 @@ import java.awt.Dimension; import java.awt.Point; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -55,9 +55,8 @@ PrintWriter writer, ServerDataModel serverDataModel, Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { -// String groupLabel = "Group #" + groups.indexOf(group); String groupLabel = group.toString(); writer.println("Identifier, Group, # tokens, row stdev, column stdev"); double groupWeightedSpatialMetric = 0.0d; diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/SummaryProcessor.java @@ -29,7 +29,7 @@ @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); - List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + List<GroupDataModel> groups = serverDataModel.getOrderedGroups(); for (GroupDataModel group: groups) { int totalConsumedGroupTokens = 0; ArrayList<String> clientTokens = new ArrayList<String>(); diff -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 -r 312ce9ac8bef8d4d3dbc4d4d2d7305cf268e8e22 src/main/java/edu/asu/commons/foraging/server/ForagingServer.java --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java @@ -258,6 +258,7 @@ // reassociation of clients to ids and data. should be // logged however so we can remember the context of the data transmit(new ClientMessageEvent(event.getId(), "The experiment has already started, we cannot add you at this time.")); + sendFacilitatorMessage(String.format("Experiment was already started, not adding %s", event.getId())); return; } Identifier identifier = event.getId(); 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...> - 2012-02-04 00:18:45
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/41a912f9af5c/ changeset: 41a912f9af5c user: alllee date: 2012-02-04 01:18:38 summary: replacing contribution results generation with StringTemplate affected #: 7 files diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a ivy.xml --- a/ivy.xml +++ b/ivy.xml @@ -5,7 +5,7 @@ <ivy-module version="2.0"><info organisation="edu.asu.commons" module="irrigation"/><dependencies> - <dependency org="edu.asu.commons" name="csidex" rev="0.3-SNAPSHOT"/> + <dependency org="edu.asu.commons" name="csidex" rev="0.4-SNAPSHOT"/><dependency org="org.jfree" name="jfreechart" rev="1.0.14"/></dependencies></ivy-module> diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -472,6 +472,7 @@ } + // FIXME: replace with StringTemplate public void displayContributionInformation(final ClientData clientData) { GroupDataModel groupDataModel = clientData.getGroupDataModel(); int totalContributedTokens = groupDataModel.getTotalContributedTokens(); diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/client/GamePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java @@ -32,7 +32,7 @@ * * Primary in-round game interface window for the irrigation game. Displays the * - * FIXME: refactor layout + * FIXME: refactor layout, currently a hodge podge of fixed sizes... * * @author <a href='mailto:All...@as...'>Allen Lee</a>, Sanket Joshi * @version $Rev$ diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java --- a/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java +++ b/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java @@ -1,5 +1,7 @@ package edu.asu.commons.irrigation.client; +import java.awt.Dimension; + import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -28,7 +30,6 @@ import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.SocketIdentifier; -import edu.asu.commons.ui.UserInterfaceUtils; /** * $Id$ @@ -41,6 +42,8 @@ */ public class IrrigationClient { + private static final Dimension DEFAULT_FRAME_DIMENSION = new Dimension(1200, 800); + enum ClientState { UNCONNECTED, CONNECTED, READY, RUNNING, DENIED }; @@ -104,9 +107,13 @@ JFrame frame = new JFrame(); IrrigationClient client = new IrrigationClient(); client.initialize(); - frame.setTitle("Client Window: " + client.getId()); - frame.add(client.getExperimentGameWindow()); - UserInterfaceUtils.maximize(frame); + frame.setTitle("Virtual Commons Experiment Client: " + client.id); + frame.setPreferredSize(DEFAULT_FRAME_DIMENSION); +// frame.setResizable(false); + frame.getContentPane().add(client.getExperimentGameWindow()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -47,7 +47,7 @@ } public int getTokenEndowment() { - return getIntProperty("token-endowment", 10); + return getIntProperty("token-endowment"); } /** @@ -173,5 +173,16 @@ st.add("showExitInstructions", showExitInstructions); return st.render(); } + + public String generateContributionSummary(ClientData clientData) { + ST st = createStringTemplate(getContributionSummaryTemplate()); + st.add("clientData", clientData); + st.add("groupDataModel", clientData.getGroupDataModel()); + return st.render(); + } + + private String getContributionSummaryTemplate() { + return getProperty("contribution-summary"); + } } diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -172,7 +172,7 @@ } public String getInvestmentInstructions() { - return getProperty("investment-instructions"); + return render(getProperty("investment-instructions")); } public int getNumberOfQuizPages() { @@ -199,6 +199,10 @@ public double getDollarsPerToken() { return getDoubleProperty("dollars-per-token", DEFAULT_DOLLARS_PER_TOKEN); } + + public int getTokenEndowment() { + return getIntProperty("token-endowment", 10); + } public static int getTokensEarned(int waterCollected) { if (waterCollected < 150) { diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -310,15 +310,15 @@ <entry key="investment-instructions"><![CDATA[ <p> -You have been endowed with 10 tokens to invest. You must make a decision about -how much you wish to invest [0,10] in the irrigation infrastructure. You can -see the relationship between total investment and irrigation infrastructure in -the table below. After you have entered the number of tokens you'd like to -invest, hit the enter key or click the submit button to confirm your -investment. When everybody has made their decision, the total investment will -be calculated and the overall irrigation infrastructure will be displayed. -Each token you invest corresponds to one percent of infrastructure efficiency, -so if you invest 10 tokens you are contributing 10% to the overall +You have been endowed with {self.tokenEndowment} tokens to invest. You must make a decision about +how much you wish to invest in the irrigation infrastructure (choosing a number +between 0 and {self.tokenEndowment}. You can see the relationship between total +investment and irrigation infrastructure in the table below. After you have entered +the number of tokens you'd like to invest, hit the enter key or click the submit +button to confirm your investment. When everybody has made their decision, the total +investment will be calculated and the overall irrigation infrastructure will be +displayed. Each token you invest corresponds to one percent of infrastructure +efficiency, so if you invest 10 tokens you are contributing 10% to the overall infrastructure efficiency. </p><table border="1" cellspacing="2" cellpadding="2"> @@ -424,5 +424,25 @@ </p> ]]></entry> - +<entry key="contribution-summary"> +<![CDATA[ +<h1>Contributions Summary</h1> +<hr> +<p> +Your group invested a total of <b>{groupDataModel.totalContributedTokens} tokens</b> this round, resulting in an infrastructure efficiency of <b>{groupDataModel.infrastructureEfficiency}%</b> and a water delivery capacity of <b>{groupDataModel.irrigationCapacity} cubic feet per second</b>. +The amount of water available to pass through your canal is {groupDataModel.actualWaterDeliveryCapacity cubic feet per second}. +</p> +<table border=2 cellspacing=2 cellpadding=3> +<tr> +<th></th></th><th>Infrastructure Efficiency</th><th>Water Delivery Capacity</th><th>Water Availability</th> +</tr> +<tr> +<td>Before Investment</td><td>{groupDataModel.infrastructureEfficiencyBeforeInvestment}%</td><td>{groupDataModel.irrigationCapacityBeforeInvestment} cubic feet per second</td><td>{groupDataModel.actualWaterDeliveryCapacity}</td> +</tr> +<tr> +<td>After Investment</td><td>{groupDataModel.infrastructureEfficiency}%</td><td>{groupDataModel.irrigationCapacity} cubic feet per second</td><td>{groupDataModel.actualWaterDeliveryCapacity}</td> +</tr> +</table> +]]> +</entry></properties> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-03 08:31:03
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/7eddd3cd0a9c/ changeset: 7eddd3cd0a9c user: alllee date: 2012-02-03 09:30:45 summary: minor UI enhancements and configuration fixes affected #: 7 files diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 build.xml --- a/build.xml +++ b/build.xml @@ -159,6 +159,7 @@ </target><target name='deploy'> + <fail message="Please verify that server.address is properly set in build.properties" unless="server.address"/><antcall target='deploy-to'><param name='deploy.dir' value='${web.dir}'/></antcall> diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 pom.xml --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ <dependency><groupId>edu.asu.commons</groupId><artifactId>csidex</artifactId> - <version>0.3-SNAPSHOT</version> + <version>0.4-SNAPSHOT</version></dependency><dependency><groupId>org.jfree</groupId> diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -123,7 +123,8 @@ StyleContext.DEFAULT_STYLE); // Style regularStyle = styledDocument.addStyle("regular", // defaultStyle); - StyleConstants.setFontFamily(defaultStyle, "Helvetica"); + StyleConstants.setFontSize(defaultStyle, 16); + StyleConstants.setFontFamily(defaultStyle, UserInterfaceUtils.getDefaultFont().getFamily()); StyleConstants.setBold(styledDocument.addStyle("bold", defaultStyle), true); StyleConstants.setItalic(styledDocument.addStyle("italic", defaultStyle), true); } @@ -145,6 +146,7 @@ messageWindow.setEditable(false); messageWindow.setBackground(Color.WHITE); messageScrollPane = new JScrollPane(messageWindow); +// UserInterfaceUtils.addStyles(messageWindow, 16); addStylesToMessageWindow(); textEntryPanel = new TextEntryPanel(); chatInstructionsPane = UserInterfaceUtils.createInstructionsEditorPane(); @@ -158,7 +160,7 @@ public void displayMessage(String chatHandle, String message) { final StyledDocument document = messageWindow.getStyledDocument(); if (!chatHandle.endsWith(":")) { - chatHandle = chatHandle.concat(":"); + chatHandle = chatHandle.concat(": "); } try { document.insertString(0, chatHandle, document.getStyle("bold")); diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 src/main/java/edu/asu/commons/irrigation/client/GamePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java @@ -30,7 +30,9 @@ /** * $Id$ * - * Primary game interface window for the irrigation game. + * Primary in-round game interface window for the irrigation game. Displays the + * + * FIXME: refactor layout * * @author <a href='mailto:All...@as...'>Allen Lee</a>, Sanket Joshi * @version $Rev$ diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -98,9 +98,17 @@ return isFirstRound() || getBooleanProperty("reset-infrastructure-efficiency", false); } + /** + * Returns the instructions for this round. If undefined at the round level it uses default instructions at the parent ServerConfiguration level. + */ public String getInstructions() { - return getStringProperty("instructions", getParentConfiguration().getSameAsPreviousRoundInstructions()); - } + ST template = createStringTemplate(getProperty("instructions", getParentConfiguration().getSameAsPreviousRoundInstructions())); + // FIXME: probably should just lift these out into methods on RoundConfiguration + // and refer to them as self.durationInMinutes or self.dollarsPerTokenCurrencyString, etc. + template.add("duration", inMinutes(getDuration()) + " minutes"); + template.add("dollarsPerToken", toCurrencyString(getDollarsPerToken())); + return template.render(); + } public boolean shouldDisplayGroupTokens() { return getBooleanProperty("display-group-tokens"); diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -39,15 +39,15 @@ } public String getLogFileDestination() { - return assistant.getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); + return getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); } public String getPersistenceDirectory() { - return assistant.getStringProperty("save-dir", "data"); + return getStringProperty("save-dir", "data"); } public boolean shouldUpdateFacilitator() { - return assistant.getBooleanProperty("update-facilitator"); + return getBooleanProperty("update-facilitator"); } @Override @@ -73,19 +73,19 @@ } public boolean isUndisruptedFlowRequired(){ - return assistant.getBooleanProperty("undisrupted-flow-required", false); + return getBooleanProperty("undisrupted-flow-required", false); } public String getUndisruptedFlowInstructions() { - return assistant.getProperty("undisrupted-flow-instructions", ""); + return getProperty("undisrupted-flow-instructions", ""); } public double getShowUpPayment() { - return assistant.getDoubleProperty("showup-payment", 5.0d); + return getDoubleProperty("showup-payment", 5.0d); } public String getInitialInstructions() { - ST template = createStringTemplate(assistant.getProperty("initial-instructions")); + ST template = createStringTemplate(getProperty("initial-instructions")); template.groupThatCreatedThisInstance.registerRenderer(Number.class, new NumberRenderer()); NumberFormat formatter = NumberFormat.getCurrencyInstance(); template.add("showUpPayment", formatter.format(getShowUpPayment())); @@ -95,11 +95,11 @@ } public String getChatInstructions() { - return createStringTemplate(assistant.getProperty("chat-instructions")).render(); + return createStringTemplate(getProperty("chat-instructions")).render(); } public String getChatDurationInMinutes() { - long minutes = assistant.inMinutes(getChatDuration()); + long minutes = inMinutes(getChatDuration()); return String.format("%d minute%s", minutes, (minutes > 1) ? "s" : ""); } @@ -124,7 +124,7 @@ } public double getQuizCorrectAnswerReward() { - return assistant.getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); + return getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); } public double getMaximumQuizEarnings() { @@ -132,15 +132,15 @@ } public String getWelcomeInstructions() { - return assistant.getProperty("welcome-instructions"); + return getProperty("welcome-instructions"); } public int getNumberOfQuizQuestions() { - return assistant.getIntProperty("numberOfQuizQuestions", 6); + return getIntProperty("numberOfQuizQuestions", 6); } public Map<String, String> getQuizAnswers() { - Properties properties = assistant.getProperties(); + Properties properties = getProperties(); Map<String, String> answers = new HashMap<String, String>(); for (int i = 1; properties.containsKey("q" + i); i++) { String key = "q" + i; @@ -156,48 +156,48 @@ } public String getQuizQuestion(int pageNumber) { - return assistant.getProperty("general-instructionsq" + pageNumber); + return getProperty("general-instructionsq" + pageNumber); } public String getQuizPage(int pageNumber) { - return assistant.getProperty("quiz-page"+pageNumber); + return getProperty("quiz-page"+pageNumber); } public String getWaterCollectedToTokensTable() { - return assistant.getProperty("water-collected-to-tokens-table"); + return getProperty("water-collected-to-tokens-table"); } public String getFinalInstructions() { - return assistant.getProperty("final-instructions", "<b>The experiment is now over. Thanks for participating!</b>"); + return getProperty("final-instructions", "<b>The experiment is now over. Thanks for participating!</b>"); } public String getInvestmentInstructions() { - return assistant.getProperty("investment-instructions"); + return getProperty("investment-instructions"); } public int getNumberOfQuizPages() { - return assistant.getIntProperty("question-pages", 2); + return getIntProperty("quiz-pages", 2); } public int getChatDuration() { - return assistant.getIntProperty("chat-duration", 60); + return getIntProperty("chat-duration", 60); } public String getGameScreenshotInstructions() { - return assistant.getProperty("game-screenshot-instructions"); + return getProperty("game-screenshot-instructions"); } public String getSameAsPreviousRoundInstructions() { - return createStringTemplate(assistant.getProperty("same-as-previous-round-instructions")).render(); + return createStringTemplate(getProperty("same-as-previous-round-instructions")).render(); } public String getClientDebriefingTemplate() { - return assistant.getProperty("client-debriefing"); + return getProperty("client-debriefing"); } public double getDollarsPerToken() { - return assistant.getDoubleProperty("dollars-per-token", DEFAULT_DOLLARS_PER_TOKEN); + return getDoubleProperty("dollars-per-token", DEFAULT_DOLLARS_PER_TOKEN); } public static int getTokensEarned(int waterCollected) { diff -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -27,6 +27,7 @@ <entry key="round20">round20.xml</entry><entry key="round21">round21.xml</entry> +<entry key='quiz-pages'>2</entry><entry key="wait-for-participants">true</entry><entry key="number-of-rounds">22</entry> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-03 08:29:56
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/c4bfc740cfdc/ changeset: c4bfc740cfdc user: alllee date: 2012-02-03 09:29:36 summary: version bump for csidex library, minor hygiene affected #: 6 files diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 pom.xml --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ <dependency><groupId>edu.asu.commons</groupId><artifactId>csidex</artifactId> - <version>0.3-SNAPSHOT</version> + <version>0.4-SNAPSHOT</version></dependency><dependency><groupId>net.java.dev.jogl</groupId> diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java @@ -285,8 +285,4 @@ throw new UnsupportedOperationException("3D support is currently unavailable"); } - public String getLastRoundDebriefing() { - return getRoundConfiguration().getLastRoundDebriefing(getId()); - } - } diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java @@ -330,12 +330,6 @@ return getProperty("regulation-instructions"); } - public String getLastRoundDebriefing(Identifier id) { - ST template = createStringTemplate(getProperty("last-round-debriefing")); - template.add("id", id); - return template.render(); - } - /** * FIXME: quiz instructions and quiz enabled should be tightly coupled.. * diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java @@ -48,15 +48,15 @@ } public String getLogFileDestination() { - return assistant.getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); + return getStringProperty("log", DEFAULT_LOG_FILE_DESTINATION); } public boolean shouldUpdateFacilitator() { - return assistant.getBooleanProperty("update-facilitator", false); + return getBooleanProperty("update-facilitator", false); } public boolean isCensoredChat() { - return assistant.getBooleanProperty("censored-chat-enabled", false); + return getBooleanProperty("censored-chat-enabled", false); } public boolean shouldInitialize3D() { @@ -77,19 +77,19 @@ } public double getShowUpPayment() { - return assistant.getDoubleProperty("show-up-payment", DEFAULT_SHOW_UP_PAYMENT); + return getDoubleProperty("show-up-payment", DEFAULT_SHOW_UP_PAYMENT); } public double getQuizCorrectAnswerReward() { - return assistant.getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); + return getDoubleProperty("quiz-correct-answer-reward", DEFAULT_QUIZ_CORRECT_ANSWER_REWARD); } public String getWelcomeInstructions() { - return assistant.getStringProperty("welcome-instructions", "Please wait quietly and do not open or close any programs on this computer."); + return getStringProperty("welcome-instructions", "Please wait quietly and do not open or close any programs on this computer."); } public String getGeneralInstructions() { - ST st = createStringTemplate(assistant.getStringProperty("general-instructions")); + ST st = createStringTemplate(getStringProperty("general-instructions")); NumberFormat formatter = NumberFormat.getCurrencyInstance(); st.add("showUpPayment", formatter.format(getShowUpPayment())); st.add("dollarsPerToken", formatter.format(getDollarsPerToken())); @@ -97,11 +97,11 @@ } public String getSameAsPreviousRoundInstructions() { - return assistant.getStringProperty("same-as-previous-round-instructions", SAME_ROUND_AS_PREVIOUS_INSTRUCTIONS); + return getStringProperty("same-as-previous-round-instructions", SAME_ROUND_AS_PREVIOUS_INSTRUCTIONS); } public String getFieldOfVisionInstructions() { - return assistant.getProperty("field-of-vision-instructions", + return getProperty("field-of-vision-instructions", "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } @@ -114,20 +114,20 @@ } public String getFinalRoundFacilitatorInstructions() { - return assistant.getProperty("facilitator-payment-instructions", + return getProperty("facilitator-payment-instructions", "<h3>The experiment has ended and participant payments are listed above. We recommend that you copy and paste it into a text editor for your records.</h3>"); } public String getSurveyInstructions() { - return assistant.getProperty("survey-instructions"); + return getProperty("survey-instructions"); } public String getFacilitatorDebriefing() { - return assistant.getProperty("facilitator-debriefing"); + return getProperty("facilitator-debriefing"); } public String getClientDebriefing() { - return assistant.getProperty("client-debriefing"); + return getProperty("client-debriefing"); } public double getTotalIncome(ClientData data) { @@ -144,19 +144,19 @@ } public String getInitialVotingInstructions() { - return assistant.getProperty("initial-voting-instructions"); + return getProperty("initial-voting-instructions"); } public String getVotingResults() { - return assistant.getProperty("voting-results"); + return getProperty("voting-results"); } public int getServerSleepInterval() { - return assistant.getIntProperty("server-sleep-interval", 50); + return getIntProperty("server-sleep-interval", 50); } public String getWaitingRoomInstructions() { - return assistant.getProperty("waiting-room-instructions", "<h1>Please wait</h1><hr><p>Please wait while the rest of the participants complete the task.</p>"); + return getProperty("waiting-room-instructions", "<h1>Please wait</h1><hr><p>Please wait while the rest of the participants complete the task.</p>"); } } diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java @@ -637,31 +637,31 @@ // FIXME: replace with StringTemplate private void postSanctionDebriefingText(final PostRoundSanctionUpdateEvent event) { - instructionsBuilder.delete(0, instructionsBuilder.length()); - ClientData clientData = event.getClientData(); - // FIXME: split into tokens used to sanction others and tokens taken - // away by other people. - instructionsBuilder.append( - String.format("<h3>Your statistics from the last round have been updated as follows:</h3>" + - "<ul>" + - "<li>Tokens collected last round: %d</li>" + - "<li>Tokens subtracted by other players: %d</li>" + - "<li>Tokens used to subtract tokens from other players: %d</li>" + - "<li>Net earned tokens in the last round: %d</li>" + - "<li>Net income from the last round: $%3.2f</li>" + - "</ul>", - clientData.getTokensCollectedLastRound(), - clientData.getSanctionPenalties(), - clientData.getSanctionCosts(), - clientData.getCurrentTokens(), - getIncome(clientData.getCurrentTokens())) - ); - instructionsBuilder.append(String.format("Your <b>total income</b> so far is: $%3.2f<hr>", - getIncome(clientData.getTotalTokens()))); - if (event.isLastRound()) { - instructionsBuilder.append(client.getDataModel().getLastRoundDebriefing()); - } - setInstructions(instructionsBuilder.toString()); +// instructionsBuilder.delete(0, instructionsBuilder.length()); +// ClientData clientData = event.getClientData(); +// // FIXME: split into tokens used to sanction others and tokens taken +// // away by other people. +// instructionsBuilder.append( +// String.format("<h3>Your statistics from the last round have been updated as follows:</h3>" + +// "<ul>" + +// "<li>Tokens collected last round: %d</li>" + +// "<li>Tokens subtracted by other players: %d</li>" + +// "<li>Tokens used to subtract tokens from other players: %d</li>" + +// "<li>Net earned tokens in the last round: %d</li>" + +// "<li>Net income from the last round: $%3.2f</li>" + +// "</ul>", +// clientData.getTokensCollectedLastRound(), +// clientData.getSanctionPenalties(), +// clientData.getSanctionCosts(), +// clientData.getCurrentTokens(), +// getIncome(clientData.getCurrentTokens())) +// ); +// instructionsBuilder.append(String.format("Your <b>total income</b> so far is: $%3.2f<hr>", +// getIncome(clientData.getTotalTokens()))); +// if (event.isLastRound()) { +// instructionsBuilder.append(client.getDataModel().getLastRoundDebriefing()); +// } +// setInstructions(instructionsBuilder.toString()); } diff -r dedbf30aad77d957dd1b25dc411faa456f30c6c5 -r c4bfc740cfdc5eaa6878b92678868554c3a0ba61 src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java --- a/src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java +++ b/src/main/java/edu/asu/commons/foraging/ui/InstructionsView.java @@ -46,27 +46,28 @@ } public void debrief(ClientDataModel dataModel, boolean lastRound) { - RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); - instructionsBuilder.delete(0, instructionsBuilder.length()); - instructionsBuilder.append( - String.format("<h3>Your stats in this round:</h3>" + - "<ul>" + - "<li>Tokens collected: %d</li>" + - "<li>Income: $%3.2f</li>" + - "</ul>", - dataModel.getCurrentTokens(), - dataModel.getCurrentIncome()) - ); - if (roundConfiguration.isPracticeRound()) { - instructionsBuilder.append("<h3>Note - since this was a practice round you did not earn any income this round.</h3>"); - } - double showUpPayment = roundConfiguration.getParentConfiguration().getShowUpPayment(); - instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", - showUpPayment, dataModel.getTotalIncome() + showUpPayment)); - if (lastRound) { - instructionsBuilder.append(dataModel.getLastRoundDebriefing()); - } - setInstructions(instructionsBuilder.toString()); + throw new UnsupportedOperationException("Deprecated"); +// RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); +// instructionsBuilder.delete(0, instructionsBuilder.length()); +// instructionsBuilder.append( +// String.format("<h3>Your stats in this round:</h3>" + +// "<ul>" + +// "<li>Tokens collected: %d</li>" + +// "<li>Income: $%3.2f</li>" + +// "</ul>", +// dataModel.getCurrentTokens(), +// dataModel.getCurrentIncome()) +// ); +// if (roundConfiguration.isPracticeRound()) { +// instructionsBuilder.append("<h3>Note - since this was a practice round you did not earn any income this round.</h3>"); +// } +// double showUpPayment = roundConfiguration.getParentConfiguration().getShowUpPayment(); +// instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", +// showUpPayment, dataModel.getTotalIncome() + showUpPayment)); +// if (lastRound) { +// instructionsBuilder.append(dataModel.getLastRoundDebriefing()); +// } +// setInstructions(instructionsBuilder.toString()); } /** 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...> - 2012-02-02 02:25:07
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/cd8b8aba3bfd/ changeset: cd8b8aba3bfd user: alllee date: 2012-02-02 03:24:57 summary: fixing client-debriefing template by adding a transient self boolean to ClientData representing whether or not that ClientData is the same as the one running the client interface + package refactoring affected #: 30 files diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java @@ -11,7 +11,7 @@ import javax.swing.JPanel; import javax.swing.Timer; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; /** * $Id$ diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -94,8 +94,7 @@ private void sendMessage() { String message = chatField.getText(); if (message != null && ! message.isEmpty() && targetIdentifier != null) { - displayMessage(String.format("%s : ", getChatHandle(getClientId())), - message); + displayMessage(getChatHandle(getClientId()), message); chatField.setText(""); irrigationClient.transmit(new ChatRequest(getClientId(), message, targetIdentifier)); } @@ -157,8 +156,10 @@ } public void displayMessage(String chatHandle, String message) { - // String chatHandle = getChatHandle(source); final StyledDocument document = messageWindow.getStyledDocument(); + if (!chatHandle.endsWith(":")) { + chatHandle = chatHandle.concat(":"); + } try { document.insertString(0, chatHandle, document.getStyle("bold")); document.insertString(chatHandle.length(), message + "\n", document.getStyle("italic")); @@ -170,7 +171,7 @@ } public void initialize(List<Identifier> participants) { - displayMessage("", " ---- chat round starting ---- "); + displayMessage("System Message", " ---- chat round starting ---- "); if (HANDLES != null) { return; } @@ -193,7 +194,7 @@ public void handle(final ChatEvent chatEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { - displayMessage(String.format("%s : ", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), + displayMessage(getChatHandle(chatEvent.getSource()), chatEvent.toString()); } }); diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java @@ -12,8 +12,8 @@ import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.irrigation.events.ClientUpdateEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** @@ -109,8 +109,10 @@ } public List<ClientData> getClientDataSortedByPriority() { - ArrayList<ClientData> clientDataList = new ArrayList<ClientData>(getGroupDataModel().getClientDataMap().values()); - // sort by position. + Map<Identifier, ClientData> clientDataMap = getGroupDataModel().getClientDataMap(); + clientDataMap.get(getId()).setSelf(true); + ArrayList<ClientData> clientDataList = new ArrayList<ClientData>(clientDataMap.values()); + // sort by priority Collections.sort(clientDataList, new Comparator<ClientData>() { public int compare(ClientData a, ClientData b) { return Integer.valueOf(a.getPriority()).compareTo(b.getPriority()); diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -31,8 +31,8 @@ import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.irrigation.events.EndRoundEvent; import edu.asu.commons.irrigation.events.QuizResponseEvent; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.ui.HtmlEditorPane; import edu.asu.commons.ui.HtmlEditorPane.FormActionEvent; import edu.asu.commons.ui.UserInterfaceUtils; diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/GamePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java @@ -26,7 +26,7 @@ import org.jfree.data.xy.XYSeriesCollection; import edu.asu.commons.irrigation.conf.ServerConfiguration; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; /** * $Id$ * diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java @@ -13,7 +13,7 @@ import org.jfree.data.xy.XYSeriesCollection; import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.GroupDataModel; /** * $Id$ diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java @@ -7,7 +7,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; /** * $Id$ diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java @@ -8,7 +8,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; /** * $Id$ diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java @@ -7,8 +7,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; /** * $Id$ diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java @@ -13,8 +13,8 @@ import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -6,7 +6,7 @@ import edu.asu.commons.conf.ExperimentRoundParameters; import edu.asu.commons.irrigation.client.ClientDataModel; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; import edu.asu.commons.util.Duration; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -9,7 +9,7 @@ import org.stringtemplate.v4.ST; import edu.asu.commons.conf.ExperimentConfiguration; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; /** * $Id$ @@ -99,7 +99,8 @@ } public String getChatDurationInMinutes() { - return assistant.inMinutes(getChatDuration()) + " minutes"; + long minutes = assistant.inMinutes(getChatDuration()); + return String.format("%d minute%s", minutes, (minutes > 1) ? "s" : ""); } public double getTotalIncome(ClientData data) { diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/data/IrrigationSaveFileConverter.java --- a/src/main/java/edu/asu/commons/irrigation/data/IrrigationSaveFileConverter.java +++ b/src/main/java/edu/asu/commons/irrigation/data/IrrigationSaveFileConverter.java @@ -17,9 +17,9 @@ import edu.asu.commons.experiment.SaveFileProcessor; import edu.asu.commons.experiment.SavedRoundData; import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; -import edu.asu.commons.irrigation.server.ServerDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; +import edu.asu.commons.irrigation.model.ServerDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/BeginChatRoundRequest.java --- a/src/main/java/edu/asu/commons/irrigation/events/BeginChatRoundRequest.java +++ b/src/main/java/edu/asu/commons/irrigation/events/BeginChatRoundRequest.java @@ -2,7 +2,7 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.event.FacilitatorRequest; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/ClientUpdateEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/ClientUpdateEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/ClientUpdateEvent.java @@ -2,7 +2,7 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.event.ExperimentUpdateEvent; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/EndRoundEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/EndRoundEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/EndRoundEvent.java @@ -2,7 +2,7 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.event.ExperimentUpdateEvent; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java @@ -1,7 +1,7 @@ package edu.asu.commons.irrigation.events; import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.irrigation.server.ServerDataModel; +import edu.asu.commons.irrigation.model.ServerDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/InfrastructureUpdateEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/InfrastructureUpdateEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/InfrastructureUpdateEvent.java @@ -4,8 +4,8 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.event.ExperimentUpdateEvent; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java @@ -3,7 +3,7 @@ import edu.asu.commons.event.AbstractEvent; import edu.asu.commons.event.ExperimentUpdateEvent; import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.model.ClientData; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/events/RoundStartedEvent.java --- a/src/main/java/edu/asu/commons/irrigation/events/RoundStartedEvent.java +++ b/src/main/java/edu/asu/commons/irrigation/events/RoundStartedEvent.java @@ -1,7 +1,7 @@ package edu.asu.commons.irrigation.events; import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.irrigation.model.GroupDataModel; import edu.asu.commons.net.Identifier; /** diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java --- a/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java +++ b/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java @@ -18,7 +18,7 @@ import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.RegistrationEvent; -import edu.asu.commons.irrigation.server.ServerDataModel; +import edu.asu.commons.irrigation.model.ServerDataModel; import edu.asu.commons.net.ClientDispatcher; import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java --- a/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java @@ -18,9 +18,9 @@ import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.ShowQuizRequest; -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; -import edu.asu.commons.irrigation.server.ServerDataModel; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; +import edu.asu.commons.irrigation.model.ServerDataModel; import edu.asu.commons.net.Identifier; import edu.asu.commons.ui.HtmlEditorPane; import edu.asu.commons.ui.UserInterfaceUtils; diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/model/ClientData.java --- /dev/null +++ b/src/main/java/edu/asu/commons/irrigation/model/ClientData.java @@ -0,0 +1,254 @@ +package edu.asu.commons.irrigation.model; + +import java.io.Serializable; + +import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Stores client-specific information used by the server. + * + * FIXME: need additional fields: + * total tokens collected in a round + * minus tokens subtracted by others + * minus tokens subtracted by sanctioning others + * + * @author <a href='mailto:all...@as...'>Allen Lee</a>, Deepali Bhagvat + * @version $Revision$ + */ + +public class ClientData implements Serializable { + + private static final long serialVersionUID = 5281922601551921005L; + + private Identifier id; + + private GroupDataModel groupDataModel; + + private int waterCollected = 0; + + private int availableFlowCapacity; + + private int investedTokens; + + private int assignedNumber; + + private int correctQuizAnswers = 0; + + private RoundConfiguration roundConfiguration; + + private int totalTokens; + + private boolean gateOpen = false; + + // transient formatted earnings data set by RoundConfiguration while generating debriefing text + private String quizEarnings; + private String grandTotalIncome; + private String totalDollarsEarnedThisRound; + + // represents whether or not this ClientData is for the client in question. + private transient boolean self = false; + + public ClientData(Identifier id) { + this.id = id; + } + + public boolean isGateClosed(){ + return ! gateOpen; + } + + public boolean isGateOpen(){ + return gateOpen; + } + + /** + * The actual bandwidth allocated to this client. + */ + public void setAvailableFlowCapacity(int availableFlowCapacity) { + this.availableFlowCapacity = availableFlowCapacity; + } + + public int getAvailableFlowCapacity(){ + return availableFlowCapacity; + } + + public int getPriority() { + return getAssignedNumber() - 1; + } + + // FIXME: logic duplicated with ServerConfiguration.toPriorityString(int priority); + private final static String[] PRIORITY_STRINGS = { "A", "B", "C", "D", "E" }; + + public String getPriorityString() { + // bounds check + int priority = getPriority(); + if (priority >= 0 && priority < PRIORITY_STRINGS.length) { + return PRIORITY_STRINGS[priority]; + } + return "Position not found"; + } + + public void openGate(){ + gateOpen = true; + } + + public void closeGate(){ + gateOpen = false; + } + + /** + * get and set the Tokens that are contributed by this client. + * * @param contributedTokens + */ + public void setInvestedTokens(int investedTokens) { + this.investedTokens = investedTokens; + } + + public int getInvestedTokens(){ + return investedTokens; + } + + public int getUninvestedTokens() { + return roundConfiguration.getMaximumTokenInvestment() - investedTokens; + } + + public GroupDataModel getGroupDataModel() { + return groupDataModel; + } + public void setGroupDataModel(GroupDataModel group) { + this.groupDataModel = group; + } + public Identifier getId() { + return id; + } + + public void setRoundConfiguration(RoundConfiguration roundConfiguration) { + this.roundConfiguration = roundConfiguration; + } + + /** + * Resets this client data's instance variables at the end of the round. + * + */ + public void resetEndRound() { + closeGate(); + investedTokens = 0; + waterCollected = 0; + } + + public void resetAllTokens() { + resetEndRound(); + totalTokens = 0; + } + + public int getAssignedNumber() { + return assignedNumber; + } + + public void setAssignedNumber(int assignedNumber) { + this.assignedNumber = assignedNumber; + } + + public int getTotalTokens() { + return totalTokens; + } + + + public RoundConfiguration getRoundConfiguration(){ + return roundConfiguration; + } + /** + * This would initialize the clientData before the start of each download. + * + */ + public void init(int availableFlowCapacity) { + closeGate(); + setAvailableFlowCapacity(availableFlowCapacity); + } + + public void addTokensEarnedThisRoundToTotal() { + totalTokens += getAllTokensEarnedThisRound(); + } + + /** + * Returns the current number of tokens given to this participant. + * @return + */ + public int getAllTokensEarnedThisRound(){ + return getTokensEarnedFromWaterCollected() + getUninvestedTokens(); + } + + public String getTotalDollarsEarnedThisRound() { + return totalDollarsEarnedThisRound; + } + + /** + * Reward function table correlating water usage to tokens earned. + * + * @param value + * @return + */ + public int getTokensEarnedFromWaterCollected() { + return ServerConfiguration.getTokensEarned(waterCollected); + } + + + public void collectWater() { + waterCollected += availableFlowCapacity; + } + + public int getWaterCollected(){ + return waterCollected; + } + + public void setId(Identifier id) { + this.id = id; + } + + public boolean isImmediateNeighbor(ClientData otherClientData) { + int thisPosition = getPriority(); + int otherPosition = otherClientData.getPriority(); + return (thisPosition == otherPosition) || (thisPosition == otherPosition + 1) || (thisPosition == otherPosition - 1); + } + + public int getCorrectQuizAnswers() { + return correctQuizAnswers; + } + + public void setCorrectQuizAnswers(int correctQuizAnswers) { + this.correctQuizAnswers = correctQuizAnswers; + } + + public String getQuizEarnings() { + return quizEarnings; + } + + public void setQuizEarnings(String quizEarnings) { + this.quizEarnings = quizEarnings; + } + + public String getGrandTotalIncome() { + return grandTotalIncome; + } + + public void setGrandTotalIncome(String grandTotalIncome) { + this.grandTotalIncome = grandTotalIncome; + } + + public void setTotalDollarsEarnedThisRound(String totalDollarsEarnedThisRound) { + this.totalDollarsEarnedThisRound = totalDollarsEarnedThisRound; + } + + public boolean isSelf() { + return self; + } + + public void setSelf(boolean current) { + this.self = current; + } +} + + diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/model/GroupDataModel.java --- /dev/null +++ b/src/main/java/edu/asu/commons/irrigation/model/GroupDataModel.java @@ -0,0 +1,249 @@ +package edu.asu.commons.irrigation.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import edu.asu.commons.event.EventChannel; +import edu.asu.commons.experiment.DataModel; +import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Data model for a single Group of clients. Each Group manages its own unique resource shared among + * its own participants. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class GroupDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { + + private static final long serialVersionUID = 5817418171228817123L; + + private transient Logger logger = Logger.getLogger(GroupDataModel.class.getName()); + + private final Map<Identifier, ClientData> clients = new LinkedHashMap<Identifier, ClientData>(); + + private RoundConfiguration roundConfiguration; + + private transient ServerDataModel serverDataModel; + + + private int currentlyAvailableFlowCapacity = 0; + private int maximumAvailableWaterFlow = 0; + + private int infrastructureEfficiency; + // infrastructure efficiency before investment (but post decline) + private int infrastructureEfficiencyBeforeInvestment; + + private int totalContributedTokens = 0; + + + public GroupDataModel(ServerDataModel serverDataModel) { + this.serverDataModel = serverDataModel; + setRoundConfiguration(serverDataModel.getRoundConfiguration()); + } + + public ClientData getClientData(Identifier id) { + return clients.get(id); + } + + public List<Identifier> getAllClientIdentifiers() { + return new ArrayList<Identifier>(clients.keySet()); + } + + public void addClient(ClientData clientData) { + clients.put(clientData.getId(), clientData); + clientData.setAssignedNumber(clients.size()); + } + + public int size() { + return clients.size(); + } + + public void removeClient(Identifier id) { + clients.remove(id); + } + + public boolean isFull() { + return clients.size() == getRoundConfiguration().getClientsPerGroup(); + } + + public void clear() { + clients.clear(); + } + + public Map<Identifier, ClientData> getClientDataMap() { + return Collections.unmodifiableMap(clients); + } + + public int getAvailableClientFlowCapacity() { + return Math.min(currentlyAvailableFlowCapacity, getRoundConfiguration().getMaximumClientFlowCapacity()); + } + + public RoundConfiguration getRoundConfiguration() { + return roundConfiguration; + } + + public int getTotalContributedTokens() { + return totalContributedTokens; + } + + public void initializeInfrastructure() { + // for practice round and first round, initialize to initial infrastructure efficiency + //setting the total contributed Bandwidth = 0 , so that for every round, + // fresh totalContributed tokens are calculated + totalContributedTokens = 0; + for(ClientData clientData : getClientDataMap().values()) { + totalContributedTokens += clientData.getInvestedTokens(); + } + updateInfrastructureEfficiency(totalContributedTokens); + currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualWaterDeliveryCapacity(); + } + + private void updateInfrastructureEfficiency(int totalContributedTokens) { + RoundConfiguration roundConfiguration = getRoundConfiguration(); + // initialize infrastructure efficiency + if ( roundConfiguration.shouldResetInfrastructureEfficiency() ) { + infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); + } + else { + // degrade by infrastructure-degradation-factor, clamp at 0 + infrastructureEfficiency = Math.max(infrastructureEfficiency - roundConfiguration.getInfrastructureDegradationFactor(), 0); + } + // set original infrastructure efficiency before token contributions + getLogger().info("initial infrastructure efficiency: " + infrastructureEfficiency); + infrastructureEfficiencyBeforeInvestment = infrastructureEfficiency; + // add total invested tokens to infrastructure efficiency, clamp at + // 100 + infrastructureEfficiency = Math.min(100, totalContributedTokens + infrastructureEfficiency); + } + + /** + * This function maps flow capacity to infrastructure efficiency. Returns an int representing + * the flow capacity given the infrastructure efficiency. + * this needs to be designed. + * @param totalTokens + * @return + */ + public int calculateIrrigationCapacity(final int infrastructureEfficiency) { + if (infrastructureEfficiency <= 45) { + return 0; + } + else if (infrastructureEfficiency <= 51) { + return 5; + } + else if (infrastructureEfficiency <= 55) { + return 10; + } + else if (infrastructureEfficiency <= 58) { + return 15; + } + else if (infrastructureEfficiency <= 61) { + return 20; + } + else if (infrastructureEfficiency <= 65) { + return 25; + } + else if (infrastructureEfficiency <= 70) { + return 30; + } + else if (infrastructureEfficiency <= 80) { + return 35; + } + else if (infrastructureEfficiency <= 100) { + return 40; + } + return 40; + } + + public int getIrrigationCapacityBeforeInvestment() { +// return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); + return calculateIrrigationCapacity(infrastructureEfficiencyBeforeInvestment); + } + + /** + * Returns the theoretical maximum amount of water that the infrastructure can handle. + * This is independent of the actual water supply. + */ + public int getIrrigationCapacity() { + return calculateIrrigationCapacity(infrastructureEfficiency); +// return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); + } + + /** + * Returns the actual maximum amount of water that can pass through the canal, which is the minimum + * of the irrigation capacity and the water supply. + * @return + */ + public int getActualWaterDeliveryCapacity() { + return Math.min(getIrrigationCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); + } + + public void resetCurrentlyAvailableFlowCapacity() { + currentlyAvailableFlowCapacity = maximumAvailableWaterFlow; + } + + public void allocateWater(ClientData clientData) { + int maximumClientFlowCapacity = getRoundConfiguration().getMaximumClientFlowCapacity(); + if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { + currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; + clientData.setAvailableFlowCapacity(maximumClientFlowCapacity); + } + else { + clientData.setAvailableFlowCapacity(currentlyAvailableFlowCapacity); + currentlyAvailableFlowCapacity = 0; + } + clientData.collectWater(); + } + + public int getMaximumAvailableWaterFlow() { + return maximumAvailableWaterFlow; + } + + public int getInfrastructureEfficiency() { + return infrastructureEfficiency; + } + + public int getInfrastructureEfficiencyBeforeInvestment() { + return infrastructureEfficiencyBeforeInvestment; + } + + public Logger getLogger() { + if (logger == null) { + logger = Logger.getLogger(getClass().getName()); + } + return logger; + } + + + public void setRoundConfiguration(RoundConfiguration roundConfiguration) { + this.roundConfiguration = roundConfiguration; + } + + @Override + public EventChannel getEventChannel() { + return serverDataModel.getEventChannel(); + } + + public ServerDataModel getServerDataModel() { + return serverDataModel; + } + + public void setServerDataModel(ServerDataModel serverDataModel) { + this.serverDataModel = serverDataModel; + } + + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } + +} + diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java --- /dev/null +++ b/src/main/java/edu/asu/commons/irrigation/model/ServerDataModel.java @@ -0,0 +1,110 @@ +package edu.asu.commons.irrigation.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import edu.asu.commons.event.EventChannel; +import edu.asu.commons.experiment.DataModel; +import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class ServerDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { + + private static final long serialVersionUID = -2633842942700901843L; + + // maps client Identifiers to the Group that client belongs to. + private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); + + private RoundConfiguration roundConfiguration; + + private transient EventChannel eventChannel; + + public RoundConfiguration getRoundConfiguration() { + return roundConfiguration; + } + + public void setRoundConfiguration(RoundConfiguration roundConfiguration) { + this.roundConfiguration = roundConfiguration; + for (GroupDataModel group: clientsToGroups.values()) { + group.setRoundConfiguration(roundConfiguration); + } + } + + public synchronized void addClient(ClientData clientData) { + // iterate through all existing groups + for (GroupDataModel group : clientsToGroups.values()) { + if (!group.isFull()) { + addClientToGroup(clientData, group); + return; + } + } + GroupDataModel group = new GroupDataModel(this); + addClientToGroup(clientData, group); + return; + } + + public Set<GroupDataModel> getAllGroupDataModels() { + return new HashSet<GroupDataModel>(clientsToGroups.values()); + } + + public GroupDataModel getGroupDataModel(Identifier id) { + return clientsToGroups.get(id); + } + + + private void addClientToGroup(ClientData clientData, GroupDataModel group) { + clientData.setRoundConfiguration(roundConfiguration); + group.addClient(clientData); + clientData.setGroupDataModel(group); + clientsToGroups.put(clientData.getId(), group); + } + + public Map<Identifier, ClientData> getClientDataMap(Identifier clientId) { + GroupDataModel group = clientsToGroups.get(clientId); + return group.getClientDataMap(); + } + + public void clear() { + for (Iterator<GroupDataModel> iter = clientsToGroups.values().iterator(); iter.hasNext(); ) { + GroupDataModel group = iter.next(); + group.clear(); + iter.remove(); + } + } + + public void removeClient(Identifier id) { + GroupDataModel groupDataModel = clientsToGroups.remove(id); + groupDataModel.removeClient(id); + } + + public EventChannel getEventChannel() { + return eventChannel; + } + + public void setEventChannel(EventChannel eventChannel) { + this.eventChannel = eventChannel; + } + + @Override + public List<Identifier> getAllClientIdentifiers() { + return new ArrayList<Identifier>(clientsToGroups.keySet()); + } + + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } +} diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/server/ClientData.java --- a/src/main/java/edu/asu/commons/irrigation/server/ClientData.java +++ /dev/null @@ -1,243 +0,0 @@ -package edu.asu.commons.irrigation.server; - -import java.io.Serializable; - -import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.conf.ServerConfiguration; -import edu.asu.commons.net.Identifier; - -/** - * $Id$ - * - * Stores client-specific information used by the server. - * - * FIXME: need additional fields: - * total tokens collected in a round - * minus tokens subtracted by others - * minus tokens subtracted by sanctioning others - * - * @author <a href='mailto:all...@as...'>Allen Lee</a>, Deepali Bhagvat - * @version $Revision$ - */ - -public class ClientData implements Serializable { - - private static final long serialVersionUID = 5281922601551921005L; - - private Identifier id; - - private GroupDataModel groupDataModel; - - private int waterCollected = 0; - - private int availableFlowCapacity; - - private int investedTokens; - - private int assignedNumber; - - private int correctQuizAnswers = 0; - - private RoundConfiguration roundConfiguration; - - private int totalTokens; - - private boolean gateOpen = false; - - // transient formatted earnings data set by RoundConfiguration while generating debriefing text - private String quizEarnings; - private String grandTotalIncome; - private String totalDollarsEarnedThisRound; - - public ClientData(Identifier id) { - this.id = id; - } - - public boolean isGateClosed(){ - return ! gateOpen; - } - - public boolean isGateOpen(){ - return gateOpen; - } - - /** - * The actual bandwidth allocated to this client. - */ - public void setAvailableFlowCapacity(int availableFlowCapacity) { - this.availableFlowCapacity = availableFlowCapacity; - } - - public int getAvailableFlowCapacity(){ - return availableFlowCapacity; - } - - public int getPriority() { - return getAssignedNumber() - 1; - } - - // FIXME: logic duplicated with ServerConfiguration.toPriorityString(int priority); - private final static String[] PRIORITY_STRINGS = { "A", "B", "C", "D", "E" }; - - public String getPriorityString() { - // bounds check - int priority = getPriority(); - if (priority >= 0 && priority < PRIORITY_STRINGS.length) { - return PRIORITY_STRINGS[priority]; - } - return "Position not found"; - } - - public void openGate(){ - gateOpen = true; - } - - public void closeGate(){ - gateOpen = false; - } - - /** - * get and set the Tokens that are contributed by this client. - * * @param contributedTokens - */ - public void setInvestedTokens(int investedTokens) { - this.investedTokens = investedTokens; - } - - public int getInvestedTokens(){ - return investedTokens; - } - - public int getUninvestedTokens() { - return roundConfiguration.getMaximumTokenInvestment() - investedTokens; - } - - public GroupDataModel getGroupDataModel() { - return groupDataModel; - } - public void setGroupDataModel(GroupDataModel group) { - this.groupDataModel = group; - } - public Identifier getId() { - return id; - } - - public void setRoundConfiguration(RoundConfiguration roundConfiguration) { - this.roundConfiguration = roundConfiguration; - } - - /** - * Resets this client data's instance variables at the end of the round. - * - */ - public void resetEndRound() { - closeGate(); - investedTokens = 0; - waterCollected = 0; - } - - public void resetAllTokens() { - resetEndRound(); - totalTokens = 0; - } - - public int getAssignedNumber() { - return assignedNumber; - } - - public void setAssignedNumber(int assignedNumber) { - this.assignedNumber = assignedNumber; - } - - public int getTotalTokens() { - return totalTokens; - } - - - public RoundConfiguration getRoundConfiguration(){ - return roundConfiguration; - } - /** - * This would initialize the clientData before the start of each download. - * - */ - public void init(int availableFlowCapacity) { - closeGate(); - setAvailableFlowCapacity(availableFlowCapacity); - } - - public void addTokensEarnedThisRoundToTotal() { - totalTokens += getAllTokensEarnedThisRound(); - } - - /** - * Returns the current number of tokens given to this participant. - * @return - */ - public int getAllTokensEarnedThisRound(){ - return getTokensEarnedFromWaterCollected() + getUninvestedTokens(); - } - - public String getTotalDollarsEarnedThisRound() { - return totalDollarsEarnedThisRound; - } - - /** - * Reward function table correlating water usage to tokens earned. - * - * @param value - * @return - */ - public int getTokensEarnedFromWaterCollected() { - return ServerConfiguration.getTokensEarned(waterCollected); - } - - - public void collectWater() { - waterCollected += availableFlowCapacity; - } - - public int getWaterCollected(){ - return waterCollected; - } - - public void setId(Identifier id) { - this.id = id; - } - - public boolean isImmediateNeighbor(ClientData otherClientData) { - int thisPosition = getPriority(); - int otherPosition = otherClientData.getPriority(); - return (thisPosition == otherPosition) || (thisPosition == otherPosition + 1) || (thisPosition == otherPosition - 1); - } - - public int getCorrectQuizAnswers() { - return correctQuizAnswers; - } - - public void setCorrectQuizAnswers(int correctQuizAnswers) { - this.correctQuizAnswers = correctQuizAnswers; - } - - public String getQuizEarnings() { - return quizEarnings; - } - - public void setQuizEarnings(String quizEarnings) { - this.quizEarnings = quizEarnings; - } - - public String getGrandTotalIncome() { - return grandTotalIncome; - } - - public void setGrandTotalIncome(String grandTotalIncome) { - this.grandTotalIncome = grandTotalIncome; - } - - public void setTotalDollarsEarnedThisRound(String totalDollarsEarnedThisRound) { - this.totalDollarsEarnedThisRound = totalDollarsEarnedThisRound; - } -} - - diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java +++ /dev/null @@ -1,249 +0,0 @@ -package edu.asu.commons.irrigation.server; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import edu.asu.commons.event.EventChannel; -import edu.asu.commons.experiment.DataModel; -import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.conf.ServerConfiguration; -import edu.asu.commons.net.Identifier; - -/** - * $Id$ - * - * Data model for a single Group of clients. Each Group manages its own unique resource shared among - * its own participants. - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class GroupDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { - - private static final long serialVersionUID = 5817418171228817123L; - - private transient Logger logger = Logger.getLogger(GroupDataModel.class.getName()); - - private final Map<Identifier, ClientData> clients = new LinkedHashMap<Identifier, ClientData>(); - - private RoundConfiguration roundConfiguration; - - private transient ServerDataModel serverDataModel; - - - private int currentlyAvailableFlowCapacity = 0; - private int maximumAvailableWaterFlow = 0; - - private int infrastructureEfficiency; - // infrastructure efficiency before investment (but post decline) - private int infrastructureEfficiencyBeforeInvestment; - - private int totalContributedTokens = 0; - - - public GroupDataModel(ServerDataModel serverDataModel) { - this.serverDataModel = serverDataModel; - setRoundConfiguration(serverDataModel.getRoundConfiguration()); - } - - public ClientData getClientData(Identifier id) { - return clients.get(id); - } - - public List<Identifier> getAllClientIdentifiers() { - return new ArrayList<Identifier>(clients.keySet()); - } - - public void addClient(ClientData clientData) { - clients.put(clientData.getId(), clientData); - clientData.setAssignedNumber(clients.size()); - } - - public int size() { - return clients.size(); - } - - public void removeClient(Identifier id) { - clients.remove(id); - } - - public boolean isFull() { - return clients.size() == getRoundConfiguration().getClientsPerGroup(); - } - - public void clear() { - clients.clear(); - } - - public Map<Identifier, ClientData> getClientDataMap() { - return Collections.unmodifiableMap(clients); - } - - public int getAvailableClientFlowCapacity() { - return Math.min(currentlyAvailableFlowCapacity, getRoundConfiguration().getMaximumClientFlowCapacity()); - } - - public RoundConfiguration getRoundConfiguration() { - return roundConfiguration; - } - - public int getTotalContributedTokens() { - return totalContributedTokens; - } - - public void initializeInfrastructure() { - // for practice round and first round, initialize to initial infrastructure efficiency - //setting the total contributed Bandwidth = 0 , so that for every round, - // fresh totalContributed tokens are calculated - totalContributedTokens = 0; - for(ClientData clientData : getClientDataMap().values()) { - totalContributedTokens += clientData.getInvestedTokens(); - } - updateInfrastructureEfficiency(totalContributedTokens); - currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualWaterDeliveryCapacity(); - } - - private void updateInfrastructureEfficiency(int totalContributedTokens) { - RoundConfiguration roundConfiguration = getRoundConfiguration(); - // initialize infrastructure efficiency - if ( roundConfiguration.shouldResetInfrastructureEfficiency() ) { - infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); - } - else { - // degrade by infrastructure-degradation-factor, clamp at 0 - infrastructureEfficiency = Math.max(infrastructureEfficiency - roundConfiguration.getInfrastructureDegradationFactor(), 0); - } - // set original infrastructure efficiency before token contributions - getLogger().info("initial infrastructure efficiency: " + infrastructureEfficiency); - infrastructureEfficiencyBeforeInvestment = infrastructureEfficiency; - // add total invested tokens to infrastructure efficiency, clamp at - // 100 - infrastructureEfficiency = Math.min(100, totalContributedTokens + infrastructureEfficiency); - } - - /** - * This function maps flow capacity to infrastructure efficiency. Returns an int representing - * the flow capacity given the infrastructure efficiency. - * this needs to be designed. - * @param totalTokens - * @return - */ - public int calculateIrrigationCapacity(final int infrastructureEfficiency) { - if (infrastructureEfficiency <= 45) { - return 0; - } - else if (infrastructureEfficiency <= 51) { - return 5; - } - else if (infrastructureEfficiency <= 55) { - return 10; - } - else if (infrastructureEfficiency <= 58) { - return 15; - } - else if (infrastructureEfficiency <= 61) { - return 20; - } - else if (infrastructureEfficiency <= 65) { - return 25; - } - else if (infrastructureEfficiency <= 70) { - return 30; - } - else if (infrastructureEfficiency <= 80) { - return 35; - } - else if (infrastructureEfficiency <= 100) { - return 40; - } - return 40; - } - - public int getIrrigationCapacityBeforeInvestment() { -// return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); - return calculateIrrigationCapacity(infrastructureEfficiencyBeforeInvestment); - } - - /** - * Returns the theoretical maximum amount of water that the infrastructure can handle. - * This is independent of the actual water supply. - */ - public int getIrrigationCapacity() { - return calculateIrrigationCapacity(infrastructureEfficiency); -// return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); - } - - /** - * Returns the actual maximum amount of water that can pass through the canal, which is the minimum - * of the irrigation capacity and the water supply. - * @return - */ - public int getActualWaterDeliveryCapacity() { - return Math.min(getIrrigationCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); - } - - public void resetCurrentlyAvailableFlowCapacity() { - currentlyAvailableFlowCapacity = maximumAvailableWaterFlow; - } - - public void allocateWater(ClientData clientData) { - int maximumClientFlowCapacity = getRoundConfiguration().getMaximumClientFlowCapacity(); - if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { - currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; - clientData.setAvailableFlowCapacity(maximumClientFlowCapacity); - } - else { - clientData.setAvailableFlowCapacity(currentlyAvailableFlowCapacity); - currentlyAvailableFlowCapacity = 0; - } - clientData.collectWater(); - } - - public int getMaximumAvailableWaterFlow() { - return maximumAvailableWaterFlow; - } - - public int getInfrastructureEfficiency() { - return infrastructureEfficiency; - } - - public int getInfrastructureEfficiencyBeforeInvestment() { - return infrastructureEfficiencyBeforeInvestment; - } - - public Logger getLogger() { - if (logger == null) { - logger = Logger.getLogger(getClass().getName()); - } - return logger; - } - - - public void setRoundConfiguration(RoundConfiguration roundConfiguration) { - this.roundConfiguration = roundConfiguration; - } - - @Override - public EventChannel getEventChannel() { - return serverDataModel.getEventChannel(); - } - - public ServerDataModel getServerDataModel() { - return serverDataModel; - } - - public void setServerDataModel(ServerDataModel serverDataModel) { - this.serverDataModel = serverDataModel; - } - - @Override - public ServerConfiguration getExperimentConfiguration() { - return roundConfiguration.getParentConfiguration(); - } - -} - diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java --- a/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java +++ b/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java @@ -37,6 +37,9 @@ import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.ShowQuizRequest; import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; +import edu.asu.commons.irrigation.model.ClientData; +import edu.asu.commons.irrigation.model.GroupDataModel; +import edu.asu.commons.irrigation.model.ServerDataModel; import edu.asu.commons.net.Dispatcher; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.SocketIdentifier; diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java +++ /dev/null @@ -1,110 +0,0 @@ -package edu.asu.commons.irrigation.server; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import edu.asu.commons.event.EventChannel; -import edu.asu.commons.experiment.DataModel; -import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.conf.ServerConfiguration; -import edu.asu.commons.net.Identifier; - -/** - * $Id$ - * - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class ServerDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { - - private static final long serialVersionUID = -2633842942700901843L; - - // maps client Identifiers to the Group that client belongs to. - private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); - - private RoundConfiguration roundConfiguration; - - private transient EventChannel eventChannel; - - public RoundConfiguration getRoundConfiguration() { - return roundConfiguration; - } - - public void setRoundConfiguration(RoundConfiguration roundConfiguration) { - this.roundConfiguration = roundConfiguration; - for (GroupDataModel group: clientsToGroups.values()) { - group.setRoundConfiguration(roundConfiguration); - } - } - - public synchronized void addClient(ClientData clientData) { - // iterate through all existing groups - for (GroupDataModel group : clientsToGroups.values()) { - if (!group.isFull()) { - addClientToGroup(clientData, group); - return; - } - } - GroupDataModel group = new GroupDataModel(this); - addClientToGroup(clientData, group); - return; - } - - public Set<GroupDataModel> getAllGroupDataModels() { - return new HashSet<GroupDataModel>(clientsToGroups.values()); - } - - public GroupDataModel getGroupDataModel(Identifier id) { - return clientsToGroups.get(id); - } - - - private void addClientToGroup(ClientData clientData, GroupDataModel group) { - clientData.setRoundConfiguration(roundConfiguration); - group.addClient(clientData); - clientData.setGroupDataModel(group); - clientsToGroups.put(clientData.getId(), group); - } - - public Map<Identifier, ClientData> getClientDataMap(Identifier clientId) { - GroupDataModel group = clientsToGroups.get(clientId); - return group.getClientDataMap(); - } - - public void clear() { - for (Iterator<GroupDataModel> iter = clientsToGroups.values().iterator(); iter.hasNext(); ) { - GroupDataModel group = iter.next(); - group.clear(); - iter.remove(); - } - } - - public void removeClient(Identifier id) { - GroupDataModel groupDataModel = clientsToGroups.remove(id); - groupDataModel.removeClient(id); - } - - public EventChannel getEventChannel() { - return eventChannel; - } - - public void setEventChannel(EventChannel eventChannel) { - this.eventChannel = eventChannel; - } - - @Override - public List<Identifier> getAllClientIdentifiers() { - return new ArrayList<Identifier>(clientsToGroups.keySet()); - } - - @Override - public ServerConfiguration getExperimentConfiguration() { - return roundConfiguration.getParentConfiguration(); - } -} diff -r d1297849a7ca83a02f28ff7188ad826751754ce7 -r cd8b8aba3bfd94931c8ec1b1d214a5d12e2b9a8e src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -376,7 +376,7 @@ <th>Total dollars earned</th></tr> {dataModel.clientDataSortedByPriority: {clientData| - <tr align='center' bgcolor='#{if (clientData.priority==dataModel.priority)}FFFFCC{else}CCCCCC{endif}'> + <tr align='center' bgcolor='#{if (clientData.self)}FFFFCC{else}CCCCCC{endif}'><td>{clientData.priorityString}</td><td>{self.tokenEndowment}</td><td>{clientData.investedTokens}</td> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-02-01 00:10:36
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/d1297849a7ca/ changeset: d1297849a7ca user: alllee date: 2012-02-01 01:10:22 summary: refactoring ChatPanel, fixing chat instructions template and default dollars per token affected #: 8 files diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 build.xml --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ -<!-- $Id: build.xml 330 2008-02-13 05:31:26Z alllee $ +<!-- $Id$ vim:sts=2:sw=2: - Version: $Revision: 330 $ + Version: $Revision$ --><project xmlns:ivy='antlib:org.apache.ivy.ant' name="irrigation" default="build-all" basedir="."> @@ -220,6 +220,9 @@ <!-- Clean up build by deleting build directories --><target name="clean"> + <echo message="Removing ${user.home}/.ant/cache" /> + <delete dir='${user.home}/.ant/cache' /> + <delete dir='${user.home}/.m2/repository/edu/asu/commons' /><delete dir="${build.dir}"/><delete dir="${test.build.dir}"/><delete dir='${lib.dir}'/> diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -20,12 +20,12 @@ import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import javax.swing.text.StyledDocument; -import javax.swing.text.html.HTMLEditorKit; import edu.asu.commons.event.ChatEvent; import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.EventTypeProcessor; import edu.asu.commons.net.Identifier; +import edu.asu.commons.ui.UserInterfaceUtils; /** * $Id$ @@ -148,11 +148,7 @@ messageScrollPane = new JScrollPane(messageWindow); addStylesToMessageWindow(); textEntryPanel = new TextEntryPanel(); - chatInstructionsPane = new JEditorPane(); - chatInstructionsPane.setContentType("text/html"); - chatInstructionsPane.setEditorKit(new HTMLEditorKit()); - chatInstructionsPane.setEditable(false); - chatInstructionsPane.setBackground(Color.WHITE); + chatInstructionsPane = UserInterfaceUtils.createInstructionsEditorPane(); JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); add(chatInstructionsScrollPane, BorderLayout.PAGE_START); add(messageScrollPane, BorderLayout.CENTER); @@ -164,9 +160,9 @@ // String chatHandle = getChatHandle(source); final StyledDocument document = messageWindow.getStyledDocument(); try { - document.insertString(document.getLength(), chatHandle, document.getStyle("bold")); - document.insertString(document.getLength(), message + "\n", document.getStyle("italic")); - messageWindow.setCaretPosition(document.getLength()); + document.insertString(0, chatHandle, document.getStyle("bold")); + document.insertString(chatHandle.length(), message + "\n", document.getStyle("italic")); + messageWindow.setCaretPosition(0); } catch (BadLocationException e) { e.printStackTrace(); diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java @@ -24,7 +24,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class ClientDataModel implements DataModel<RoundConfiguration> { +public class ClientDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = -3424256672940188027L; @@ -135,5 +135,10 @@ return getClientData().isImmediateNeighbor(otherClientData); } + @Override + public ServerConfiguration getExperimentConfiguration() { + return serverConfiguration; + } + } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java --- a/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java +++ b/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java @@ -1,7 +1,5 @@ package edu.asu.commons.irrigation.client; -import java.awt.Dimension; - import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -30,6 +28,7 @@ import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.SocketIdentifier; +import edu.asu.commons.ui.UserInterfaceUtils; /** * $Id$ @@ -105,13 +104,9 @@ JFrame frame = new JFrame(); IrrigationClient client = new IrrigationClient(); client.initialize(); - frame.setTitle("Virtual Commons Experiment Client: " + client.id); - frame.setPreferredSize(new Dimension(1200, 800)); -// frame.setResizable(false); - frame.getContentPane().add(client.getExperimentGameWindow()); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); + frame.setTitle("Client Window: " + client.getId()); + frame.add(client.getExperimentGameWindow()); + UserInterfaceUtils.maximize(frame); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -28,7 +28,7 @@ private static final String DEFAULT_LOG_FILE_DESTINATION = "irrigation.log"; - private static final double DEFAULT_DOLLARS_PER_TOKEN = 0.50d; + private static final double DEFAULT_DOLLARS_PER_TOKEN = 0.05d; public ServerConfiguration() { super(); @@ -95,9 +95,11 @@ } public String getChatInstructions() { - ST template = createStringTemplate(assistant.getProperty("chat-instructions")); - template.add("chatDuration", getChatDuration()); - return template.render(); + return createStringTemplate(assistant.getProperty("chat-instructions")).render(); + } + + public String getChatDurationInMinutes() { + return assistant.inMinutes(getChatDuration()) + " minutes"; } public double getTotalIncome(ClientData data) { diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java @@ -10,6 +10,7 @@ import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.net.Identifier; /** @@ -21,7 +22,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class GroupDataModel implements DataModel<RoundConfiguration> { +public class GroupDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = 5817418171228817123L; @@ -239,5 +240,10 @@ this.serverDataModel = serverDataModel; } + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } + } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java @@ -1,6 +1,5 @@ package edu.asu.commons.irrigation.server; -import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -12,6 +11,7 @@ import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.net.Identifier; /** @@ -21,7 +21,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class ServerDataModel implements DataModel<RoundConfiguration>, Serializable { +public class ServerDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = -2633842942700901843L; @@ -102,4 +102,9 @@ public List<Identifier> getAllClientIdentifiers() { return new ArrayList<Identifier>(clientsToGroups.keySet()); } + + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -85,7 +85,7 @@ infrastructure. Based on the <b>water delivery capacity</b> of the irrigation infrastructure and the availability of water you will be able to grow crops. Tokens earned in a round is the sum of tokens not invested plus tokens earned by growing -crops. Each token is worth 5 cents. In each round you will first decide how much to +crops. Each token is worth {dollarsPerToken}. In each round you will first decide how much to invest in the irrigation infrastructure. Based on the combined contributions of all 5 participants in your group in each round, your group can maintain the capacity of the irrigation infrastructure for growing crops. @@ -93,9 +93,9 @@ <p> We will now start a practice round to help illustrate the experiment. Before each -round in this experiment you will have a chat period of %d seconds where you can -send text messages to the other participants. You may discuss any aspect of the -exercise with two important exceptions: +round in this experiment you will have a chat period of {self.chatDurationInMinutes} +where you can send text messages to the other participants. You may discuss any +aspect of the exercise with two important exceptions: </p><ol><li>You are <b>not allowed</b> to promise the other participants Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- 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...> - 2012-01-31 20:33:45
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/190307106d69/ changeset: 190307106d69 user: alllee date: 2012-01-31 21:33:34 summary: version bumps on library dependencies affected #: 5 files diff -r 1a7dc397625f280283925aa1ff94694787821ed8 -r 190307106d6904b6c74e26061360fbde17e987f5 ivy.xml --- a/ivy.xml +++ b/ivy.xml @@ -5,10 +5,7 @@ <ivy-module version="2.0"><info organisation="edu.asu.commons" module="irrigation"/><dependencies> - <dependency org="edu.asu.commons" name="csidex" rev="0.2-SNAPSHOT"/> - <dependency org="org.antlr" name="stringtemplate" rev="4.0.2"/> - <dependency org="jfree" name="jfreechart" rev="1.0.13"/> - <dependency org="jfree" name="jcommon" rev="1.0.16"/> - <dependency org="org.freemarker" name="freemarker" rev="2.3.16"/> + <dependency org="edu.asu.commons" name="csidex" rev="0.3-SNAPSHOT"/> + <dependency org="org.jfree" name="jfreechart" rev="1.0.14"/></dependencies></ivy-module> diff -r 1a7dc397625f280283925aa1ff94694787821ed8 -r 190307106d6904b6c74e26061360fbde17e987f5 ivysettings.xml --- a/ivysettings.xml +++ b/ivysettings.xml @@ -13,7 +13,6 @@ </filesystem><ibiblio name='commons.snapshots' m2compatible='true' root='http://dev.commons.asu.edu/archiva/repository/snapshots'/><ibiblio name='commons.internal' m2compatible='true' root='http://dev.commons.asu.edu/archiva/repository/internal'/> - <ibiblio name='tdar.archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/></chain></resolvers></ivysettings> diff -r 1a7dc397625f280283925aa1ff94694787821ed8 -r 190307106d6904b6c74e26061360fbde17e987f5 pom.xml --- a/pom.xml +++ b/pom.xml @@ -31,38 +31,28 @@ <dependency><groupId>junit</groupId><artifactId>junit</artifactId> - <version>4.5</version> + <version>4.10</version><scope>test</scope></dependency><dependency><groupId>edu.asu.commons</groupId><artifactId>csidex</artifactId> - <version>0.2-SNAPSHOT</version> + <version>0.3-SNAPSHOT</version></dependency><dependency> - <groupId>jfree</groupId> - <artifactId>jcommon</artifactId> - <version>1.0.16</version> + <groupId>org.jfree</groupId> + <artifactId>jfreechart</artifactId> + <version>1.0.14</version></dependency><dependency> - <groupId>jfree</groupId> - <artifactId>jfreechart</artifactId> - <version>1.0.13</version> + <groupId>net.java.dev.jgoodies</groupId> + <artifactId>looks</artifactId> + <version>2.1.4</version></dependency><dependency> - <groupId>jgoodies</groupId> - <artifactId>looks</artifactId> - <version>1.2.2</version> - </dependency> - <dependency> - <groupId>org.antlr</groupId> - <artifactId>stringtemplate</artifactId> - <version>4.0.2</version> - </dependency> - <dependency> - <groupId>jgoodies</groupId> + <groupId>net.java.dev.jgoodies</groupId><artifactId>forms</artifactId> - <version>1.0.5</version> + <version>1.1.0</version></dependency></dependencies><build> diff -r 1a7dc397625f280283925aa1ff94694787821ed8 -r 190307106d6904b6c74e26061360fbde17e987f5 src/main/resources/web/client.jnlp --- a/src/main/resources/web/client.jnlp +++ b/src/main/resources/web/client.jnlp @@ -13,7 +13,7 @@ <jar href='jcommon.jar'/><jar href='@FRAMEWORK_JAR@'/><jar href='jfreechart.jar'/> - <jar href='stringtemplate.jar'/> + <jar href='ST4.jar'/><jar href='antlr-runtime.jar'/></resources><application-desc main-class="@MAIN_CLASS@"/> diff -r 1a7dc397625f280283925aa1ff94694787821ed8 -r 190307106d6904b6c74e26061360fbde17e987f5 src/main/resources/web/facilitator.jnlp --- a/src/main/resources/web/facilitator.jnlp +++ b/src/main/resources/web/facilitator.jnlp @@ -11,7 +11,7 @@ <j2se version="1.6+"/><jar href="facilitator.jar"/><jar href='@FRAMEWORK_JAR@'/> - <jar href='stringtemplate.jar'/> + <jar href='ST4.jar'/><jar href='antlr-runtime.jar'/></resources><application-desc main-class="@MAIN_CLASS@"/> Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |