virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 58)
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: <kj...@us...> - 2009-12-01 19:06:56
|
Revision: 383 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=383&view=rev Author: kjonas Date: 2009-12-01 19:06:46 +0000 (Tue, 01 Dec 2009) Log Message: ----------- Added messageHandler and faultHandler methods. not sure how to use consumers etc to set this up, so will leave that to Seema. Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/Communication.mxml Modified: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-01 08:54:41 UTC (rev 382) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-01 19:06:46 UTC (rev 383) @@ -3,14 +3,36 @@ <mx:Script> <![CDATA[ + import mx.rpc.events.ResultEvent; + import mx.rpc.events.FaultEvent; import actionscript.Communication; import actionscript.Student; import mx.controls.Label; import mx.controls.Text; + public var student:Student = null; + + public function faultHandler(event:FaultEvent):void + { + // Silent Failure + } + public function messageHandler(event:ResultEvent):void + { + if(event.message.body is actionscript.Communication) + { + commReceived(event.message.body as actionscript.Communication); + } + } + public function btnSend_click():void { - //<service>.<method>(txtMessage.text); + var tempCommunication:actionscript.Communication = new actionscript.Communication(); + tempCommunication.date = new Date(); + tempCommunication.message = txtMessage.text; + tempCommunication.student = this.student; + txtMessage.text = ""; + + //<service>.<method>(tempCommunication); } public function btnSelfComm_click():void { @@ -46,6 +68,10 @@ ]]> </mx:Script> + <mx:RemoteObject id="communicationService" destination="communicationService" fault="faultHandler(event)"> + <mx:method name="sendCommunication" result="resultHandler(event)"/> + </mx:RemoteObject> + <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> <mx:HBox> <mx:TextInput id="txtMessage" width="500"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-12-01 17:03:38
|
I came in to work today at 10:00 am I will work on the communication component: adding the mxml for the service that it will use. On Sun, Nov 29, 2009 at 3:11 PM, Kalin Jonas <kj...@as...> wrote: > Checking out at 3:00pm > I have completed the Communication interface as listed below. > It needs to have a service to connect to the server, and code needs to be > written to push the communication objects to all clients connected, but the > interface is done. > > > On Sun, Nov 29, 2009 at 12:18 PM, Kalin Jonas <kj...@as...> wrote: > >> Checking in from home today at 12:00 noon >> I will be working on a communications interface with the following design: >> >> - Large Box for messages received/sent >> - Small Box for typing a message >> - Button for sending a message (Enter key should also send) >> >> I am going to try to give it the following functionality: >> >> - Client concatenates user number & sends a message to server when >> Enter/Button pressed (Server should assign timestamp and push the message to >> all clients) >> - Client receives a message from the server (does not matter who it is >> from) and puts it in the Large Box. >> >> > |
From: <kj...@us...> - 2009-12-01 08:54:52
|
Revision: 382 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=382&view=rev Author: kjonas Date: 2009-12-01 08:54:41 +0000 (Tue, 01 Dec 2009) Log Message: ----------- I have made the two buttons invisible, and made the messages automatically scroll to the bottom. All that remains to be done is integrating a service: - There is a comment that indicates where the server request will go. - The method commReceived() needs to be called by the messageReceived() method or something. Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/Communication.mxml Modified: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-11-30 19:59:21 UTC (rev 381) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-01 08:54:41 UTC (rev 382) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSelfComm}"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSend}"> <mx:Script> <![CDATA[ @@ -27,6 +27,7 @@ { if(comm.message == null || comm.message.length == 0) return; vbxMessages.addChild(commToText(comm)); + vbxMessages.verticalScrollPosition = vbxMessages.maxVerticalScrollPosition; } private function strToText(str:String):Text @@ -45,11 +46,11 @@ ]]> </mx:Script> - <mx:VBox id="vbxMessages" width="500" height="300"/> + <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> <mx:HBox> - <mx:TextInput id="txtMessage" width="400"/> - <mx:Button id="btnSend" label="Send" click="btnSend_click()"/> - <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()"/> + <mx:TextInput id="txtMessage" width="500"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> + <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> </mx:HBox> </mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-30 19:59:31
|
Revision: 381 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=381&view=rev Author: alllee Date: 2009-11-30 19:59:21 +0000 (Mon, 30 Nov 2009) Log Message: ----------- fixing snapshots repo Modified Paths: -------------- irrigation/trunk/ivysettings.xml Modified: irrigation/trunk/ivysettings.xml =================================================================== --- irrigation/trunk/ivysettings.xml 2009-11-30 19:58:26 UTC (rev 380) +++ irrigation/trunk/ivysettings.xml 2009-11-30 19:59:21 UTC (rev 381) @@ -4,17 +4,16 @@ --> <ivysettings> <settings defaultResolver="chain-resolver" /> - <property name='local-m2-pattern' - value='${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]'/> + <property name='local-m2-pattern' value='${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]'/> <resolvers> <chain name='chain-resolver' returnFirst='true'> <filesystem name='m2' m2compatible='true'> <ivy pattern='${local-m2-pattern}.pom' /> <artifact pattern='${local-m2-pattern}.[ext]'/> </filesystem> - <ibiblio name='commons-archiva' m2compatible='true' root='http://dev.commons.asu.edu/archiva/repository/snapshots'/> - <ibiblio name='commons-archiva' 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'/> + <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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-30 19:58:38
|
Revision: 380 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=380&view=rev Author: alllee Date: 2009-11-30 19:58:26 +0000 (Mon, 30 Nov 2009) Log Message: ----------- fixed SocketIdentifier compareTo method so it should now get properly stored in SortedMap and other Sorted Collections that rely on compareTo. Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2009-11-29 22:06:34 UTC (rev 379) +++ csidex/trunk/pom.xml 2009-11-30 19:58:26 UTC (rev 380) @@ -52,7 +52,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.3</version> + <version>1.3.1</version> </dependency> <dependency> <groupId>xpp3</groupId> Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2009-11-29 22:06:34 UTC (rev 379) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2009-11-30 19:58:26 UTC (rev 380) @@ -52,13 +52,13 @@ // FIXME: set up some kind of application logging for the server side classes. private final static Logger logger = Logger.getLogger(Persister.class.getName()); - private final Logger chatLogger = Logger.getLogger("chat-logger"); + private final Logger chatLogger = Logger.getLogger("chat.logger"); private FileHandler chatLogFileHandler; private R roundConfiguration; - private final SortedSet<PersistableEvent> actions; - private final SortedSet<ChatRequest> chatRequests; + private final SortedSet<PersistableEvent> actions = new TreeSet<PersistableEvent>(); + private final SortedSet<ChatRequest> chatRequests = new TreeSet<ChatRequest>(); private String experimentSaveDirectory; private String persistenceDirectory; private EventChannel channel; @@ -73,8 +73,6 @@ public Persister(T experimentConfiguration) { this.persistenceDirectory = experimentConfiguration.getPersistenceDirectory(); - this.actions = new TreeSet<PersistableEvent>(); - this.chatRequests = new TreeSet<ChatRequest>(); // initialize persister with first round parameters SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ROUND_SAVE_DIRECTORY_FORMAT); this.experimentSaveDirectory = simpleDateFormat.format(new Date()); @@ -121,7 +119,7 @@ } catch (IOException unrecoverable) { unrecoverable.printStackTrace(); - logger.severe("Unable to initialize chat log: " + chatLogPath + " - aborting."); + logger.severe("Unable to initialize chat log: " + chatLogPath); } } } @@ -366,7 +364,6 @@ private <E extends DataModel<R>> void saveRound(E serverDataModel, String persistenceDirectory) throws IOException { String saveDestination = getSavePath(persistenceDirectory); - logger.info("saving to " + saveDestination); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(getRoundSaveFilePath(saveDestination, roundConfiguration.getRoundNumber()))); @@ -392,6 +389,9 @@ synchronized (actions) { oos.writeObject(actions); } + synchronized (chatRequests) { + oos.writeObject(chatRequests); + } oos.flush(); } } Modified: csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2009-11-29 22:06:34 UTC (rev 379) +++ csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2009-11-30 19:58:26 UTC (rev 380) @@ -7,8 +7,10 @@ /** * $Id$ * - * Uniquely identifies a socket connection and provides translation methods to convert the COOR - * lab's IP addresses into computer station numbers. + * Uniquely identifies a socket connection and provides translation methods to convert + * IP addresses of a certain format to "station numbers". Mostly used for our experimental + * lab at the COOR building which has IP hostnames of the format "xxx.xxx.xxx.14", where 14 is + * the appropriate station number. * * @author <a href='All...@as...'>Allen Lee</a> * @version $Revision$ @@ -23,6 +25,7 @@ private Integer stationNumber; private static volatile int ordinal = 0; + private final int id = ordinal++; private static final long serialVersionUID = 2371746759512286392L; @@ -104,30 +107,27 @@ */ public String toString() { -// return String.format("[local: %s] -> [remote: %s]", -// localSocketAddress, remoteSocketAddress); int stationNumber = getStationNumber(); - return (stationed) ? "Station " + stationNumber : remoteSocketAddress.toString(); + return (stationed) ? String.format("Station %d:%d", stationNumber, id) : remoteSocketAddress.toString(); } - - public String view() { - return remoteSocketAddress.toString(); - } - public int index() { - return getStationNumber(); - } - + /** + * FIXME: this method only works for hostnames whose last two characters are + * numbers. Furthermore, for clients originating from the same machine (or behind NAT) it + * will return the same client station number. + * @return + */ public int getStationNumber() { if (stationNumber != null) { return stationNumber.intValue(); } StringTokenizer tokenizer = new StringTokenizer(remoteSocketAddress.toString(), "."); String hostname = tokenizer.nextToken(); + int startIndex = hostname.length() - 2; String station = hostname.substring(startIndex, startIndex+2); try { - stationNumber = Integer.valueOf(station); + stationNumber = Math.abs(Integer.valueOf(station)); stationed = true; return stationNumber; } @@ -138,6 +138,16 @@ } public int compareTo(SocketIdentifier socketId) { - return getStationNumber() - socketId.getStationNumber(); + int comparison = 0; + if (stationed) { + comparison = stationNumber.compareTo(socketId.stationNumber); + } + if (comparison == 0) { + // ensure that these two are .equals. + if (! equals(socketId)) { + comparison = Integer.valueOf(id).compareTo(Integer.valueOf(socketId.id)); + } + } + return comparison; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-29 22:11:30
|
Checking out at 3:00pm I have completed the Communication interface as listed below. It needs to have a service to connect to the server, and code needs to be written to push the communication objects to all clients connected, but the interface is done. On Sun, Nov 29, 2009 at 12:18 PM, Kalin Jonas <kj...@as...> wrote: > Checking in from home today at 12:00 noon > I will be working on a communications interface with the following design: > > - Large Box for messages received/sent > - Small Box for typing a message > - Button for sending a message (Enter key should also send) > > I am going to try to give it the following functionality: > > - Client concatenates user number & sends a message to server when > Enter/Button pressed (Server should assign timestamp and push the message to > all clients) > - Client receives a message from the server (does not matter who it is > from) and puts it in the Large Box. > > |
From: <kj...@us...> - 2009-11-29 22:06:41
|
Revision: 379 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=379&view=rev Author: kjonas Date: 2009-11-29 22:06:34 +0000 (Sun, 29 Nov 2009) Log Message: ----------- Changed actionscript/Communication.as to use Date instead of Timestamp Added custom/Communication.mxml class which has basic methods needed for communication-interface. - Client will create an Communication.as object and send to server, expecting server to push same object to all clients exactly once. - Client can display Communication.as objects that it receives from server. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/Communication.as Added Paths: ----------- mentalmodels/trunk/flex/src/custom/Communication.mxml Modified: mentalmodels/trunk/flex/src/actionscript/Communication.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Communication.as 2009-11-29 19:23:30 UTC (rev 378) +++ mentalmodels/trunk/flex/src/actionscript/Communication.as 2009-11-29 22:06:34 UTC (rev 379) @@ -6,8 +6,8 @@ { public var id:Number; public var message:String; - public var timestamp:Timestamp; - public var student:Student; + public var date:Date; + public var student:actionscript.Student; public var round:Round; } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-11-29 22:06:34 UTC (rev 379) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSelfComm}"> + + <mx:Script> + <![CDATA[ + import actionscript.Communication; + import actionscript.Student; + import mx.controls.Label; + import mx.controls.Text; + + public function btnSend_click():void + { + //<service>.<method>(txtMessage.text); + } + public function btnSelfComm_click():void + { + var comm:actionscript.Communication = new actionscript.Communication(); + comm.message = txtMessage.text; + comm.date = new Date(); + comm.student = new actionscript.Student(); comm.student.id = 1; + txtMessage.text = ""; + + commReceived(comm); + } + + public function commReceived(comm:actionscript.Communication):void + { + if(comm.message == null || comm.message.length == 0) return; + vbxMessages.addChild(commToText(comm)); + } + + private function strToText(str:String):Text + { + var newText:Text = new Text(); + newText.text = str; + return newText; + } + private function commToText(comm:actionscript.Communication):Text + { + var newText:Text = new Text(); + newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; + return newText; + } + + ]]> + </mx:Script> + + <mx:VBox id="vbxMessages" width="500" height="300"/> + <mx:HBox> + <mx:TextInput id="txtMessage" width="400"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()"/> + <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()"/> + </mx:HBox> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-11-29 19:23:41
|
Revision: 378 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=378&view=rev Author: kjonas Date: 2009-11-29 19:23:30 +0000 (Sun, 29 Nov 2009) Log Message: ----------- updated swf files Modified Paths: -------------- mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.swf mentalmodels/trunk/src/main/webapp/test.swf Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/test.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-11-29 19:22:44
|
Revision: 377 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=377&view=rev Author: kjonas Date: 2009-11-29 19:22:34 +0000 (Sun, 29 Nov 2009) Log Message: ----------- fixed small typo Modified Paths: -------------- mentalmodels/trunk/flex/src/test.mxml Modified: mentalmodels/trunk/flex/src/test.mxml =================================================================== --- mentalmodels/trunk/flex/src/test.mxml 2009-11-29 18:51:32 UTC (rev 376) +++ mentalmodels/trunk/flex/src/test.mxml 2009-11-29 19:22:34 UTC (rev 377) @@ -5,7 +5,7 @@ <mx:TextInput id="gc" text="test3"/> <mx:ArrayCollection id="strat"> - <actionscript:StudentStrategy days="1" repeatedDecisions="true" location="{locs.getItemAt(0) as Location}"/> + <actionscript:StudentStrategy days="1" repeatedDecision="true" location="{locs.getItemAt(0) as Location}"/> </mx:ArrayCollection> <mx:ArrayCollection id="locs"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-29 19:18:22
|
Checking in from home today at 12:00 noon I will be working on a communications interface with the following design: - Large Box for messages received/sent - Small Box for typing a message - Button for sending a message (Enter key should also send) I am going to try to give it the following functionality: - Client concatenates user number & sends a message to server when Enter/Button pressed (Server should assign timestamp and push the message to all clients) - Client receives a message from the server (does not matter who it is from) and puts it in the Large Box. |
From: <kj...@us...> - 2009-11-29 18:51:41
|
Revision: 376 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=376&view=rev Author: kjonas Date: 2009-11-29 18:51:32 +0000 (Sun, 29 Nov 2009) Log Message: ----------- FisheryExperimentCore.mxml now accepts Game objects, rather than Block only. Other files changed to pass the game object along the hierarchy wherever needed. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-11-29 18:51:32 UTC (rev 376) @@ -20,6 +20,7 @@ { public var msg:String = ""; + public var gameObject:actionscript.Game = null; public var pages:ArrayCollection; public var minPagesRead:int; public var currentPageNumber:int; @@ -110,7 +111,7 @@ { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); sdq.locations = locations; - sdq.roundService.getCurrentRound(); + sdq.setRound(gameObject.currentRound); sdq.loadFromQuestion(Question(tempQuestion)); sdq.id = "q"+question; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -105,8 +105,9 @@ // // Important Variables // - public var currentModule:Module = null; - public var currentModuleNumber:int = 0; + public var gameObject:actionscript.Game = null; +// public var currentModule:Module = null; +// public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); @@ -134,6 +135,15 @@ { setBlock(event.message.body as actionscript.Block); } + else if(event.message.body is actionscript.Game) + { + gameObject = event.message.body as actionscript.Game; + setBlock(gameObject.currentBlock); + if(instructions != null) + { + instructions.setGameObject(this.gameObject); + } + } else if(event.message.body is ArrayCollection) { var students:ArrayCollection = new ArrayCollection(); Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import actionscript.Game; import custom.questions.strategyDesign.StrategyDesignQuestionC; import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; import actionscript.Location; @@ -14,6 +15,7 @@ import actionscript.PageDisplay; import mx.collections.ArrayCollection; + [Bindable] public var gameObject:actionscript.Game = null; [Bindable] public var moduleNumber:int = 1; [Bindable] public var module:Module; [Bindable] public var blockNumber:int = 0; @@ -36,6 +38,15 @@ return newLoc; } + public function setGameObject(newGameObject:actionscript.Game):void + { + this.gameObject = newGameObject; + if(pageDisplay != null) + { + pageDisplay.gameObject = this.gameObject; + } + } + // public function initModule(newModule:actionscript.Module):void // { // module = newModule; @@ -83,6 +94,7 @@ pageDisplay = new PageDisplay(makeBlock(),0,locations); // Alert.show(debug2.text); } + setGameObject(this.gameObject); currPage = pageDisplay.currentPageNumber; numPages = pageDisplay.pages.length; Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -37,7 +37,7 @@ var red:String = "#FF0000"; var white:String = "#FFFFFF"; - if(getGender().length != 1) // "M", "F", "Err" + if(getGender().length != 1) // possible genders are: "M", "F", "Err" { boxGender.setStyle(bgcolor, red); ready=false; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -33,8 +33,8 @@ <mx:Label text="days before starting the next repetition."/> </mx:HBox> - <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> - <mx:method name="getCurrentRound" result="roundResultHandler(event)"/> + <mx:RemoteObject id="GameService" destination="gameService" fault="faultHandler(event)"> + <mx:method name="getCurrentRoundNo" result="roundResultHandler(event)"/> </mx:RemoteObject> <mx:Script> @@ -63,9 +63,13 @@ public function roundResultHandler(event:ResultEvent):void { - repeated.round = notRepeated.round = event.result as Round; + setRound(event.result as Round); // Alert.show("Round received in StrategyDesign"); } + public function setRound(newRound:Round):void + { + repeated.round = notRepeated.round = newRound; + } public function faultHandler(event:FaultEvent):void { Alert.show("Error finding round for Strategy Design!"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-11-25 23:32:03
|
Revision: 375 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=375&view=rev Author: seematalele Date: 2009-11-25 23:31:53 +0000 (Wed, 25 Nov 2009) Log Message: ----------- create new entity DayGroupLocation.java, HibernateDayGroupLocationDao, then changed the applicationContext.xml and hibernate. Need to create Actionscript class in flex (Not needed though). Modified Paths: -------------- mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayGroupLocationDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayGroupLocation.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StrategyService.java Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-25 23:31:53 UTC (rev 375) @@ -389,39 +389,8 @@ -- Table structure for table `group_location` -- -DROP TABLE IF EXISTS `group_location`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `group_location` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `current_population` double DEFAULT NULL, - `fish_leaving` double DEFAULT NULL, - `fish_return` double DEFAULT NULL, - `initial_population` double NOT NULL, - `max_capacity` double NOT NULL, - `dayByDayDecsion_id` bigint(20) DEFAULT NULL, - `group_id` bigint(20) NOT NULL, - `location_id` bigint(20) NOT NULL, - PRIMARY KEY (`id`), - KEY `FKCFF7B975224FD013` (`location_id`), - KEY `FKCFF7B97565663181` (`group_id`), - KEY `FKCFF7B975A4684961` (`dayByDayDecsion_id`), - CONSTRAINT `FKCFF7B975A4684961` FOREIGN KEY (`dayByDayDecsion_id`) REFERENCES `day_by_day_decision` (`id`), - CONSTRAINT `FKCFF7B975224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`), - CONSTRAINT `FKCFF7B97565663181` FOREIGN KEY (`group_id`) REFERENCES `grp` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `group_location` --- - -LOCK TABLES `group_location` WRITE; -/*!40000 ALTER TABLE `group_location` DISABLE KEYS */; -/*!40000 ALTER TABLE `group_location` ENABLE KEYS */; -UNLOCK TABLES; - --- -- Table structure for table `grp` -- Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayGroupLocationDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayGroupLocationDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayGroupLocationDao.java 2009-11-25 23:31:53 UTC (rev 375) @@ -0,0 +1,13 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.DayGroupLocation; + +public class HibernateDayGroupLocationDao extends HibernateDao<DayGroupLocation>{ + + public HibernateDayGroupLocationDao() { + super(DayGroupLocation.class); + + } + + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayGroupLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayGroupLocation.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayGroupLocation.java 2009-11-25 23:31:53 UTC (rev 375) @@ -0,0 +1,87 @@ +package edu.asu.commons.mme.entity; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name="day_group_location") +public class DayGroupLocation implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1961926317422666537L; + @Id + @GeneratedValue + private Long id; + + @Column(name="current_population") + private Double currentPopulation; + + @Column(name="fish_leaving") + private Double fishLeaving; + + @Column(name="fish_return") + private Double fishReturned; + + private Integer dayNumber; + + @ManyToOne + @JoinColumn(nullable=true) + private GroupLocation groupLocation; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setCurrentPopulation(Double currentPopulation) { + this.currentPopulation = currentPopulation; + } + + public Double getCurrentPopulation() { + return currentPopulation; + } + + public void setFishLeaving(Double fishLeaving) { + this.fishLeaving = fishLeaving; + } + + public Double getFishLeaving() { + return fishLeaving; + } + + public void setFishReturned(Double fishReturned) { + this.fishReturned = fishReturned; + } + + public Double getFishReturned() { + return fishReturned; + } + + public void setGroupLocation(GroupLocation groupLocation) { + this.groupLocation = groupLocation; + } + + public GroupLocation getGroupLocation() { + return groupLocation; + } + + public void setDayNumber(Integer dayNumber) { + this.dayNumber = dayNumber; + } + + public Integer getDayNumber() { + return dayNumber; + } +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-25 23:31:53 UTC (rev 375) @@ -27,14 +27,14 @@ @JoinColumn(nullable=false) private Location location; - @Column(name="current_population") + /*@Column(name="current_population") private Double currentPopulation; @Column(name="fish_leaving") private Double fishLeaving; @Column(name="fish_return") - private Double fishReturned; + private Double fishReturned;*/ @ManyToOne @JoinColumn(nullable=false) @@ -46,11 +46,6 @@ @Column(nullable=false,name="initial_population") private Double initialPopulation; - @ManyToOne - @JoinColumn(nullable=true) - private DayByDayDecisions dayByDayDecsion; - - public void setId(Long id) { this.id = id; } @@ -59,7 +54,7 @@ return id; } - public void setCurrentPopulation(Double currentPopulation) { + /*public void setCurrentPopulation(Double currentPopulation) { this.currentPopulation = currentPopulation; } @@ -81,7 +76,7 @@ public Double getFishReturned() { return fishReturned; - } + }*/ public void setGroup(Group group) { this.group = group; @@ -115,12 +110,4 @@ return initialPopulation; } - public void setDayByDayDecsion(DayByDayDecisions dayByDayDecsion) { - this.dayByDayDecsion = dayByDayDecsion; - } - - public DayByDayDecisions getDayByDayDecsion() { - return dayByDayDecsion; - } - } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-11-25 23:31:53 UTC (rev 375) @@ -29,6 +29,8 @@ @Column(nullable=false,name="growth_rate") private Double growthRate; + + /*@Column(nullable=false,name="initial_population", scale=2) private Double initialPopulation; @@ -118,4 +120,6 @@ public Group getGroup() { return group; }*/ + + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-25 23:31:53 UTC (rev 375) @@ -37,7 +37,7 @@ Student student; public static final String getLastDay = "SELECT max(d.dayNumber) FROM DayByDayDecisions d " + - "where d.student=:student"; + "where d.student=:student and d.studentStrategy != NULL"; /** * This method is for Psychometric, Categorical and text question types. @@ -82,9 +82,9 @@ Integer lastDayNo = 0; for(int i = 0; i < studentStrategies.size(); i++ ) { - clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); - if(clientStudentStrategy.getDays() != 0) - { + clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); + if(clientStudentStrategy.getDays() != 0) + { studentStrategy = new StudentStrategy(); studentStrategy.setLocation(clientStudentStrategy.getLocation()); studentStrategy.setAllocationSeqNo(clientStudentStrategy.getAllocationSeqNo()); @@ -95,12 +95,12 @@ studentStrategy.setThreshold(clientStudentStrategy.getThreshold()); studentStrategy.setRepeatedDecisionNo(clientStudentStrategy.getRepeatedDecisionNo()); getStudentStrategyDao().save(studentStrategy); - + Query getLastDayForStudent = getStudentStrategyDao().getCurrentSession().createQuery(getLastDay); getLastDayForStudent.setEntity("student", studentStrategy.getStudent()); Iterator<?> lastdayIterator = getLastDayForStudent.list().iterator(); getLogger().debug("Days are : " + studentStrategy.getDays()); - + while(lastdayIterator.hasNext()) { lastDayNo = (Integer) lastdayIterator.next(); @@ -109,7 +109,7 @@ { lastDayNo = 0; } - + } //get previous day number for(int dayNo = lastDayNo+1,counter=0; counter < studentStrategy.getDays(); dayNo++,counter++) @@ -124,6 +124,8 @@ } } } + + }catch(Exception e) { e.printStackTrace(); Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-25 23:31:53 UTC (rev 375) @@ -8,24 +8,26 @@ import org.hibernate.Query; import org.springframework.transaction.annotation.Transactional; - - import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; import edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao; +import edu.asu.commons.mme.dao.HibernateDayGroupLocationDao; import edu.asu.commons.mme.dao.HibernateGameDao; import edu.asu.commons.mme.dao.HibernateGroupDao; import edu.asu.commons.mme.dao.HibernateGroupLocationDao; import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.dao.HibernateStudentDao; import edu.asu.commons.mme.dao.HibernateStudentStrategyDao; +import edu.asu.commons.mme.dao.HibernateSuspendRepetitionDao; import edu.asu.commons.mme.entity.DayByDayDecisions; import edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions; +import edu.asu.commons.mme.entity.DayGroupLocation; import edu.asu.commons.mme.entity.Game; import edu.asu.commons.mme.entity.Group; import edu.asu.commons.mme.entity.GroupLocation; import edu.asu.commons.mme.entity.Location; import edu.asu.commons.mme.entity.Student; import edu.asu.commons.mme.entity.StudentStrategy; +import edu.asu.commons.mme.entity.SuspendRepetition; /*** 1) Harvesting - Find out the amount of fish per agent and calculate the current population after harvesting @@ -86,6 +88,8 @@ private HibernateGroupDao groupDao; private HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao; private HibernateStudentStrategyDao studentStrategyDao; + private HibernateDayGroupLocationDao dayGroupLocationDao; + private HibernateSuspendRepetitionDao suspendRepetitionDao; private double totalFishLeaving; @@ -97,9 +101,38 @@ " where s.game =:game and s=ss.student and " + " dbd.studentStrategy=ss and " + " ss.repeatedDecision=:repeated_decisions"; + static final String getPreviousEarningForLocation = "select dd.earnings from DayByDayDecisions dd " + + "where dd.id = ()"; + + static final String studentStrategiesForRepeatedDecision = "SELECT ss FROM StudentStrategy ss " + + "where ss.student=:student_id" + + " and ss.repeatedDecision=:repeated_decision " + + "order by ss.repeatedDecisionNo asc"; + static final String getDayGroupLocation = "Select dgl from DayGroupLocation dgl " + + "where dgl.dayNumber=:prevdayNo and " + + "dgl.groupLocation=:groupLocation"; + /*static final String checkSuspendCondition="select sr from SuspendRepetition sr where sr.student =:student and sr.threshold < " + + "(select dd.earnings from DayByDayDecisions dd where dd.id = " + + "(SELECT max(d.id) FROM DayByDayDecisions d inner join StudentStrategy ss " + + "where d.student=:student and ss.repeatedDecision=:repeated_decision" + + "and d.studentStrategy=ss and d.location=:location))";*/ - static final String checkSuspendCondition=""; + static final String getSuspendRepetition = "select sr from SuspendRepetition sr where sr.student =:student"; + static final String checkForRepeatedDecision = "select s from StudentStrategy s " + + "where s.id = " + + "(SELECT d.studentStrategy.id FROM DayByDayDecisions d " + + "where d.dayNumber=:dayNo and d.student=:student and d.studentStrategy.id IS NOT NULL)"; + + static final String getEarningForDay = "select dd.earnings from DayByDayDecisions dd where dd.studentStrategy=:studentStrategy and dd.dayNumber=:dayNo"; + + static final String getDaybyDayDecisionForSuspendCondition = "select dd from DayByDayDecisions dd " + + "where dd.studentStrategy =: studentStrategy and dd.dayNumber<:dayNo order by dd.dayNumber desc"; + + static final String dayBydayBetweenDays = "SELECT d FROM DayByDayDecisions d where d.student=:student and d.dayNumber dayNumber >=: dayNoLow and dayNumber <=: dayNoHigh "; + + static final String prevDayEarningForSameLocation = ""; + public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } @@ -177,74 +210,17 @@ query.setEntity("game", game); - Iterator studentDecisionsIterator = query.list().iterator(); + Iterator<?> studentDecisionsIterator = query.list().iterator(); try{ while(studentDecisionsIterator.hasNext()) { DayByDayDecisions decision = (DayByDayDecisions)studentDecisionsIterator.next(); studentDecisions.add(decision); - getLogger().info("student decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); + //getLogger().info("student decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); } - executeStrategy(studentDecisions, game, false); + executeDayByDayDecisions(studentDecisions, game); - //find out different groups in the game - /*Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); - - queryforGroups.setLong("current_game_id", game.getId()); - Iterator groups = queryforGroups.list().iterator(); - List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); - List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); - /** For every group find out the groupLocations objects. - * find out the student decisions for current group. - * Separate the students for each bay - * find out the population for every bay - */ - - /*getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); - while(groups.hasNext()) - { - Group currentGroup = (Group) groups.next(); - getLogger().debug("group id in executeStrategy is: " + currentGroup.getId()); - - groupLocations = groupLocationDao.findAllByProperty("group",currentGroup); - //getLogger().debug("grouplocation size is: " + groupLocations.size()); - - List<DayByDayDecisions> studentDecisionForCurrentGroup = new ArrayList<DayByDayDecisions>(); - for(DayByDayDecisions tempStudentDecision:studentDecisions) - { - if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) - { - //studentDecisionForCurrentGroup.add(tempStudentDecision); - if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) - { - bay1Students.add(tempStudentDecision); - } - else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) - { - bay2Students.add(tempStudentDecision); - } - else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) - { - bay3Students.add(tempStudentDecision); - } - else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) - { - harborStudents.add(tempStudentDecision); - } - - } - - } - calculateHarvest(bay1Students,"Bay1",currentGroup,game); - calculateHarvest(bay2Students,"Bay2",currentGroup,game); - calculateHarvest(bay3Students,"Bay3",currentGroup,game); - calculateNewPopulation(currentGroup); - }*/ - }catch(Exception e) { e.printStackTrace(); @@ -252,7 +228,7 @@ } //FIXME: max_fish_capacity is hard coded to 5 but actually this value should get from game object - public void calculateHarvest(List<DayByDayDecisions> bayStudents,String locationName, Group currentGroup, Game game) + public void calculateHarvest(List<DayByDayDecisions> bayStudents,String locationName, Group currentGroup, Game game, int currentDayNumber) { // TODO Auto-generated method stub double maxFishCapacity = 0.0; @@ -262,38 +238,56 @@ double fishLeaving = 0.0; Long groupId; DayByDayOtherStudentDecisions otherStudents; + DayGroupLocation dayGroupLocation = null; maxFishCapacity = game.getGameConfig().getMaxFishHarvest(); getLogger().debug("location name is : " +locationName + "bay student size is: " + bayStudents.size()); try { - Location location = locationDao.findByProperty("locationName",locationName); - Group group = groupDao.find(currentGroup.getId()); GroupLocation groupLocation = new GroupLocation(); Query query = groupLocationDao.getCurrentSession().createQuery(getgroupLocation); query.setEntity("location", location); query.setEntity("group", group); - Iterator i = query.list().iterator(); + Iterator<?> i = query.list().iterator(); while(i.hasNext()) { groupLocation = (GroupLocation)i.next(); - getLogger().debug("groupLocation id is: " + groupLocation.getId()); + // getLogger().debug("groupLocation id is: " + groupLocation.getId()); } //get current population - actualPopulation = groupLocation.getCurrentPopulation(); + if(currentDayNumber == 1) + { + actualPopulation = groupLocation.getInitialPopulation(); + dayGroupLocation = new DayGroupLocation(); + dayGroupLocation.setDayNumber(currentDayNumber); + } + else + { + Query getPopulationForPrevDay = dayGroupLocationDao.getCurrentSession().createQuery(getDayGroupLocation); + getPopulationForPrevDay.setInteger("prevdayNo", currentDayNumber-1); + getPopulationForPrevDay.setEntity("groupLocation", groupLocation); + Iterator<?> populationIterator = getPopulationForPrevDay.list().iterator(); + while(populationIterator.hasNext()) + { + dayGroupLocation = (DayGroupLocation)populationIterator.next(); + // getLogger().debug("groupLocation id is: " + groupLocation.getId()); + } + actualPopulation = dayGroupLocation.getCurrentPopulation(); + } + dayGroupLocation.setGroupLocation(groupLocation); //1)Harvesting //Find out the amount of fish per agent - amountPerAgent = maxFishCapacity * groupLocation.getCurrentPopulation() / groupLocation.getMaxCapacity(); + amountPerAgent = maxFishCapacity * actualPopulation / groupLocation.getMaxCapacity(); if((bayStudents.size() * amountPerAgent) > actualPopulation) { amountPerAgent = actualPopulation / bayStudents.size(); - getLogger().debug("In IF Loop assigning amount/agent: " + amountPerAgent); + //getLogger().debug("In IF Loop assigning amount/agent: " + amountPerAgent); } //FIXME: allocate this amountPerAgent to each student @@ -309,13 +303,13 @@ fishLeaving = actualPopulation * growth / groupLocation.getMaxCapacity(); getLogger().info("Fish leaving at " + locationName + " is: " + fishLeaving); - groupLocation.setFishLeaving(fishLeaving); + dayGroupLocation.setFishLeaving(fishLeaving); //4) Population after diffusion actualPopulation = actualPopulation + growth - fishLeaving; getLogger().info("Fish population at " + locationName + " after diffusion is: " + actualPopulation); - groupLocation.setCurrentPopulation(actualPopulation); - groupLocationDao.save(groupLocation); + dayGroupLocation.setCurrentPopulation(actualPopulation); + dayGroupLocationDao.save(dayGroupLocation); if(bayStudents.size()!= 0) { @@ -336,15 +330,15 @@ //List<Student> otherStudents = new ArrayList<Student>(); Long currentStudentId = dayByDayDecision.getStudent().getId(); - getLogger().debug("For student id is: " + currentStudentId); + //getLogger().debug("For student id is: " + currentStudentId); for(DayByDayDecisions students:tempStudentDecisions) { - getLogger().debug("temp student id is: " + students.getStudent().getId()); + // getLogger().debug("temp student id is: " + students.getStudent().getId()); if(students.getStudent().getId() != currentStudentId) { - getLogger().debug("other student id is: " + students.getStudent().getId()); + // getLogger().debug("other student id is: " + students.getStudent().getId()); otherStudents = new DayByDayOtherStudentDecisions(); otherStudents.setDayByDayDecision(dayByDayDecision); otherStudents.setOtherStudent(students.getStudent()); @@ -365,7 +359,7 @@ } - private void calculateNewPopulation(Group group) { + private void calculateNewPopulation(Group group,Integer currentDayNo) { double totalFishLeaving = 0; double totalLoss = 0.0; @@ -374,14 +368,22 @@ double maxFishCapacity = 5.0; double totalReceptivity = 0.0; double receptivity = 0.0; + DayGroupLocation dayGroupLocation = null; - getLogger().debug("group id in calculate total fish leaving is: " + group.getId()); + //getLogger().debug("group id in calculate total fish leaving is: " + group.getId()); List<GroupLocation> groupLocations = groupLocationDao.findAllByProperty("group",group); - getLogger().debug("grouplocation size is: " + groupLocations.size()); + //getLogger().debug("grouplocation size is: " + groupLocations.size()); for(GroupLocation groupLocation : groupLocations) { - totalFishLeaving = totalFishLeaving + groupLocation.getFishLeaving(); - + Query getdayGroupLocation = dayGroupLocationDao.getCurrentSession().createQuery(getDayGroupLocation); + getdayGroupLocation.setInteger("prevdayNo", currentDayNo); + getdayGroupLocation.setEntity("groupLocation", groupLocation); + Iterator<?> i = getdayGroupLocation.list().iterator(); + while(i.hasNext()) + { + dayGroupLocation = (DayGroupLocation)i.next(); + totalFishLeaving = totalFishLeaving + dayGroupLocation.getFishLeaving(); + } } getLogger().debug("total fish leaving is : " + totalFishLeaving); //setTotalFishLeaving(totalFishLeaving); @@ -407,11 +409,20 @@ { if(groupLocation.getLocation().getId()!=1) { - getLogger().debug(groupLocation.getLocation().getLocationName() + "current population : " + groupLocation.getCurrentPopulation()); - receptivity = 1 - (groupLocation.getCurrentPopulation() /groupLocation.getMaxCapacity()); - getLogger().info(groupLocation.getLocation().getLocationName() + " receptivity is: " + receptivity); - bayReceptivity.put(groupLocation.getLocation().getLocationName(), receptivity); - totalReceptivity = receptivity + totalReceptivity; + Query getdayGroupLocation = dayGroupLocationDao.getCurrentSession().createQuery(getDayGroupLocation); + getdayGroupLocation.setInteger("prevdayNo", currentDayNo); + getdayGroupLocation.setEntity("groupLocation", groupLocation); + Iterator<?> i = getdayGroupLocation.list().iterator(); + while(i.hasNext()) + { + dayGroupLocation = (DayGroupLocation)i.next(); + getLogger().debug(groupLocation.getLocation().getLocationName() + "current population : " + dayGroupLocation.getCurrentPopulation()); + receptivity = 1 - (dayGroupLocation.getCurrentPopulation() /groupLocation.getMaxCapacity()); + getLogger().info(groupLocation.getLocation().getLocationName() + " receptivity is: " + receptivity); + bayReceptivity.put(groupLocation.getLocation().getLocationName(), receptivity); + totalReceptivity = receptivity + totalReceptivity; + } + } } getLogger().info("Total receptivity is: " + totalReceptivity); @@ -428,20 +439,28 @@ { if(groupLocation.getLocation().getId()!=1) { - if(totalReceptivity == 0) + Query getdayGroupLocation = dayGroupLocationDao.getCurrentSession().createQuery(getDayGroupLocation); + getdayGroupLocation.setInteger("prevdayNo", currentDayNo); + getdayGroupLocation.setEntity("groupLocation", groupLocation); + Iterator<?> i = getdayGroupLocation.list().iterator(); + while(i.hasNext()) { - groupLocation.setFishReturned(0.0); + dayGroupLocation = (DayGroupLocation)i.next(); + if(totalReceptivity == 0) + { + dayGroupLocation.setFishReturned(0.0); + } + else + { + receptivity = bayReceptivity.get(groupLocation.getLocation().getLocationName()); + dayGroupLocation.setFishReturned(receptivity * totalReturn * receptivity / totalReceptivity); + getLogger().debug("Fish returned to " + groupLocation.getLocation().getLocationName() + "is " + dayGroupLocation.getFishReturned()); + dayGroupLocation.setCurrentPopulation(dayGroupLocation.getCurrentPopulation() + dayGroupLocation.getFishReturned()); + getLogger().debug("New population at " + groupLocation.getLocation().getLocationName() + " is: " + dayGroupLocation.getCurrentPopulation()); + } } - else - { - receptivity = bayReceptivity.get(groupLocation.getLocation().getLocationName()); - groupLocation.setFishReturned(receptivity * totalReturn * receptivity / totalReceptivity); - getLogger().debug("Fish returned to " + groupLocation.getLocation().getLocationName() + "is " + groupLocation.getFishReturned()); - groupLocation.setCurrentPopulation(groupLocation.getCurrentPopulation() + groupLocation.getFishReturned()); - getLogger().debug("New population at " + groupLocation.getLocation().getLocationName() + " is: " + groupLocation.getCurrentPopulation()); - } } - groupLocationDao.save(groupLocation); + dayGroupLocationDao.save(dayGroupLocation); } }catch(Exception e) @@ -450,7 +469,7 @@ } } - public void executeStrategy(Game game) + /*public void executeStrategy(Game game) { //get student Strategies List<DayByDayDecisions> studentDecisions = new ArrayList<DayByDayDecisions>(); @@ -463,16 +482,16 @@ studentStrategiesWithNonRepeatedDecisions.setEntity("game", game); studentStrategiesWithNonRepeatedDecisions.setBoolean("repeated_decisions", repeatedDecisions); - Iterator studentStrategyNonRepeatedIterator = studentStrategiesWithNonRepeatedDecisions.list().iterator(); + Iterator<?> studentStrategyNonRepeatedIterator = studentStrategiesWithNonRepeatedDecisions.list().iterator(); while(studentStrategyNonRepeatedIterator.hasNext()) { DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyNonRepeatedIterator.next(); studentDecisions.add(dayByDayDecision); } - executeStrategy(studentDecisions, game, repeatedDecisions); - + // executeStrategy(studentDecisions, game, repeatedDecisions); + //execute repeated decisions repeatedDecisions = true; Query studentStrategiesQueryWithRepeatedDecisions = getDao().getCurrentSession().createQuery(getStudentDayByDayDecisionsFromStrategy); @@ -480,14 +499,14 @@ studentStrategiesQueryWithRepeatedDecisions.setEntity("game", game); studentStrategiesQueryWithRepeatedDecisions.setBoolean("repeated_decisions",repeatedDecisions); - Iterator studentStrategyRepeatedIterator = studentStrategiesQueryWithRepeatedDecisions.list().iterator(); + Iterator<?> studentStrategyRepeatedIterator = studentStrategiesQueryWithRepeatedDecisions.list().iterator(); while(studentStrategyRepeatedIterator.hasNext()) { DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyRepeatedIterator.next(); studentDecisions.add(dayByDayDecision); } - executeStrategy(studentDecisions, game, repeatedDecisions); + executeStrategy(studentDecisions, game); }catch(Exception e) { @@ -497,27 +516,191 @@ } - public void executeStrategy(List<DayByDayDecisions> studentDecisions, Game game, boolean repeatedDecisions) + public void executeStrategy(List<DayByDayDecisions> studentDecisions, Game game) { - Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); - - queryforGroups.setLong("current_game_id", game.getId()); - Iterator groups = queryforGroups.list().iterator(); List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); - /** For every group find out the groupLocations objects. + + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + queryforGroups.setLong("current_game_id", game.getId()); + List<Group> groups = queryforGroups.list(); + + *//** For every group find out the groupLocations objects. * find out the student decisions for current group. * Separate the students for each bay * find out the population for every bay - */ + *//* + StudentStrategy studentStrategy; + Game currentGame = gameDao.find(game.getId()); + getLogger().debug("group size in game: " + groups.size()); + for(int currentDayNumber = 1; currentDayNumber <= currentGame.getGameConfig().getMaxDays(); currentDayNumber++ ) + { + for(Group currentGroup:groups) + { + //Group currentGroup = (Group) groups.next(); + getLogger().debug("group id in executeStrategy is: " + currentGroup.getId()); + groupLocations = groupLocationDao.findAllByProperty("group",currentGroup); + for(DayByDayDecisions tempStudentDecision:studentDecisions) + { + if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) + { + *//*** Check for the NON repeated decisions + * If they are not over execute those first + * the go for repeated decision + * + *//* + double bay1Earning = -1.0, bay2Earning = -1.0, bay3Earning = -1.0; + + getLogger().debug("student is : " + tempStudentDecision.getStudent().getId() + "day no: " + currentDayNumber ); + Query checkRepeatedDecision = getDao().getCurrentSession().createQuery(checkForRepeatedDecision); + checkRepeatedDecision.setEntity("student",tempStudentDecision.getStudent()); + checkRepeatedDecision.setInteger("dayNo",currentDayNumber); + + if(checkRepeatedDecision.list().size() == 1) + { + studentStrategy = (StudentStrategy)checkRepeatedDecision.list().get(0); + getLogger().debug("For student: " + tempStudentDecision.getStudent().getId() + "repeated decision is: " + studentStrategy.isRepeatedDecision()); + if(studentStrategy.isRepeatedDecision()) + { + if(studentStrategy.getRepeatedDecisionNo() == 1) //start of the repeated decision sequence again + { + //get all strategies for a student with repeated decision = true + + Query allStrategiesWithRepeatedDecision = studentStrategyDao.getCurrentSession().createQuery(studentStrategiesForRepeatedDecision); + allStrategiesWithRepeatedDecision.setEntity("student",tempStudentDecision.getStudent().getId()); + allStrategiesWithRepeatedDecision.setBoolean("repeated_decision", true); + //allStrategiesWithRepeatedDecision.setEntity("location_id", location.getId()); + + Iterator<?> repeatedDecisionIterator = allStrategiesWithRepeatedDecision.list().iterator(); + while(repeatedDecisionIterator.hasNext()) + { + StudentStrategy tempStudentStrategy = (StudentStrategy)repeatedDecisionIterator.next(); + getLogger().debug("Repeated Decision no is: " + tempStudentStrategy.getRepeatedDecisionNo()); + if(tempStudentStrategy != null) + { + Query queryDBD = getDao().getCurrentSession().createQuery(getDaybyDayDecisionForSuspendCondition); + queryDBD.setEntity("studentStrategy",tempStudentStrategy); + queryDBD.setInteger("dayNo",currentDayNumber); + DayByDayDecisions tempDBD = (DayByDayDecisions)queryDBD.list().get(0); + + if(tempDBD.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { + bay1Earning = tempDBD.getEarnings(); + //baycounter++; + } + + else if(tempDBD.getLocation().getLocationName().equalsIgnoreCase("Bay2")) + { + bay2Earning = tempDBD.getEarnings(); + //baycounter++; + } + + else if(tempDBD.getLocation().getLocationName().equalsIgnoreCase("Bay3")) + { + bay3Earning = tempDBD.getEarnings(); + //baycounter++; + } + } + } + SuspendRepetition suspendRepetition = null; + + Query suspendRepetitionQuery = suspendRepetitionDao.getCurrentSession().createQuery(getSuspendRepetition); + suspendRepetitionQuery.setEntity("student",tempStudentDecision.getStudent()); + if(suspendRepetitionQuery.list().size() == 1) + { + suspendRepetition = (SuspendRepetition) suspendRepetitionQuery.list().get(0); + } + + if( (bay1Earning < suspendRepetition.getThreshold()) && (bay2Earning < suspendRepetition.getThreshold()) && (bay3Earning < suspendRepetition.getThreshold()) ) + { + + //get all the day by day decisions for next day in harbor days and change the locations to harbor. + getLogger().debug("Suspend Repetition condition is succeeded for student" + tempStudentDecision.getStudent()); + Query DBDBetweenDays = getDao().getCurrentSession().createQuery(dayBydayBetweenDays); + DBDBetweenDays.setEntity("student", tempStudentDecision.getStudent()); + DBDBetweenDays.setInteger("dayNoLow", currentDayNumber); + DBDBetweenDays.setInteger("dayNoHigh", (suspendRepetition.getDaysInHarbor() + currentDayNumber) - 1); + + Iterator<?> dayByDayDecisions = DBDBetweenDays.list().iterator(); + while(dayByDayDecisions.hasNext()) + { + DayByDayDecisions tempDayByDayDecision = (DayByDayDecisions)dayByDayDecisions.next(); + tempDayByDayDecision.setLocation(locationDao.findByProperty("locationName", "Harbor")); + getDao().save(tempDayByDayDecision); + } + + } + + } + } + } + else + { + getLogger().error("Query "+ checkForRepeatedDecision + "is returning more than one parameter. Check the Query!"); + } + + //check for the threshold + + //if(tempStudentDecision.getLocation().getId() == ) + + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harborStudents.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { + bay1Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) + { + bay2Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) + { + bay3Students.add(tempStudentDecision); + } + } + } + + calculateHarvest(bay1Students,"Bay1",currentGroup,game,currentDayNumber); + calculateHarvest(bay2Students,"Bay2",currentGroup,game,currentDayNumber); + calculateHarvest(bay3Students,"Bay3",currentGroup,game,currentDayNumber); + calculateNewPopulation(currentGroup,currentDayNumber); + bay1Students.clear(); + bay2Students.clear(); + bay3Students.clear(); + harborStudents.clear(); + } + } + + } +*/ + public void executeDayByDayDecisions(List<DayByDayDecisions> studentDecisions, Game game) + { + + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + + queryforGroups.setLong("current_game_id", game.getId()); + Iterator<?> groups = queryforGroups.list().iterator(); + List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); + List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + /** For every group find out the groupLocations objects. + * find out the student decisions for current group. + * Separate the students for each bay + * find out the population for every bay + */ + getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); Game currentGame = gameDao.find(game.getId()); - for(int dayCounter = 0; dayCounter < currentGame.getGameConfig().getMaxDays(); dayCounter++ ) + for(int currentDayNumber = 1; currentDayNumber <= currentGame.getGameConfig().getMaxDays(); currentDayNumber++ ) { while(groups.hasNext()) { @@ -532,19 +715,8 @@ if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) { - /** - * Check suspend condition for repeated decisions before putting allocating a student to any location - * - */ - if(repeatedDecisions) + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) { - tempStudentDecision.getStudentStrategy().getThreshold(); - } - - - - if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) - { harborStudents.add(tempStudentDecision); } else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) @@ -560,19 +732,38 @@ bay3Students.add(tempStudentDecision); } } - } - - calculateHarvest(bay1Students,"Bay1",currentGroup,game); - calculateHarvest(bay2Students,"Bay2",currentGroup,game); - calculateHarvest(bay3Students,"Bay3",currentGroup,game); - calculateNewPopulation(currentGroup); - + calculateHarvest(bay1Students,"Bay1",currentGroup,game,currentDayNumber); + calculateHarvest(bay2Students,"Bay2",currentGroup,game,currentDayNumber); + calculateHarvest(bay3Students,"Bay3",currentGroup,game,currentDayNumber); + calculateNewPopulation(currentGroup,currentDayNumber); } } } + + public void setStudentStrategyDao(HibernateStudentStrategyDao studentStrategyDao) { this.studentStrategyDao = studentStrategyDao; } + + + public void setDayGroupLocationDao(HibernateDayGroupLocationDao dayGroupLocationDao) { + this.dayGroupLocationDao = dayGroupLocationDao; + } + + + public HibernateDayGroupLocationDao getDayGroupLocationDao() { + return dayGroupLocationDao; + } + + + public void setSuspendRepetitionDao(HibernateSuspendRepetitionDao suspendRepetitionDao) { + this.suspendRepetitionDao = suspendRepetitionDao; + } + + + public HibernateSuspendRepetitionDao getSuspendRepetitionDao() { + return suspendRepetitionDao; + } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-25 23:31:53 UTC (rev 375) @@ -149,7 +149,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - pushBlock(game); + //pushBlock(game); flag = true; } else @@ -377,10 +377,10 @@ initCapacity = maxCapacity/2; groupLocation.setInitialPopulation(initCapacity); - groupLocation.setCurrentPopulation(initCapacity); + //groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); - groupLocation.setFishLeaving(0.0); - groupLocation.setFishReturned(0.0); + //groupLocation.setFishLeaving(0.0); + //groupLocation.setFishReturned(0.0); } if(location.getLocationName().equalsIgnoreCase("bay2")) @@ -392,10 +392,10 @@ initCapacity = maxCapacity/2; groupLocation.setInitialPopulation(initCapacity); - groupLocation.setCurrentPopulation(initCapacity); + /* groupLocation.setCurrentPopulation(initCapacity); groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - +*/ getLogger().info("initiali population set is: " + initCapacity); } if(location.getLocationName().equalsIgnoreCase("bay3")) @@ -407,11 +407,12 @@ initCapacity = maxCapacity/2; groupLocation.setInitialPopulation(initCapacity); - groupLocation.setCurrentPopulation(initCapacity); + getLogger().info("initiali population set is: " + initCapacity); + /*groupLocation.setCurrentPopulation(initCapacity); groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - +*/ } if(location.getLocationName().equalsIgnoreCase("harbor")) { @@ -422,13 +423,13 @@ initCapacity = maxCapacity/2; groupLocation.setInitialPopulation(initCapacity); - groupLocation.setCurrentPopulation(initCapacity); +/* groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - +*/ } - groupLocation.setDayByDayDecsion(null); + //groupLocation.setDayByDayDecsion(null); groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StrategyService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StrategyService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StrategyService.java 2009-11-25 23:31:53 UTC (rev 375) @@ -0,0 +1,25 @@ +package edu.asu.commons.mme.service; + +import edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao; +import edu.asu.commons.mme.dao.HibernateGameDao; +import edu.asu.commons.mme.dao.HibernateGroupDao; +import edu.asu.commons.mme.dao.HibernateGroupLocationDao; +import edu.asu.commons.mme.dao.HibernateLocationDao; +import edu.asu.commons.mme.dao.HibernateStudentDao; +import edu.asu.commons.mme.dao.HibernateStudentStrategyDao; +import edu.asu.commons.mme.entity.StudentStrategy; + + + +public class StrategyService extends Service.Base<StudentStrategy, HibernateStudentStrategyDao> +{ + private HibernateGameDao gameDao; + private HibernateLocationDao locationDao; + private HibernateStudentDao studentDao; + private HibernateGroupLocationDao groupLocationDao; + private HibernateGroupDao groupDao; + private HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao; + + + +} Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-11-25 23:31:53 UTC (rev 375) @@ -122,6 +122,9 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='dayGroupLocationDao' class='edu.asu.commons.mme.dao.HibernateDayGroupLocationDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> <!-- spring managed service layer --> <bean id='gameService' class='edu.asu.commons.mme.service.GameService'> @@ -148,6 +151,9 @@ <property name='gameDao' ref='gameDao'/> <property name='groupLocationDao' ref='groupLocationDao'/> <property name='dayByDayOtherStudentDecisionsDao' ref='dayByDayOtherStudentDecisionsDao'/> + <property name='dayGroupLocationDao' ref='dayGroupLocationDao'/> + <property name='suspendRepetitionDao' ref='suspendRepetitionDao'/> + </bean> <bean id='answeringService' class='edu.asu.commons.mme.service.AnsweringService'> Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-11-20 20:38:48 UTC (rev 374) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-11-25 23:31:53 UTC (rev 375) @@ -41,7 +41,9 @@ <mapping class='edu.asu.commons.mme.entity.DayByDayDecisions'/> <mapping class='edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions'/> + <mapping class='edu.asu.commons.mme.entity.DayGroupLocation'/> + </session-factory> </hibernate-configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (JIRA) <jef...@as...> - 2009-11-21 19:33:26
|
[ http://opensource.asu.edu/jira/browse/COMMONS-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved COMMONS-5. ----------------------------- Resolution: Fixed Implemented in r374. > interface and instructions flow improvement > ------------------------------------------- > > Key: COMMONS-5 > URL: http://opensource.asu.edu/jira/browse/COMMONS-5 > Project: The Virtual Commons > Issue Type: Improvement > Components: irrigation > Affects Versions: irrigation.asu.fall.2009 > Reporter: Allen Lee > Assignee: Allen Lee > Fix For: irrigation.asu.fall.2009 > > > Updated flow: > 1. Brief introduction to the experiment > 2. Introduce chat > 3. Do basic chat, just say hi > 4. Introduce token investment screen > 5. Display static screenshot and introduce experiment > 6. Start practice round. > 7. Free text quiz (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. > 8. Next is the second practice round. > 9. Finally the start of the first round. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <al...@us...> - 2009-11-20 20:38:57
|
Revision: 374 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=374&view=rev Author: alllee Date: 2009-11-20 20:38:48 +0000 (Fri, 20 Nov 2009) Log Message: ----------- minor wording changes to infrastructure efficiency to water delivery capacity table. Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-20 18:21:53 UTC (rev 373) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-20 20:38:48 UTC (rev 374) @@ -327,8 +327,8 @@ </p> <table border="1" cellspacing="2" cellpadding="2"> <thead> -<th>Total Infrastructure Efficiency (percent)</th> -<th>Water delivery (cubic feet per second)</th> +<th>Irrigation Infrastructure Efficiency (percent)</th> +<th>Water delivery capacity (cubic feet per second)</th> </thead> <tr> <td> ≤ 45</td><td>0</td> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-11-20 18:21:53 UTC (rev 373) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-11-20 20:38:48 UTC (rev 374) @@ -327,8 +327,8 @@ </p> <table border="1" cellspacing="2" cellpadding="2"> <thead> -<th>Total Infrastructure Efficiency (percent)</th> -<th>Water delivery (cubic feet per second)</th> +<th>Irrigation Infrastructure Efficiency (percent)</th> +<th>Water delivery capacity (cubic feet per second)</th> </thead> <tr> <td> ≤ 45</td><td>0</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (JIRA) <jef...@as...> - 2009-11-20 19:23:25
|
inaccurate total earnings for other participants in debriefing -------------------------------------------------------------- Key: COMMONS-6 URL: http://opensource.asu.edu/jira/browse/COMMONS-6 Project: The Virtual Commons Issue Type: Bug Reporter: Allen Lee Assignee: Allen Lee The debriefing information isn't getting updated properly. Specifically, the total earnings isn't accurate for the other participants (but is accurate for the current participant). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <see...@us...> - 2009-11-20 18:22:01
|
Revision: 373 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=373&view=rev Author: seematalele Date: 2009-11-20 18:21:53 +0000 (Fri, 20 Nov 2009) Log Message: ----------- 1)Re factored code. Removed some unwanted java service files. Changed the applicationContext.xml also. 2)Changed the entities in Server side, so changed the actionscript class files too. 3)Written Strategy Execution algorithm for non repeated decisions and also for repeated decisions. But for Repeated decisions, checking of suspend condition needs to be done. 3)Testing (successfully) - Non repeated decisions. Repeated conditions WITHOUT suspend condition. Game object is sent to the client (instead of pushing block, pushing the game state). DayByDayDecisions 4)Next Tasks - Execute repeated decisions with suspend condition. Test DayByDayDecisions and StrategyExecution with client GUI. Create communication Component and configure and write code for chatting also. Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as mentalmodels/trunk/flex/src/actionscript/Round.as mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java Removed Paths: ------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2009-11-20 18:21:53 UTC (rev 373) @@ -161,7 +161,7 @@ private function messageHandler(event:MessageEvent):void { //Alert.show("message from server came.."); - if(event.message.body as actionscript.Block) + /* if(event.message.body as actionscript.Block) { var block:actionscript.Block = event.message.body as actionscript.Block; //Alert.show("String came from server is: " + block.id + " " + block.description); @@ -176,8 +176,31 @@ else if(event.message.body as ArrayCollection) { Alert.show("something else "); + } */ + if(event.message.body as actionscript.Game) + { + var game:actionscript.Game = event.message.body as actionscript.Game; + //Alert.show("String came from server is: " + block.id + " " + block.description); + + if(game == null) + { + Alert.show("Game is over!!"); + } + else + Alert.show("Block from server is : " + game.currentBlock.description); } + else if(event.message.body as ArrayCollection) + { + Alert.show("something else "); + } + else if(event.message.body as int) + { + Alert.show((event.message.body as int).toString()); + } + + + } ]]> Modified: mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as 2009-11-20 18:21:53 UTC (rev 373) @@ -12,6 +12,6 @@ public var earnings:Number; public var money:Number; public var student:actionscript.Student; - public var otherStudents:ArrayCollection; + public var studentStrategy:StudentStrategy; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Round.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Round.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/Round.as 2009-11-20 18:21:53 UTC (rev 373) @@ -8,9 +8,6 @@ public class Round { public var id:Number; - public var roundNo:int; - public var game:Game; public var communicationFlag:Boolean; - public var roundLocations:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-11-20 18:21:53 UTC (rev 373) @@ -13,7 +13,9 @@ public var days:int; public var threshold:Number; public var location:Location; - public var repeatedDecisions:Boolean; + public var repeatedDecision:Boolean; public var round:actionscript.Round; + public var dayBydayDecisions:ArrayCollection; + public var repeatedDecisionNo:int; } } Modified: mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as 2009-11-20 18:21:53 UTC (rev 373) @@ -6,9 +6,9 @@ public class SuspendRepetition { public var id:Number; - public var roundConfig:Round; - public var student:Student; + public var round:Round; + public var student:actionscript.Student; public var daysInHarbor:int; - public var fishingThreshold:Number; + public var threshold:Number; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-20 18:21:53 UTC (rev 373) @@ -136,7 +136,7 @@ tempObject.round = notRepeated.round; tempObject.allocationSeqNo = i; - tempObject.repeatedDecisions = false; + tempObject.repeatedDecision = false; array.addItem(tempObject); } @@ -150,7 +150,7 @@ tempObject.round = repeated.round; tempObject.allocationSeqNo = i+notRepeatedArray.length; - tempObject.repeatedDecisions = true; + tempObject.repeatedDecision = true; array.addItem(tempObject); } Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-20 18:21:53 UTC (rev 373) @@ -218,11 +218,14 @@ `earnings` double DEFAULT NULL, `location_id` bigint(20) NOT NULL, `student_id` bigint(20) NOT NULL, + `studentStrategy_id` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK5B92B164224FD013` (`location_id`), KEY `FK5B92B164992B5A41` (`student_id`), - CONSTRAINT `FK5B92B164992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FK5B92B164224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) + KEY `FK5B92B164A4A1AE81` (`studentStrategy_id`), + CONSTRAINT `FK5B92B164A4A1AE81` FOREIGN KEY (`studentStrategy_id`) REFERENCES `student_strategy` (`id`), + CONSTRAINT `FK5B92B164224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`), + CONSTRAINT `FK5B92B164992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -396,13 +399,16 @@ `fish_return` double DEFAULT NULL, `initial_population` double NOT NULL, `max_capacity` double NOT NULL, + `dayByDayDecsion_id` bigint(20) DEFAULT NULL, `group_id` bigint(20) NOT NULL, `location_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), KEY `FKCFF7B975224FD013` (`location_id`), KEY `FKCFF7B97565663181` (`group_id`), - CONSTRAINT `FKCFF7B97565663181` FOREIGN KEY (`group_id`) REFERENCES `grp` (`id`), - CONSTRAINT `FKCFF7B975224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) + KEY `FKCFF7B975A4684961` (`dayByDayDecsion_id`), + CONSTRAINT `FKCFF7B975A4684961` FOREIGN KEY (`dayByDayDecsion_id`) REFERENCES `day_by_day_decision` (`id`), + CONSTRAINT `FKCFF7B975224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`), + CONSTRAINT `FKCFF7B97565663181` FOREIGN KEY (`group_id`) REFERENCES `grp` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -813,7 +819,8 @@ `id` bigint(20) NOT NULL AUTO_INCREMENT, `allocation_sequence_no` int(11) NOT NULL, `days` int(11) NOT NULL, - `repeated_decisions` tinyint(1) NOT NULL, + `repeated_decision` tinyint(1) NOT NULL, + `repeated_decision_no` int(11) DEFAULT NULL, `threshold` double NOT NULL, `location_id` bigint(20) NOT NULL, `round_id` bigint(20) NOT NULL, @@ -847,14 +854,14 @@ CREATE TABLE `suspend_repetition` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `days_in_harbor` int(11) NOT NULL, - `fishing_threshold` float NOT NULL, - `roundConfig_id` bigint(20) NOT NULL, + `threshold` float NOT NULL, + `round_id` bigint(20) NOT NULL, `student_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), - KEY `FKFBDC454297B31F` (`roundConfig_id`), + KEY `FKFBDC45447CF2321` (`round_id`), KEY `FKFBDC454992B5A41` (`student_id`), CONSTRAINT `FKFBDC454992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FKFBDC454297B31F` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`) + CONSTRAINT `FKFBDC45447CF2321` FOREIGN KEY (`round_id`) REFERENCES `round_config` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -876,4 +883,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-11-12 22:20:40 +-- Dump completed on 2009-11-20 18:10:50 Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java 2009-11-20 18:21:53 UTC (rev 373) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.SuspendRepetition; + +public class HibernateSuspendRepetitionDao extends HibernateDao<SuspendRepetition> { + + public HibernateSuspendRepetitionDao() + { + super(SuspendRepetition.class); + } +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-20 18:21:53 UTC (rev 373) @@ -36,6 +36,9 @@ @Column private Double earnings; + @ManyToOne + @JoinColumn(nullable=true) + private StudentStrategy studentStrategy; /*@OneToMany(mappedBy = "dayByDayDecision") @CollectionOfElements(fetch = FetchType.EAGER) private List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions;*/ @@ -80,6 +83,14 @@ return earnings; } + public void setStudentStrategy(StudentStrategy studentStrategy) { + this.studentStrategy = studentStrategy; + } + + public StudentStrategy getStudentStrategy() { + return studentStrategy; + } + /*public void setDayByDayOtherStudentDecisions( List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions) { this.dayByDayOtherStudentDecisions = dayByDayOtherStudentDecisions; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-20 18:21:53 UTC (rev 373) @@ -46,6 +46,11 @@ @Column(nullable=false,name="initial_population") private Double initialPopulation; + @ManyToOne + @JoinColumn(nullable=true) + private DayByDayDecisions dayByDayDecsion; + + public void setId(Long id) { this.id = id; } @@ -110,4 +115,12 @@ return initialPopulation; } + public void setDayByDayDecsion(DayByDayDecisions dayByDayDecsion) { + this.dayByDayDecsion = dayByDayDecsion; + } + + public DayByDayDecisions getDayByDayDecsion() { + return dayByDayDecsion; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-20 18:21:53 UTC (rev 373) @@ -38,8 +38,6 @@ private String semester; - - @Column private Double money; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-11-20 18:21:53 UTC (rev 373) @@ -2,17 +2,21 @@ import java.io.Serializable; - +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; +import org.hibernate.annotations.CollectionOfElements; +import edu.asu.commons.mme.entity.DayByDayDecisions; + @Entity @Table(name="student_strategy") @@ -45,9 +49,20 @@ @JoinColumn(nullable=false) public Location location; - @Column (name="repeated_decisions",columnDefinition="Boolean", nullable=false) - public boolean repeatedDecisions; + @Column (name="repeated_decision",columnDefinition="Boolean", nullable=false) + public boolean repeatedDecision; + @Column (name="repeated_decision_no") + public Integer repeatedDecisionNo; + + public Integer getRepeatedDecisionNo() { + return repeatedDecisionNo; + } + + public void setRepeatedDecisionNo(Integer repeatedDecisionNo) { + this.repeatedDecisionNo = repeatedDecisionNo; + } + public void setId(Long id) { this.id = id; } @@ -80,12 +95,12 @@ return threshold; } - public void setRepeatedDecisions(boolean repeatedDecisions) { - this.repeatedDecisions = repeatedDecisions; + public void setRepeatedDecision(boolean repeatedDecision) { + this.repeatedDecision = repeatedDecision; } - public boolean isRepeatedDecisions() { - return repeatedDecisions; + public boolean isRepeatedDecision() { + return repeatedDecision; } public void setRound(Round round) { @@ -111,7 +126,13 @@ public Student getStudent() { return student; } - - - + + /*public void setDayBydayDecisions(List<DayByDayDecisions> dayBydayDecisions) { + this.dayBydayDecisions = dayBydayDecisions; + } + + public List<DayByDayDecisions> getDayBydayDecisions() { + return dayBydayDecisions; + }*/ + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java 2009-11-20 18:21:53 UTC (rev 373) @@ -33,8 +33,8 @@ @Column(name="days_in_harbor",nullable=false) private Integer daysInHarbor; - @Column(name="fishing_threshold",nullable=false) - private Float fishingThreshold; + @Column(name="threshold",nullable=false) + private Float threshold; public void setId(Long id) { this.id = id; @@ -52,28 +52,28 @@ return daysInHarbor; } - public void setFishingThreshold(Float fishingThreshold) { - this.fishingThreshold = fishingThreshold; + public void setStudent(Student student) { + this.student = student; } - public Float getFishingThreshold() { - return fishingThreshold; + public Student getStudent() { + return student; } - public void setRoundConfig(Round roundconfig) { - this.round = roundconfig; + public void setThreshold(Float threshold) { + this.threshold = threshold; } - public Round getRoundConfig() { - return round; + public Float getThreshold() { + return threshold; } - public void setStudent(Student student) { - this.student = student; + public void setRound(Round round) { + this.round = round; } - public Student getStudent() { - return student; + public Round getRound() { + return round; } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,32 +1,44 @@ package edu.asu.commons.mme.service; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; + + +import org.hibernate.Query; + import org.springframework.transaction.annotation.Transactional; import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; import edu.asu.commons.mme.dao.HibernateStudentResponseDao; import edu.asu.commons.mme.dao.HibernateStudentStrategyDao; +import edu.asu.commons.mme.dao.HibernateSuspendRepetitionDao; import edu.asu.commons.mme.entity.DayByDayDecisions; import edu.asu.commons.mme.entity.Student; import edu.asu.commons.mme.entity.StudentResponse; import edu.asu.commons.mme.entity.StudentStrategy; +import edu.asu.commons.mme.entity.SuspendRepetition; @Transactional public class AnsweringService extends Service.Base<StudentResponse, HibernateStudentResponseDao> { - - + + //private HibernateStudentDao studentDao; private HibernateStudentStrategyDao studentStrategyDao; //private HibernateDayByDayDecisionsDao dayByDayDecisionsDao; -// private DayByDayDecisionsService dayByDayDecisionsService; + // private DayByDayDecisionsService dayByDayDecisionsService; private ModuleService moduleService; private HibernateDayByDayDecisionsDao dayByDayDecisionsDao; - + private HibernateSuspendRepetitionDao suspendRepetitionDao; + StudentResponse studentResponse; StudentStrategy studentStrategy; Student student; - + + public static final String getLastDay = "SELECT max(d.dayNumber) FROM DayByDayDecisions d " + + "where d.student=:student"; + /** * This method is for Psychometric, Categorical and text question types. * @param studentResponses @@ -34,48 +46,91 @@ public void saveQuestion(List<StudentResponse> studentResponses) { StudentResponse clientStudentResponse = new StudentResponse(); - for(int i = 0; i < studentResponses.size(); i++ ) - { - clientStudentResponse = (StudentResponse) studentResponses.get(i); - getLogger().debug("Question is: " + clientStudentResponse.getQuestion()); - getLogger().debug("Response is: " + clientStudentResponse.getResponse()); - getLogger().debug("Student is: " + clientStudentResponse.getStudent()); - studentResponse = new StudentResponse(); - studentResponse.setQuestion(clientStudentResponse.getQuestion()); - studentResponse.setResponse(clientStudentResponse.getResponse()); - studentResponse.setStudent(clientStudentResponse.getStudent()); + for(int i = 0; i < studentResponses.size(); i++ ) + { + clientStudentResponse = (StudentResponse) studentResponses.get(i); + getLogger().debug("Question is: " + clientStudentResponse.getQuestion()); + getLogger().debug("Response is: " + clientStudentResponse.getResponse()); + getLogger().debug("Student is: " + clientStudentResponse.getStudent()); + studentResponse = new StudentResponse(); + studentResponse.setQuestion(clientStudentResponse.getQuestion()); + studentResponse.setResponse(clientStudentResponse.getResponse()); + studentResponse.setStudent(clientStudentResponse.getStudent()); - getDao().save(studentResponse); - } - + getDao().save(studentResponse); + } + } - + /** * this method is for saving strategies of students. * @param studentStrategies */ - + public void saveSuspendRepetition(SuspendRepetition suspendRepetition) + { + SuspendRepetition suspendDecision = new SuspendRepetition(); + suspendDecision.setDaysInHarbor(suspendRepetition.getDaysInHarbor()); + suspendDecision.setThreshold(suspendRepetition.getThreshold()); + suspendDecision.setStudent(suspendRepetition.getStudent()); + suspendDecision.setRound(suspendRepetition.getRound()); + suspendRepetitionDao.save(suspendDecision); + } public void saveStrategy(List<StudentStrategy> studentStrategies) { - StudentStrategy clientStudentStrategy = new StudentStrategy(); - for(int i = 0; i < studentStrategies.size(); i++ ) - { - clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); - studentStrategy = new StudentStrategy(); - studentStrategy.setLocation(clientStudentStrategy.getLocation()); - studentStrategy.setAllocationSeqNo(clientStudentStrategy.getAllocationSeqNo()); - studentStrategy.setDays(clientStudentStrategy.getDays()); - studentStrategy.setRepeatedDecisions(clientStudentStrategy.isRepeatedDecisions()); - studentStrategy.setRound(clientStudentStrategy.getRound()); - studentStrategy.setStudent(clientStudentStrategy.getStudent()); - studentStrategy.setThreshold(clientStudentStrategy.getThreshold()); - getStudentStrategyDao().save(studentStrategy); - } + try{ + StudentStrategy clientStudentStrategy = null; + Integer lastDayNo = 0; + for(int i = 0; i < studentStrategies.size(); i++ ) + { + clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); + if(clientStudentStrategy.getDays() != 0) + { + studentStrategy = new StudentStrategy(); + studentStrategy.setLocation(clientStudentStrategy.getLocation()); + studentStrategy.setAllocationSeqNo(clientStudentStrategy.getAllocationSeqNo()); + studentStrategy.setDays(clientStudentStrategy.getDays()); + studentStrategy.setRepeatedDecision(clientStudentStrategy.isRepeatedDecision()); + studentStrategy.setRound(clientStudentStrategy.getRound()); + studentStrategy.setStudent(clientStudentStrategy.getStudent()); + studentStrategy.setThreshold(clientStudentStrategy.getThreshold()); + studentStrategy.setRepeatedDecisionNo(clientStudentStrategy.getRepeatedDecisionNo()); + getStudentStrategyDao().save(studentStrategy); + + Query getLastDayForStudent = getStudentStrategyDao().getCurrentSession().createQuery(getLastDay); + getLastDayForStudent.setEntity("student", studentStrategy.getStudent()); + Iterator<?> lastdayIterator = getLastDayForStudent.list().iterator(); + getLogger().debug("Days are : " + studentStrategy.getDays()); + + while(lastdayIterator.hasNext()) + { + lastDayNo = (Integer) lastdayIterator.next(); + getLogger().debug("Last day Number is : " + lastDayNo); + if(lastDayNo == null) + { + lastDayNo = 0; + } + + } + //get previous day number + for(int dayNo = lastDayNo+1,counter=0; counter < studentStrategy.getDays(); dayNo++,counter++) + { + DayByDayDecisions decision = new DayByDayDecisions(); + decision.setLocation(studentStrategy.getLocation()); + decision.setStudent(studentStrategy.getStudent()); + decision.setDayNumber(dayNo); + decision.setStudentStrategy(studentStrategy); + dayByDayDecisionsDao.save(decision); + getLogger().debug("Student is : " + studentStrategy.getStudent().getId()); + } + } + } + }catch(Exception e) + { + e.printStackTrace(); + } } - - - - + + /*public void setDayByDayDecisionsDao(HibernateDayByDayDecisionsDao dayByDayDecisionsDao) { this.dayByDayDecisionsDao = dayByDayDecisionsDao; }*/ @@ -112,4 +167,12 @@ return dayByDayDecisionsDao; } + public void setSuspendRepetitionDao(HibernateSuspendRepetitionDao suspendRepetitionDao) { + this.suspendRepetitionDao = suspendRepetitionDao; + } + + public HibernateSuspendRepetitionDao getSuspendRepetitionDao() { + return suspendRepetitionDao; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -9,6 +9,7 @@ import org.hibernate.Query; import org.springframework.transaction.annotation.Transactional; + import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; import edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao; import edu.asu.commons.mme.dao.HibernateGameDao; @@ -91,12 +92,19 @@ static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; static final String getgroupLocation = "SELECT g FROM GroupLocation g where g.group =:group and g.location =:location"; - static final String getStudentStrategy = "SELECT ss FROM StudentStrategy ss,Student s where s.game =: game and s=d.student"; + //static final String getStudentStrategy = "SELECT ss FROM StudentStrategy ss,Student s where s.game =: game and s=d.student and ss.repeatedDecisions =: repeated_decisions"; + static final String getStudentDayByDayDecisionsFromStrategy = "SELECT dbd FROM DayByDayDecisions dbd,StudentStrategy ss,Student s " + + " where s.game =:game and s=ss.student and " + + " dbd.studentStrategy=ss and " + + " ss.repeatedDecision=:repeated_decisions"; + + static final String checkSuspendCondition=""; public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } + public void setLocationDao(HibernateLocationDao locationDao) { this.locationDao = locationDao; } @@ -178,9 +186,10 @@ studentDecisions.add(decision); getLogger().info("student decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); } + executeStrategy(studentDecisions, game, false); //find out different groups in the game - Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + /*Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); queryforGroups.setLong("current_game_id", game.getId()); Iterator groups = queryforGroups.list().iterator(); @@ -195,7 +204,7 @@ * find out the population for every bay */ - getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + /*getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); while(groups.hasNext()) { Group currentGroup = (Group) groups.next(); @@ -234,14 +243,12 @@ calculateHarvest(bay2Students,"Bay2",currentGroup,game); calculateHarvest(bay3Students,"Bay3",currentGroup,game); calculateNewPopulation(currentGroup); - } + }*/ }catch(Exception e) { e.printStackTrace(); } - - } //FIXME: max_fish_capacity is hard coded to 5 but actually this value should get from game object @@ -441,43 +448,77 @@ { e.printStackTrace(); } - } - /*public void executeStrategy(Game game) + public void executeStrategy(Game game) { //get student Strategies - List<StudentStrategy> studentStrategies = new ArrayList<StudentStrategy>(); + List<DayByDayDecisions> studentDecisions = new ArrayList<DayByDayDecisions>(); + boolean repeatedDecisions = false; + //execute non repeated decisions first + try + { + Query studentStrategiesWithNonRepeatedDecisions = getDao().getCurrentSession().createQuery(getStudentDayByDayDecisionsFromStrategy); - Query studentStrategiesQuery = studentStrategyDao.getCurrentSession().createQuery(getStudentStrategy); + studentStrategiesWithNonRepeatedDecisions.setEntity("game", game); + studentStrategiesWithNonRepeatedDecisions.setBoolean("repeated_decisions", repeatedDecisions); - studentStrategiesQuery.setEntity("game", game); + Iterator studentStrategyNonRepeatedIterator = studentStrategiesWithNonRepeatedDecisions.list().iterator(); - Iterator studentStrategyIterator = studentStrategiesQuery.list().iterator(); - try - { - while(studentStrategyIterator.hasNext()) + while(studentStrategyNonRepeatedIterator.hasNext()) { - StudentStrategy strategy = (StudentStrategy)studentStrategyIterator.next(); - for(int i = 0; i < strategy.getDays();i++) - studentStrategies.add(strategy); + DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyNonRepeatedIterator.next(); + studentDecisions.add(dayByDayDecision); } - Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + executeStrategy(studentDecisions, game, repeatedDecisions); + - queryforGroups.setLong("current_game_id", game.getId()); - Iterator groups = queryforGroups.list().iterator(); - List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); - List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); - /** For every group find out the groupLocations objects. - * find out the student decisions for current group. - * Separate the students for each bay - * find out the population for every bay - */ + //execute repeated decisions + repeatedDecisions = true; + Query studentStrategiesQueryWithRepeatedDecisions = getDao().getCurrentSession().createQuery(getStudentDayByDayDecisionsFromStrategy); - /* getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + studentStrategiesQueryWithRepeatedDecisions.setEntity("game", game); + studentStrategiesQueryWithRepeatedDecisions.setBoolean("repeated_decisions",repeatedDecisions); + + Iterator studentStrategyRepeatedIterator = studentStrategiesQueryWithRepeatedDecisions.list().iterator(); + + while(studentStrategyRepeatedIterator.hasNext()) + { + DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyRepeatedIterator.next(); + studentDecisions.add(dayByDayDecision); + } + executeStrategy(studentDecisions, game, repeatedDecisions); + + }catch(Exception e) + { + e.printStackTrace(); + } + + } + + + public void executeStrategy(List<DayByDayDecisions> studentDecisions, Game game, boolean repeatedDecisions) + { + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + + queryforGroups.setLong("current_game_id", game.getId()); + Iterator groups = queryforGroups.list().iterator(); + List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); + List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + /** For every group find out the groupLocations objects. + * find out the student decisions for current group. + * Separate the students for each bay + * find out the population for every bay + */ + + getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + Game currentGame = gameDao.find(game.getId()); + + for(int dayCounter = 0; dayCounter < currentGame.getGameConfig().getMaxDays(); dayCounter++ ) + { while(groups.hasNext()) { Group currentGroup = (Group) groups.next(); @@ -488,12 +529,26 @@ //List<StudentDayByDayDecisions> studentDecisionForCurrentGroup = new ArrayList<DayByDayDecisions>(); for(DayByDayDecisions tempStudentDecision:studentDecisions) { - + if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) { - //studentDecisionForCurrentGroup.add(tempStudentDecision); - if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + /** + * Check suspend condition for repeated decisions before putting allocating a student to any location + * + */ + if(repeatedDecisions) { + tempStudentDecision.getStudentStrategy().getThreshold(); + } + + + + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harborStudents.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { bay1Students.add(tempStudentDecision); } else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) @@ -504,26 +559,19 @@ { bay3Students.add(tempStudentDecision); } - else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) - { - harborStudents.add(tempStudentDecision); - } - } } + calculateHarvest(bay1Students,"Bay1",currentGroup,game); calculateHarvest(bay2Students,"Bay2",currentGroup,game); calculateHarvest(bay3Students,"Bay3",currentGroup,game); calculateNewPopulation(currentGroup); + } - }catch(Exception e) - { - e.printStackTrace(); } + } - }*/ - public void setStudentStrategyDao(HibernateStudentStrategyDao studentStrategyDao) { this.studentStrategyDao = studentStrategyDao; } Deleted: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,62 +0,0 @@ -package edu.asu.commons.mme.service; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -public class Feed implements ApplicationContextAware{ - - public static void main(String args[]) { - Feed feed = new Feed(); - feed.start(); - } - - private StartGame thread; - private ApplicationContext ctx; - - public Feed() { - } - - public void start() { - - try{ - if (thread == null) { - thread = (StartGame)ctx.getBean("startGame"); - thread.run(); - } - }catch(Exception e) - { - System.out.println(e.getStackTrace()); - } - } - - public void stop() { - thread.setRunning(false); - thread = null; - } - - @Override - public void setApplicationContext(ApplicationContext context) - throws BeansException { - // TODO Auto-generated method stub - this.ctx = context; - - } - - /*@Override - public Object invoke(Message msg) { - // TODO Auto-generated method stub - if(msg.getBody().equals("New")){ - System.out.println("Adapter received new"); - return "This is a message from invoke method"; - }else{ - System.out.println("Adapter sending message"); - AsyncMessage newMessage = (AsyncMessage)msg; - MessageService msgService = (MessageService)getDestination().getService(); - msgService.pushMessageToClients(newMessage, true); - } - return null; - - }*/ - -} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -58,7 +58,6 @@ private int blockSeqNo; - private RoundService roundService; MessageHandler msgHandler; @@ -383,8 +382,6 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("bay2")) { @@ -400,8 +397,6 @@ groupLocation.setFishReturned(0.0); getLogger().info("initiali population set is: " + initCapacity); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("bay3")) { @@ -417,8 +412,6 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("harbor")) { @@ -434,9 +427,11 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } + groupLocation.setDayByDayDecsion(null); + groupLocationDao.save(groupLocation); + getLogger().info("group location is created and id is: " + groupLocation.getId()); + } } @@ -1183,15 +1178,6 @@ } - public void setRoundService(RoundService roundService) { - this.roundService = roundService; - } - - - public RoundService getRoundService() { - return roundService; - } - public void setGroupLocationDao(HibernateGroupLocationDao groupLocationDao) { this.groupLocationDao = groupLocationDao; } Deleted: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,828 +0,0 @@ -package edu.asu.commons.mme.service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.hibernate.Hibernate; -import org.springframework.transaction.annotation.Transactional; - -import edu.asu.commons.mme.dao.HibernateBlockDao; -import edu.asu.commons.mme.dao.HibernateGameConfigDao; -import edu.asu.commons.mme.dao.HibernateGameDao; -import edu.asu.commons.mme.dao.HibernateGameRoundDao; -import edu.asu.commons.mme.dao.HibernateModuleDao; -import edu.asu.commons.mme.dao.HibernateModuleRoundConfigDao; -import edu.asu.commons.mme.dao.HibernateRoundConfigDao; -import edu.asu.commons.mme.entity.Block; -import edu.asu.commons.mme.entity.BlockInformationWindow; -import edu.asu.commons.mme.entity.CategoricalOption; -import edu.asu.commons.mme.entity.CategoricalQuestion; -import edu.asu.commons.mme.entity.Game; -import edu.asu.commons.mme.entity.GameConfig; -import edu.asu.commons.mme.entity.GameRound; -import edu.asu.commons.mme.entity.Location; -import edu.asu.commons.mme.entity.Module; -import edu.asu.commons.mme.entity.ModuleRoundConfig; -import edu.asu.commons.mme.entity.Question; -import edu.asu.commons.mme.entity.QuestionGroup; -import edu.asu.commons.mme.entity.Round; -import edu.asu.commons.mme.utility.MessageHandler; - -@Transactional -public class RoundService extends Service.Base<Round, HibernateRoundConfigDao>{ - - private HibernateModuleDao moduleDao; - private HibernateBlockDao blockDao; - private HibernateGameDao gameDao; - private HibernateModuleRoundConfigDao moduleRoundDao; - private HibernateGameRoundDao gameRoundDao; - private HibernateGameConfigDao gameConfigDao; - - private LocationService locationService; - - private int blockSeqNo; - - private Game game; - - public Game getGame() { - return game; - } - - public void setGame(Game game) { - this.game = game; - } - - public RoundService() - { - setBlockSeqNo(0); - setGameFinished(false); - } - - public GameConfig createGameConfig(GameConfig gameConfig) - { - GameConfig newGameConfig = null; - try{ - newGameConfig = new GameConfig(); - newGameConfig.setImageLocation(null); - newGameConfig.setTimestamp(gameConfig.getTimestamp()); - newGameConfig.setMaxDays(gameConfig.getMaxDays()); - newGameConfig.setMaxFishHarvest(gameConfig.getMaxFishHarvest()); - newGameConfig.setNumberOfLocations(gameConfig.getNumberOfLocations()); - getGameConfigDao().save(newGameConfig); - initializeGameRounds(newGameConfig); - initializeLocations(newGameConfig); - - }catch(Exception e) - { - e.printStackTrace(); - } - return newGameConfig; - } - - - public Game createGame(Game game) - { - getLogger().debug("game came from flex is : " + game.getGameCode()); - - Game newGame = new Game(); - //currentGame = game; - try - { - newGame.setGameCode(game.getGameCode()); - newGame.setMoney(game.getMoney()); - newGame.setTimestamp(game.getTimestamp()); - - //FIXME: Currently using default GameConfiguration whose id is 1 - GameConfig gameConfig = gameConfigDao.find(1L); - newGame.setGameConfig(gameConfig); - getGameDao().save(newGame); - String str = newGame.getGameCode()+newGame.getId(); - - if(getGameDao().findAllByProperty("gameCode", str).size() != 0) - { - //getLogger().debug("in if loop "); - newGame = null; - } - else - { - newGame.setGameCode(str); - getGameDao().save(newGame); - getLogger().info("Created the game: " + newGame.getId()); - initializeLocations(gameConfig); - initializeGame(newGame); - } - }catch(Exception e) - { - e.printStackTrace(); - } - getLogger().debug("current game from flex is: " + newGame.getId()); - return newGame; - } - - private void initializeGameRounds(GameConfig gameConfig) { - // TODO Auto-generated method stub - List<GameRound> gameRounds = new ArrayList<GameRound>(); - for(Round round:getDao().findAll()) - { - GameRound gameRound = new GameRound(); - gameRound.setGameConfig(gameConfig); - gameRound.setRound(round); - gameRoundDao.save(gameRound); - gameRounds.add(gameRound); - } - getGameConfigDao().save(gameConfig); - } - - private void initializeLocations(GameConfig gameConfig) - { - //gameConfig.setLocations(locationService.setAllLocations(gameConfig)); - getGameConfigDao().save(gameConfig); - } - - public void initializeGame(Game game) { - // TODO Auto-generated method stub - try{ - Hibernate.initialize(game); - Hibernate.initialize(game.getCurrentBlock()); - - - GameConfig gameconfig = game.getGameConfig(); - Hibernate.initialize(gameconfig); - - /*for(Location location:gameconfig.getLocations()) - { - Hibernate.initialize(location); - - }*/ - - Round round = game.getCurrentRound(); - Hibernate.initialize(round); - /*for(GameRound gameRound:round.getGameRounds()) - { - getLogger().debug("gameround in initializing round is " + gameRound.getId()); - Hibernate.initialize(gameRound); - }*/ - - }catch(Exception e ) - { - e.printStackTrace(); - } - //Hibernate.initialize(gameconfig.getGameRounds()); - - - } - public Module getNextModule(int sequenceNo) - { - return getModule(sequenceNo); - } - - public void test() - { - getLogger().debug("test to check if module service is working...." ); - } - - /* - *1) Check if the current module round config is null, this object keeps track of which round - * and which module in that round is going on - *2) Find out the current module number - *3) check if it is finished, if yes find out the current round number - *4) Find out the current block number - *5) Return the next block - */ - - public Game getBlock(Game game) - { - - ModuleRoundConfig currentModuleRoundConfig; - Block currentBlock = null; - Round currentRound = null; - - //check if it is a start of the game - if(game.getCurrentRound() == null && game.getCurrentBlock() == null ) - { - getLogger().info("Current Round is null... "); - getLogger().info("Current block is null... "); - getLogger().info("Starting of the game...." + game.getGameCode()); - - currentRound = getNextRound(game); - getLogger().info("Next Round object is "+ currentRound.getId()); - - currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - currentBlock = getBlock(currentModule,1); - } - else - { - getLogger().debug("Current Round is : " + game.getCurrentRound().getId()); - getLogger().debug("Current block is : " + game.getCurrentBlock().getId()); - currentBlock = game.getCurrentBlock(); - currentRound = game.getCurrentRound(); - if(isModuleFinished(game.getCurrentBlock())) - { - getLogger().debug("current module is finished"); - - //currentModuleRoundConfig = game.getCurrentRound(). - if(isCurrentRoundFinished(game)) - { - getLogger().debug("current round is finished"); - if(isGameFinished(game)) - { - getLogger().debug("Game is finished..." + game.getId()); - return null; - } - else - { - //set the next round - currentRound = getNextRound(game); - getLogger().info("Next Round object is "+ currentRound.getId()); - - currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - - currentBlock = getBlock(currentModule,1); - } - } - else - { - getLogger().debug("current round is not finished"); - //currentRound = getNextRound(game.getCurrentRound()); - - currentModuleRoundConfig = getModuleRoundConfig(getPreviousModuleConfigSequenceNo(game), currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - - currentBlock = getBlock(currentModule,1); - - } - } - else - { - //get the next block in the module - //getLogger().debug("currentmodule is " + game.getCurrentBlock().getModule().getId()); - currentBlock = getNextBlock(game.getCurrentBlock()); - getLogger().debug("the next block for the game is: " + game.getCurrentBlock().getDescription()); - } - } - - Game newGame = saveGameState(currentBlock,currentRound,game); - getLogger().debug("question group sizes is : " + newGame.getCurrentBlock().getQuestionGroups().size()); - //initializeCurrentBlock(newGame.getCurrentBlock()); - initializeGame(newGame); - getLogger().debug("Module is " + newGame.getCurrentBlock().getModule().getId() + "Block sent to the server is: " + currentBlock.getDescription()); - return newGame; - } - - private int getPreviousModuleConfigSequenceNo(Game game) { - // TODO Auto-generated method stub - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - ModuleRoundConfig currentModuleRoundConfig = null; - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("module",game.getCurrentBlock().getModule()); - variables.put("round", game.getCurrentRound()); - moduleRoundConfigs = moduleRoundDao.findByEqCriteria(variables); - if(moduleRoundConfigs.size() == 1) - { - currentModuleRoundConfig = moduleRoundConfigs.get(0); - moduleRoundConfigs.clear(); - } - getLogger().debug("the prev Sequence no is : " + currentModuleRoundConfig.getSequenceNo()); - if(currentModuleRoundConfig != null) - return currentModuleRoundConfig.getSequenceNo(); - return 0; - } - - private ModuleRoundConfig getModuleRoundConfig(int prevSeqNo, Round currentRound) { - // TODO Auto-generated method stub - //int prevSeqNo = 0; - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - ModuleRoundConfig currentModuleRoundConfig = null; - try - { - moduleRoundConfigs = moduleRoundDao.findAllByProperty("round",currentRound); - for(int i = 0; i < moduleRoundConfigs.size(); i++) - { - if(moduleRoundConfigs.get(i).getSequenceNo() > prevSeqNo) - { - currentModuleRoundConfig = moduleRoundConfigs.get(i); - break; - - /*setCurrentModule(moduleRoundConfigs.get(i).getModule()); - getLogger().debug("current module is: " + getCurrentModule().getDescription()); - currentBlock = null; - break;*/ - } - } - }catch(Exception e) - { - e.printStackTrace(); - } - return currentModuleRoundConfig; - - } - - private Module getModuleForCurrentRound(ModuleRoundConfig moduleRoundConfig) { - // TODO Auto-generated method stub - //getLogger().debug("current module is: " + getCurrentModule().getDescription()); - return moduleRoundConfig.getModule(); - } - - - private Round getNextRound(Game game) { - // TODO Auto-generated method stub - - Round returnRound = null; - Round currentRound = game.getCurrentRound(); - GameConfig gameConfig = game.getGameConfig(); - List<GameRound> gameRounds = new ArrayList<GameRound>(); - if(currentRound == null) - { - //get the first round - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("seqNo", 1); - getGameRoundDao().findByEqCriteria(variables); - gameRounds = gameRoundDao.findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - returnRound = gameRounds.get(0).getRound(); - gameRounds.clear(); - } - } - else - { - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("round", currentRound); - gameRounds = getGameRoundDao().findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - int currentSeqNo = gameRounds.get(0).getSeqNo(); - gameRounds = getGameRoundDao().findAll(); - for(int i = 0; i < gameRounds.size(); i++) - { - if(currentSeqNo < gameRounds.get(i).getSeqNo()) - { - returnRound = gameRounds.get(i).getRound(); - break; - //getLogger().debug("currentround object is "+ rounds.get(i).getId()); - } - } - } - else - { - getLogger().error("Error Occured.. Game Config is associated with multiple Rounds "); - } - } - - return returnRound; - } - - public HibernateModuleDao getModuleDao() { - return moduleDao; - } - - - public void setModuleDao(HibernateModuleDao moduleDao) { - this.moduleDao = moduleDao; - } - - - @SuppressWarnings("unused") - private void initializeCurrentBlock(Block block) { - - Hibernate.initialize(block); - Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); - { - while(iteratorquestionGrp.hasNext()) - { - QuestionGroup questionGroup = iteratorquestionGrp.next(); - Hibernate.initialize(questionGroup); - // getLogger().debug(questionGroup.getDescription()); - List<Question> questions = questionGroup.getQuestions(); - - for(int j = 0; j < questions.size(); j++) - { - Hibernate.initialize(questions.get(j)); - if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) - { - CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); - Iterator<CategoricalOption> categoricalOption = categoricalQ.getCategoricalOptions().iterator(); - Hibernate.initialize(categoricalOption); - } - } - } - } - - Module module = block.getModule(); - Hibernate.initialize(module); - initializeModule(module); - - } - - - private Block getNextBlock(Block currentBlock) { - // TODO Auto-generated method stub - List<Block> blocks = new ArrayList<Block>(); - blocks = currentBlock.getModule().getBlocks(); - Block returnBlock = null; - for(int i = 0; i < blocks.size(); i++) - { - if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) - { - returnBlock = blocks.get(i); - break; - } - } - return returnBlock; - - } - - public Module getModule(int moduleNumber) - { - // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - - Module module = moduleDao.findByProperty("sequenceNo", moduleNumber); - Hibernate.initialize(module); - getLogger().debug("Module object is " + module.getDescription()); - initializeModule(module); - - return module; - } - - public Block getBlock(Module currentModule, int seqNo) - { - //Module module = new Module(); - // module = currentModule; - Block block = new Block(); - for(int i = 0; i < currentModule.getBlocks().size(); i++) - { - block = currentModule.getBlocks().get(i); - if(block.getSequenceNo() == seqNo) - { - return block; - } - } - - return block; - } - - /* private void setRound(int roundNo) { - // TODO Auto-generated method stub - currentRound = new Round(); - - currentRound = getDao().findByProperty("roundNo", roundNo); - //Hibernate.initialize(currentRound); - getLogger().debug("currentround object is "+ currentRound.getId()); - setCurrentRound(currentRound); - - }*/ - - /*private int getCurrentRoundNo() { - // TODO Auto-generated method stub - //FIXME: Game id 1 is hard coded but needs to make it dynamic - //Game game = gameDao.find(1L); - if(getCurrentGame().getCurrentRound() == null) - return 0; - else - return getCurrentGame().getCurrentRound().getRoundNo(); - - }*/ - public boolean isGameFinished(Game game) { - GameConfig gameConfig = game.getGameConfig(); - List<GameRound> gameRounds = getGameRoundDao().findAllByProperty("gameConfig",game.getGameConfig()); - boolean flag = false; - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("round", game.getCurrentRound()); - gameRounds = getGameRoundDao().findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - int currentSeqNo = gameRounds.get(0).getSeqNo(); - gameRounds.clear(); - gameRounds = getGameRoundDao().findAllByProperty("gameConfig", gameConfig); - - if(currentSeqNo == gameRounds.get(gameRounds.size() - 1).getSeqNo()) - { - flag = true; - } - else - { - for(GameRound gameRound:gameRounds) - { - if(currentSeqNo < gameRound.getSeqNo()) - { - flag = false; - } - } - - } - } - return flag; - } - - private boolean isCurrentRoundFinished(Game game) { - boolean flag = false; - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - Round currentRound = game.getCurrentRound(); - Module currentModule = game.getCurrentBlock().getModule(); - - ModuleRoundConfig currentModuleRoundConfig = new ModuleRoundConfig(); - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("module",currentModule); - variables.put("round", currentRound); - moduleRoundConfigs = moduleRoundDao.findByEqCriteria(variables); - if(moduleRoundConfigs.size() == 1) - { - currentModuleRoundConfig = moduleRoundConfigs.get(0); - moduleRoundConfigs.clear(); - } - moduleRoundConfigs = moduleRoundDao.findAllByProperty("round",currentRound); - getLogger().debug("the module round configs size is: " + moduleRoundConfigs.size()); - //check if it contains only one module, if yes then round is over - if(moduleRoundConfigs.size() == 1) - { - flag = true; - } - else - { - getLogger().debug("module round config is "+ moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo()); - int seqNo = moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo(); - if((currentModuleRoundConfig.getSequenceNo()) == seqNo) - { - flag = true; - } - else - { - for(int i = 0; i < moduleRoundConfigs.size(); i++) - { - // getLogger().debug("moduleroundconfig seq no is" + moduleRoundConfigs.get(i).getSequenceNo()); - getLogger().debug("Current seq no is" + currentModuleRoundConfig.getSequenceNo() +"and the moduleroundconfig is "+ moduleRoundConfigs.get(i).getSequenceNo()); - - if(currentModuleRoundConfig.getSequenceNo() == moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo()) - flag = true; - if(currentModuleRoundConfig.getSequenceNo() < moduleRoundConfigs.get(i).getSequenceNo()) - { - flag = false; - } - } - } - } - return flag; - } - - - private boolean isModuleFinished(Block currentBlock) { - // TODO Auto-generated method stub - boolean flag = false; - - List<Block> blocks = new ArrayList<Block>(); - getLogger().debug("in iscurrentmodulefinished"); - if(currentBlock == null) - { - flag = true; - } - else - { - Module currentModule = currentBlock.getModule(); - //getBlocks() return blocks in order of sequence number - blocks = currentModule.getBlocks(); - //select max(b.sequence_no) from block b where b.module_id=2; - getLogger().debug("no of blocks " + blocks.size() +"for module id: " + currentModule.getId()); - //if module contains only one block - if(blocks.size() == 1) - flag = true; - else - { - for(int i = 0; i < blocks.size(); i++) - { - if(currentBlock.getSequenceNo() == blocks.get(blocks.size() - 1).getSequenceNo()) - flag = true; - if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) - { - flag = false; - } - - } - } - } - return flag; - } - - private Game saveGameState(Block currentBlock, Round currentRound, Game game) { - - //FIXME: Game id 1 is hard coded but needs to make it dynamic - getLogger().info(" Game id to SAVE is: " + game.getId()); - Game newGame = null; - newGame = gameDao.find(game.getId()); - getLogger().info("The current block is: " + currentBlock.getId() + " while the current Round is: " + currentRound.getId()); - if(newGame.getCurrentBlock() == null && newGame.getCurrentRound()==null) - getLogger().info("BEFORE GAME SAVE: The current block NULL while the current Round is NULL"); - else - getLogger().info("BEFORE GAME SAVE: The current block is: " + newGame.getCurrentBlock().getId() + " while the current Round is: " + newGame.getCurrentRound().ge... [truncated message content] |
From: <al...@us...> - 2009-11-20 01:40:03
|
Revision: 372 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=372&view=rev Author: alllee Date: 2009-11-20 01:39:54 +0000 (Fri, 20 Nov 2009) Log Message: ----------- updating variable water supply treatment server and 1st practice round parameters for upcoming pretest Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-11-20 00:53:21 UTC (rev 371) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-11-20 01:39:54 UTC (rev 372) @@ -2,6 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment server configuration</comment> +<!--<entry key="hostname">localhost</entry>--> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> @@ -25,19 +26,40 @@ <entry key="wait-for-participants">true</entry> <entry key="number-of-rounds">17</entry> -<entry key="undisrupted-flow-required">true</entry> +<entry key="q1">49</entry> +<entry key="a1">49%</entry> +<entry key="explanation1">An existing infrastructure efficiency of 20% + 29 tokens invested = 49% infrastructure efficiency.</entry> +<entry key="q2">5</entry> +<entry key="a2">5 cubic feet per second</entry> +<entry key="explanation2"> +<![CDATA[ +An existing infrastructure efficiency of 35% + 15 tokens invested = 50% infrastructure efficiency for the current round. +An infrastructure efficiency of 50% corresponds to a water delivery capacity +of 5 cubic feet per second. +]]> +</entry> +<entry key="q3">5</entry> +<entry key='a3'>5 cubic feet per second</entry> +<entry key="explanation3">Since there is only 30 cubic feet per second of water +available, the irrigation infrastructure capacity of 35 cubic feet per +second will not be fully used. When A opens their gate, they take 25 of the +30 cubic feet per second out of the canal, leaving 5 cubic feet per second for +B. +</entry> +<entry key="q4">25</entry> +<entry key="a4">25 cubic feet per second</entry> +<entry key="explanation4">If A has 25 cfps available and does not take any +water, the same amount is available for the people downstream. Since B, C and +D do not take water, 25 cfps is available for E.</entry> +<entry key="q5">7</entry> +<entry key="a5">7 tokens</entry> +<entry key="explanation5">If you invest 7 out of 10 tokens, you keep 3 tokens for yourself. If you apply 202 cubic feet of water to your field you will earn 4 tokens. 3 + 4 = 7 tokens </entry> +<entry key="q6">19</entry> +<entry key="a6">19 tokens</entry> +<entry key="explanation6">If you invest all 10 tokens, you keep 0 tokens from +your initial endowment. If you apply 555 cubic feet of water to your field +you will earn 19 tokens. 0 + 19 = 19 tokens.</entry> -<entry key="q1">4</entry> -<entry key="q2">identity</entry> -<entry key="q3">49</entry> -<entry key="q4">76</entry> -<entry key="q5">20</entry> -<entry key="q6">5</entry> -<entry key="q7">25</entry> -<entry key="q8">7</entry> -<entry key="q9">19</entry> -<entry key="q10">1.50</entry> - <entry key='final-instructions'> <![CDATA[ <p> @@ -53,100 +75,37 @@ ]]> </entry> - +<!-- FIXME: lots of parameterizable fields here. should make instructions +template-language-pluggable +--> <entry key="initial-instructions"> <![CDATA[ -<h3>Welcome</h3> <p> -Please be patient while the experimental environment is set up. -<b>Please do not close this window or open any other windows.</b> +You have already earned 5 dollars by showing up for this exercise. You can earn +more, up to an extra 25 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. </p> -]]> -</entry> - - -<entry key="facilitator-instructions"> -<![CDATA[ -<h3>Facilitator Instructions</h3> <p> -Welcome to the facilitator interface. This interface allows you to control -the experiment. You may only modify configuration parameters <b>before</b> -you start the experiment by selecting the Configuration menu. When all the -participants are ready to begin the experiment, you can start the experiment -by selecting Experiment -> Start. After a round has been completed you -will be able to view the statistics for all of the participants. You can -begin the next round by selecting Round -> Start. +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 <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 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. </p> -]]> -</entry> - - -<entry key="general-instructions0"> -<![CDATA[ -<center><h3>Welcome to the experiment. Please do not close this window or open any -other applications.</h3></center> -]]> -</entry> - -<entry key="general-instructions1"> -<![CDATA[ -<h3>General Instructions</h3> -<p>Welcome. You have already earned 5 dollars by showing up for this exercise. -You can earn more, up to an extra 25 dollars, by participating in the exercise -which will last for about one hour. You will participate in this exercise as a -part of a group. Each group has 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 rest of the -group. That is, your earnings will depend on your decisions as well as the -other members of your group. -</p> <p> -This exercise mimics decisions people make in irrigation systems. In each round you -will receive 10 tokens which you can choose to keep or invest in the irrigation -infrastructure (for example canals and water diversion structures). Depending on the -state of repair of the irrigation infrastructure, it will be capable of directing -water to your field when you use your water diversion structure (called an -irrigation gate). Depending on the amount of water you can get to your field, you -can grow crops. Depending on the number of crops you grow you earn tokens. Each -token is worth 5 cents and you will be paid cash in private at the end of the -experiment based on the number of tokens you earned. +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: </p> -<p> -The experiment consists of a number of rounds. In each round you will first make a -decision as to how much to invest in the irrigation infrastructure. Without periodic -investment, the irrigation infrastructure will break down over time. Based on the -combined contributions of all 5 participants in your group in each round, as -explained below, your group can maintain the performance of the irrigation -infrastructure. The condition of the irrigation infrastructure determines -its capacity to deliver water which you can use to grow crops. -</p> -]]> -</entry> - -<entry key="general-instructionsq1"> -<![CDATA[ -<br><br> -To continue to the next page, please answer the following question:<br> -<form> -How many OTHER people in the room will be in your group?<br> -<input type="radio" name="q1" value="0">0<br> -<input type="radio" name="q1" value="1">1<br> -<input type="radio" name="q1" value="4">4<br> -<input type="radio" name="q1" value="Everybody">Everybody<br> -<br><br> -<input type="submit" name="submit" value="Submit"> -</form> -]]> -</entry> - -<entry key="general-instructions2"> -<![CDATA[ -<h3>Chat</h3> -<p>Before each round you will have a chat period of 40 seconds 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 side-payments or threaten them with any consequence after the experiment is @@ -158,375 +117,116 @@ We will be monitoring the chat traffic. If we detect any violation of these rules, we will have to remove <b>all members of the group where the violation occurred</b> from the experiment. That group will have to wait until the entire experiment is -finished to receive their payment. +finished to receive payment. </p> -<p> -You will see a text box appear on your screen when a chat period starts. The amount -of time left in the chat period will be shown at the <b>top left of the screen</b>.<br> -</p> ]]> </entry> -<entry key="general-instructionsq2"> +<entry key='game-screenshot-instructions'> <![CDATA[ -<br><br> -To continue to the next page, please answer the following question:<br> -<form> -Which of the following topics are you <b>not allowed</b> to discuss in chat?<br> -<input type="radio" name="q2" value="weather">the weather<br> -<input type="radio" name="q2" value="identity">your real identity<br> -<input type="radio" name="q2" value="experiment">the experiment<br> -<input type="radio" name="q2" value="earnings">what you will do with the money you earn from this experiment<br> -<br><br> -<input type="submit" name="submit" value="Submit"> -</form> +<img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> ]]> </entry> -<entry key="general-instructions3"> + +<entry key="facilitator-instructions"> <![CDATA[ -<h3>Creating Irrigation Infrastructure</h3> +<h3>Facilitator Instructions</h3> <p> -After the chat period ends you and each other participant will be given 10 tokens. -You must then decide what to do with these tokens. You may decide to invest in the -irrigation infrastructure or to keep the tokens. If you keep the tokens you will -earn at a minimum 10 tokens X 5 cents = $0.50 for each round. If you do this every -round after twenty rounds you will end up with at least $10 (plus any crops that you -may be able to grow as we will discuss later). Your total earnings for -participating in the experiment would then be at least $10 plus your show-up payment -of $5, for a grand total of at least $15. +Welcome to the facilitator interface. This interface allows you to control +the experiment. You may only modify configuration parameters <b>before</b> +you start the experiment by selecting the Configuration menu. When all the +participants are ready to begin the experiment, you can start the experiment +by selecting Experiment -> Start. After a round has been completed you +will be able to view the statistics for all of the participants. You can +begin the next round by selecting Round -> Start. </p> -<p> -On the other hand, if you invest some of your tokens in the irrigation -infrastructure, you may be able to earn more than this amount by growing crops. If -the irrigation infrastructure is operating at near maximum capacity you can earn -close to $1.50 each round. Thus if you grow crops you can roughly triple your -earnings compared to doing nothing. The actual earnings depend on the decisions you -and the other participants in your group make in terms of investment and when to -grow crops. -</p> -<p> -In 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 to invest out of your initial 10 -tokens. Keep in mind that the irrigation infrastructure must exceed a certain level -before you can grow crops. The tokens invested by all participants in your group -are added together and will total up to an amount 0 and 50 tokens. Each token -invested increases the irrigation infrastructure efficiency by one percentage point, -up to a <b>maximum of 100%</b>. This means that if the irrigation infrastructure -efficiency is at 80% it would not make sense for your group to invest a total of 50 -tokens, as any investment beyond 20 tokens would be wasted. In the table below you -can see the water delivery capacity measured in water units per second as a function -of the condition of the irrigation infrastructure. When the infrastructure is at -100% efficiency, 40 cubic feet of water per second (cfps) will be available. When the -irrigation infrastructure efficiency falls below 45%, there is no capacity left for -transporting water and thus there is no water available for anyone. -</p> -<p> -Your initial irrigation infrastructure will start at 75% efficiency but <b>will -carry over from round to round</b>. As an example, let's say that no one in a -group invests any tokens in the first round. The irrigation infrastructure -efficiency will be set at 75% for that first round. The table below lists the water -delivery in cubic feet per second (cfps) corresponding to the irrigation infrastructure -efficiency. If you look at the second to last row you can see that at 75% -efficiency the irrigation infrastructure will deliver 35 cfps. So in the first -round the group will have 35 cfps of water available to them. -</p> -<p> -Recall that each round the irrigation infrastructure efficiency deteriorates by 25%, -so at the start of the second round the infrastructure efficiency decreases to 50%. -At this point all five members of the group decide to invest 7 tokens each. This -increases the infrastructure efficiency by 35%, resulting in a total infrastructure -efficiency of 85%. If you look at the table again you can see that an -infrastructure efficiency of 85% will deliver 40 cfps. -</p> -<p> -The actual amount of water that is available for the group depends on the amount of -water available. 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 the infrastructure capacity allows 30 cfps and 40 cfps of water is available -to the system, only 30 cfps can be delivered. -</p> +]]> +</entry> -<p> -To recap, at the beginning of each round you will be informed of the current -irrigation infrastructure efficiency. You will then decide how many tokens (between -0 and 10) to invest in the irrigation infrastructure. After everybody has made -their decision, you will be notified of the condition of the irrigation -infrastructure and the corresponding water delivery capacity. -</p> -<b>Table 1:</b> The water delivery capacity as a function of the irrigation -infrastructure condition -<table border="1" cellspacing="2" cellpadding="2"> -<thead> -<th>Infrastructure efficiency (percent)</th> -<th>Water delivery (cubic feet per second)</th> -</thead> -<tr> -<td>≤ 45</td><td>0</td> -</tr> -<tr> -<td>46-51</td><td>5</td> -</tr> -<tr> -<td>52-55</td><td>10</td> -</tr> -<tr> -<td>56-58</td><td>15</td> -</tr> -<tr> -<td>59-61</td><td>20</td> -</tr> -<tr> -<td>62-65</td><td>25</td> -</tr> -<tr> -<td>66-70</td><td>30</td> -</tr> -<tr> -<td>71-80</td><td>35</td> -</tr> -<tr> -<td>81-100</td><td>40</td> -</tr> -</table> +<entry key="welcome-instructions"> +<![CDATA[ +<center><h3>Welcome to the experiment. Please do not close this window or open any +other applications.</h3></center> ]]> </entry> -<entry key="general-instructionsq3"> + +<entry key="quiz-page1"> <![CDATA[ -<br><br> -To continue to the next page, please answer the following questions:<br> +<p> +The first two questions deal with irrigation infrastructure investment. +<b>Please refer to Table 1 of your handout</b>. +</p> + <form> Question 1:<br> Given an existing infrastructure efficiency of 20%, if the five participants invest a <b>total of 29 additional tokens</b>, what is the new irrigation infrastructure -efficiency? -(<small><b>Note: only enter a number, you don't need to add the % sign</b></small>)<br> -<input type="text" name="q3" value = ""> +efficiency?<br> +<input type="text" name="q1" value = "">% <br><br> Question 2:<br> -Given an existing infrastructure efficiency of 50%, if <b>two participants invest 10 tokens each</b> -while the <b>three other participants invest 2 tokens each</b>, what is the new -irrigation infrastructure efficiency? -(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> -<input type="text" name="q4" value = ""> -<br><br> -<input type="submit" name="submit" value="Submit"><br> -<br> -</form> -]]> -</entry> +Suppose the infrastructure efficiency in the last round was 60%. For the current +round, the efficiency will decline by an amount of 25% for a resulting +infrastructure efficiency of 35%. If the members of your group invest a total of 15 +tokens, what will be your group's resulting water delivery capacity?<br> -<entry key="general-instructions4"> -<![CDATA[ -<h3>Growing crops</h3> -<p>There are <b>five</b> participants in each group, each of which is randomly assigned to -one of the five positions, A, B, C, D or E. Below is a screenshot of the -graphical interface representation of the irrigation system. Water comes from -the box to the left and the five players are located from upstream (leftmost) -to downstream (rightmost) accordingly. To illustrate, assume you are in -position C. The black lines represent "gates" that you open and close by -clicking on the large button on the lower left corner of the screen. -Each round consists of 50 seconds and the amount of time left in the -experiment is indicated by a bar at the top of the screen. -</p> -<img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> +<input type="text" name="q2" value = ""> cubic feet per second <br><br> -<p> -You can irrigate your field during the round by opening your gate. Your -earnings depend on the amount of water you can draw onto your fields and will -be explained in more detail on the next page. The speed at which you can grow -a crop depends on the amount of water available to you <b>at the time that you -open your gate</b>. The maximum flow capacity of the main canal shared by A, -B, C, D, and E is forty cubic feet per second. -</p> -<p> -The maximum amount of water 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 since you are also limited by the amount of water that is flowing -through the shared canal. -</p> -]]> -</entry> -<entry key="general-instructionsq4"> -<![CDATA[ +<b>The next two questions deal with the capacity of the irrigation system in relation +to the actual amount of water available.</b> <br><br> -To continue to the next page, please answer the following question:<br> Question 3:<br> -<form> -What is the minimum time to deliver 500 cubic feet of water to your field when -your maximum water flow capacity is available? +If the irrigation efficiency is between 71 and 80%, the water delivery capacity of +the irrigation system is 35 cubic feet per second. Suppose the water supply +available to your group is 30 cubic feet per second and A opens their gate, +diverting water at 25 cubic feet per second. What is the available water flow for +B? <br> -<input type="radio" name="q5" value="12.5">12.5 seconds<br> -<input type="radio" name="q5" value="20">20 seconds<br> -<input type="radio" name="q5" value="25">25 seconds<br> -<input type="radio" name="q5" value="50">50 seconds<br> +<input type='text' name='q3' value=''> cubic feet per second <br><br> -<input type="submit" name="submit" value="Submit"> -</form> -]]> -</entry> +Question 4: +If the available water delivery capacity is 25 cubic feet per second and A, B, C, +and D are not using water, how much cubic feet of water per second is available for +E?<br> +<input type='text' name='q4' value=''> cubic feet per second +<br><br> +<input type="submit" name="submit" value="Submit"><br> +<br> -<entry key="general-instructions5"> -<![CDATA[ -<h3>Positions A,B,C,D and E</h3> -<p> -The animation above illustrates how water flows to each player when their gates are -opened and closed. When a player opens their gate, the black line will rotate to a -vertical position, allowing water (represented by white dots) to flow to them. Note -that the water available downstream of a player with an open port is reduced, -illustrated by a narrowing of the canal. -</p> -<p> -Access to water depends on your position as shown in the window. Water originates -in the box at the upper left part of the screen and travels to the right. Thus, -participant A will have first access to the available water. Water not used by -participant A is then available to be used by participant B. Water not used by -participants A and B is then available for C. Water not used by participants A, B -and C is available for D. Finally, water not used by participants A, B, C and D is -available for E. -</p> -<p> -You can only get water to your field if you have water available to your position. -Suppose that the total irrigation capacity available is 40 cfps and 40 cfps of water -is available. If player A opens their gate they will consume 25 cfps of water and 15 -cfps is left for B. Suppose on the other hand, A does not open the gate, then a -total of 40 cfps is left for B, allowing B to extract water at the maximum rate of -25 cfps. -</p> -<p> -As another example, suppose that the canal system has been allowed to deteriorate -so that the total irrigation capacity available is 20 cfps. While player A’s gate is -open, no water is available for B. If A is NOT using water, 20 cfps is available for -B. -</p> ]]> </entry> -<entry key="general-instructionsq5"> +<entry key="quiz-page2"> <![CDATA[ -<br><br> -To continue to the next page, please answer the following question:<br> +<p> +The final two questions cover the number of tokens you can earn in within a round. +<b>Please refer to table 2 of your handout</b>. +</p> <form> -Suppose the irrigation efficiency is between 71 and 80% so that the canal flow -capacity is 30 cfps. If A opens their gate and diverts water at 25 cfps what is the -available water flow for B? -<br> -<input type="radio" name="q6" value="30">30 cfps<br> -<input type="radio" name="q6" value="25">25 cfps<br> -<input type="radio" name="q6" value="15">15 cfps<br> -<input type="radio" name="q6" value="5">5 cfps<br> +Question 5:<br> +If you invest 7 of the 10 tokens you start with and you apply 202 cubic feet of +water to your fields, what is the total number of tokens you will have earned at the +end of the round?<br> +<input type="text" name="q5" value="">tokens <br><br> -If the canal flow capacity available is 25 cfps and A,B,C and D are not using water, -what is the available water for E? -<br> -<input type="radio" name="q7" value="40">40 cfps<br> -<input type="radio" name="q7" value="25">25 cfps<br> -<input type="radio" name="q7" value="15">15 cfps<br> -<input type="radio" name="q7" value="0">0 cfps<br> - -<input type="submit" name="submit" value="Submit"> +Question 6:<br> +If you invest all 10 tokens you start with and you apply 555 cubic feet of water to +your fields, what is the total number of tokens you will have earned at the end of +the round?<br> +<input type="text" name="q6" value="">tokens <br><br> +<input type="submit" name="submit" value="Submit"> </form> ]]> </entry> -<entry key="general-instructions6"> -<![CDATA[ -<h3>How to grow crops</h3> -<p> -To start growing crops, click on the yellow button labeled "open gate". -This will open your irrigation gate and allow water to flow to your field if it is -available. The text on the button will change to "close gate" - if -you would like to close the gate and stop extracting water from the canal, just -click on the yellow button again. Your gate will close and the text on the button -will change back to "open gate". -</p> -<p> -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 table below you can see the amount of tokens earned for amount of -water applied to your field. -</p> -<b>Table 2</b>: Earnings resulting from the amount of water applied to your field. - -<table border="1" cellspacing="2" cellpadding="2"> -<thead> -<th>Water units received (cubic feet)</th> -<th>Tokens earned</th> -</thead> -<tr> -<td>< 150</td><td>0</td> -</tr> -<tr> -<td>150-199</td><td>1</td> -</tr> -<tr> -<td>200-249</td><td>4</td> -</tr> -<tr> -<td>250-299</td><td>10</td> -</tr> -<tr> -<td>300-349</td><td>15</td> -</tr> -<tr> -<td>350-399</td><td>18</td> -</tr> -<tr> -<td>400-499</td><td>19</td> -</tr> -<tr> -<td>500-549</td><td>20</td> -</tr> -<tr> -<td>550-649</td><td>19</td> -</tr> -<tr> -<td>650-699</td><td>18</td> -</tr> -<tr> -<td>700-749</td><td>15</td> -</tr> -<tr> -<td>750-799</td><td>10</td> -</tr> -<tr> -<td>800-849</td><td>4</td> -</tr> -<tr> -<td>850-899</td><td>1</td> -</tr> -<tr> -<td>> 899</td><td>0</td> -</tr> -</table> - -Your earnings at the end of the round depend on your investment and the number of -tokens received for the crop. For example, suppose you invest 6 out of the 10 -tokens you are endowed with at the start of the round and you receive 333 cubic feet -of water. Your total earnings will be the amount of tokens leftover from your -initial endowment (10 - 6) plus the tokens you earned from your crop (15 tokens for -333 cubic feet of water, see Table 2). The total number of tokens earned is 19 -($0.85 since each token is $0.05). - -]]> -</entry> - <entry key='water-collected-to-tokens-table'> <![CDATA[ <table border="1" cellspacing="2" cellpadding="2"> @@ -583,106 +283,36 @@ ]]> </entry> - -<entry key="general-instructionsq6"> +<entry key='chat-instructions'> <![CDATA[ -<br><br> -To continue to the next page, please answer the following question:<br> -<form> -If you invest 7 of the 10 tokens you started with, and you put 202 cf of water -on your field, what is the <b>total number of tokens</b> you will have earned -for that round? -<br> -<input type="radio" name="q8" value="3">3<br> -<input type="radio" name="q8" value="5">5<br> -<input type="radio" name="q8" value="7">7<br> -<input type="radio" name="q8" value="13">13<br> -<br><br> -If you invest all 10 tokens you start with, and you put 555 cf of water on your -field, what is the total number of tokens your will have earned for that round? -<br> -<input type="radio" name="q9" value="10">10<br> -<input type="radio" name="q9" value="19">19<br> -<input type="radio" name="q9" value="20">20<br> -<input type="radio" name="q9" value="29">29<br> -<br><br> -<input type="submit" name="submit" value="Submit"> -</form> -]]> -</entry> - -<entry key="general-instructions7"> -<![CDATA[ -<h3>Scores</h3> -<p> -The total number of tokens collected during a round is shown on the screen with the -message: -<br><br> -Total tokens earned this round: 0 -<br><br> -This the total of tokens not invested in irrigation structure plus additional -tokens earned by growing a crop. -<br> -You will also see the scores of the other participants summarized on the screen. -Finally, you will see the water flow capacity of each player at any given moment, as -illustrated in the figure below. - -]]> -</entry> - - -<entry key="general-instructionsq7"> -<![CDATA[ -<br><br> -To continue to the next page, please answer the following question:<br> -<form> -Each token is worth 5 cents, thus if you collected 30 tokens in a round you earned: -<br> -<input type="radio" name="q10" value=".15">$0.15<br> -<input type="radio" name="q10" value=".50">$0.50<br> -<input type="radio" name="q10" value="1.50">$1.50<br> -<input type="radio" name="q10" value="2.50">$2.50<br> -<br><br> -<input type="submit" name="submit" value="Submit"> -<br><br> -</form> -]]> -</entry> - -<entry key="general-instructions8"> -<![CDATA[ -<p> -We will now start with two practice rounds. This practice round will not -contribute to your earnings – it is intended to acquaint you with the -functioning of the exercise environment. +<h3>Chat Instructions</h3> +You may now chat for %d seconds with the other members of your group. 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 +side-payments or threaten them with any consequence after the experiment is +finished. +</li> +<li>You are <b>not allowed to reveal your real identity</b>.</li> +</ol> <p> -You will first chat via text with other participants in your group and then -decide how much you wish to invest in irrigation infrastructure maintenance. -After all investment decisions have been made you will begin the actual round -and make real-time decisions on when to open your gates and irrigate your -fields. +We will be monitoring the chat traffic. If we detect any violation of these rules, +we will have to remove <b>all members of the group where the violation occurred</b> +from the experiment. That group will have to wait until the entire experiment is +finished to receive payment. </p> <p> -If you have any questions feel free to raise your hand and to ask your question. -<b>Do you have any questions so far?</b> +You can send messages by typing in the text field at the bottom of the screen +and then pressing the return key or clicking the send button. The time left +for the discussion is displayed with a progress bar above the text field at +the bottom of the screen. </p> ]]> </entry> -<entry key="undisrupted-flow-instructions"> -<![CDATA[ -<p> -If the flow of water is disrupted while your gate is open your crop growing progress -will be halted. -</p> -]]> -</entry> - - <entry key="investment-instructions"> <![CDATA[ -<h3>Invest tokens in the irrigation infrastructure</h3> <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 Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml 2009-11-20 00:53:21 UTC (rev 371) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml 2009-11-20 01:39:54 UTC (rev 372) @@ -2,7 +2,10 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> + <entry key="practice-round">true</entry> +<entry key='reset-infrastructure-efficiency'>true</entry> +<entry key='initial-infrastructure-efficiency'>50</entry> <entry key="instructions"> <![CDATA[ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-20 00:53:28
|
Revision: 371 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=371&view=rev Author: alllee Date: 2009-11-20 00:53:21 +0000 (Fri, 20 Nov 2009) Log Message: ----------- replacing bottom left dashboard with giant button, should add an open / close gate image to it as well. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-19 22:56:43 UTC (rev 370) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-20 00:53:21 UTC (rev 371) @@ -10,7 +10,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -18,8 +17,6 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; -import javax.swing.GroupLayout.Alignment; -import javax.swing.GroupLayout.ParallelGroup; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; @@ -68,22 +65,15 @@ private boolean open; - private JTextField waterCollectedTextField; - - private JLabel waterCollectedLabel; - - private JTextField tokensNotInvestedTextField; - - private JLabel tokensNotInvestedLabel; - - private JTextField tokensEarnedTextField; - - private JLabel tokensEarnedLabel; - - private JTextField totalTokensEarnedTextField; - - private JLabel totalTokensEarnedLabel; - +// private JTextField waterCollectedTextField; +// private JLabel waterCollectedLabel; +// private JTextField tokensNotInvestedTextField; +// private JLabel tokensNotInvestedLabel; +// private JTextField tokensEarnedTextField; +// private JLabel tokensEarnedLabel; +// private JTextField totalTokensEarnedTextField; +// private JLabel totalTokensEarnedLabel; + private JLabel irrigationCapacityLabel; private JLabel waterSupplyLabel; @@ -186,8 +176,8 @@ jPanelUpStreamWindow.setLayout(new BorderLayout()); jPanelUpStreamWindow.setBackground(new Color(186, 226, 237)); jPanelUpStreamWindow.setBounds(new Rectangle(13, 225+100+50, 530, 326)); - jPanelUpStreamWindow.add(getGateSwitchButton(), BorderLayout.NORTH); - jPanelUpStreamWindow.add(getControlPanel(), BorderLayout.CENTER); + jPanelUpStreamWindow.add(getGateSwitchButton(), BorderLayout.CENTER); +// jPanelUpStreamWindow.add(getControlPanel(), BorderLayout.SOUTH); } return jPanelUpStreamWindow; } @@ -213,108 +203,111 @@ } return gateSwitchButton; } + - private JPanel getControlPanel() { - JPanel bottomInformationPanel = new JPanel(); - GroupLayout layout = new GroupLayout(bottomInformationPanel); - bottomInformationPanel.setLayout(layout); - layout.setAutoCreateContainerGaps(true); - layout.setAutoCreateGaps(true); +// private JPanel getControlPanel() { +// JPanel bottomInformationPanel = new JPanel(); +// GroupLayout layout = new GroupLayout(bottomInformationPanel); +// bottomInformationPanel.setLayout(layout); +// layout.setAutoCreateContainerGaps(true); +// layout.setAutoCreateGaps(true); +// +// GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup(); +// ParallelGroup labelsGroup = layout.createParallelGroup(); +// labelsGroup.addComponent(getWaterCollectedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); +// +// horizontalGroup.addGroup(labelsGroup); +// +// ParallelGroup textFieldGroup = layout.createParallelGroup(); +// textFieldGroup.addComponent(getWaterCollectedTextField()); +// textFieldGroup.addComponent(getTokensNotInvestedTextField()); +// textFieldGroup.addComponent(getTokensEarnedTextField()); +// textFieldGroup.addComponent(getTotalTokensEarnedTextField()); +// horizontalGroup.addGroup(textFieldGroup); +// layout.setHorizontalGroup(horizontalGroup); +// +// GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup(); +// verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(getWaterCollectedLabel()).addComponent(getWaterCollectedTextField())); +// +// verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(getTokensNotInvestedLabel()).addComponent(getTokensNotInvestedTextField())); +// +// verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(getTokensEarnedLabel()).addComponent(getTokensEarnedTextField())); +// +// verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); +// +// layout.setVerticalGroup(verticalGroup); +// return bottomInformationPanel; +// } - GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup(); - ParallelGroup labelsGroup = layout.createParallelGroup(); - labelsGroup.addComponent(getWaterCollectedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); - - horizontalGroup.addGroup(labelsGroup); - - ParallelGroup textFieldGroup = layout.createParallelGroup(); - textFieldGroup.addComponent(getWaterCollectedTextField()); - textFieldGroup.addComponent(getTokensNotInvestedTextField()); - textFieldGroup.addComponent(getTokensEarnedTextField()); - textFieldGroup.addComponent(getTotalTokensEarnedTextField()); - horizontalGroup.addGroup(textFieldGroup); - layout.setHorizontalGroup(horizontalGroup); - - GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup(); - verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(getWaterCollectedLabel()).addComponent(getWaterCollectedTextField())); - - verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(getTokensNotInvestedLabel()).addComponent(getTokensNotInvestedTextField())); - - verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(getTokensEarnedLabel()).addComponent(getTokensEarnedTextField())); - - verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); - - layout.setVerticalGroup(verticalGroup); - return bottomInformationPanel; - } - - private JTextField getWaterCollectedTextField() { - if (waterCollectedTextField == null) { - waterCollectedTextField = createTextField(); - } - return waterCollectedTextField; - } - - private JTextField createTextField() { - JTextField textField = new JTextField(); - textField.setEditable(false); -// textField.setBackground(Color.LIGHT_GRAY); - textField.setBackground(Color.YELLOW); - return textField; - } - - private JLabel getWaterCollectedLabel() { - if (waterCollectedLabel == null) { - waterCollectedLabel = new JLabel("Total water applied to your field: "); - } - return waterCollectedLabel; - } - - private JTextField getTokensNotInvestedTextField() { - if (tokensNotInvestedTextField == null) { - tokensNotInvestedTextField = createTextField(); - } - return tokensNotInvestedTextField; - } - private JLabel getTokensNotInvestedLabel() { - if (tokensNotInvestedLabel == null) { - tokensNotInvestedLabel = new JLabel("Tokens not invested: "); - } - return tokensNotInvestedLabel; - } - - private JTextField getTokensEarnedTextField() { - if (tokensEarnedTextField == null) { - tokensEarnedTextField = createTextField(); - } - return tokensEarnedTextField; - } - private JLabel getTokensEarnedLabel() { - if (tokensEarnedLabel == null) { - tokensEarnedLabel = new JLabel("Tokens earned by crop production: "); - } - return tokensEarnedLabel; - } - - private JTextField getTotalTokensEarnedTextField() { - if (totalTokensEarnedTextField == null) { - totalTokensEarnedTextField = createTextField(); - } - return totalTokensEarnedTextField; - - } - - private JLabel getTotalTokensEarnedLabel() { - if (totalTokensEarnedLabel == null) { - totalTokensEarnedLabel = new JLabel("Total tokens earned this round: "); - } - return totalTokensEarnedLabel; - } + private JTextField createTextField() { + JTextField textField = new JTextField(); + textField.setEditable(false); +// textField.setBackground(Color.LIGHT_GRAY); + textField.setBackground(Color.YELLOW); + return textField; + } +// private JTextField getWaterCollectedTextField() { +// if (waterCollectedTextField == null) { +// waterCollectedTextField = createTextField(); +// } +// return waterCollectedTextField; +// } +// +// +// +// private JLabel getWaterCollectedLabel() { +// if (waterCollectedLabel == null) { +// waterCollectedLabel = new JLabel("Total water applied to your field: "); +// } +// return waterCollectedLabel; +// } +// +// private JTextField getTokensNotInvestedTextField() { +// if (tokensNotInvestedTextField == null) { +// tokensNotInvestedTextField = createTextField(); +// } +// return tokensNotInvestedTextField; +// } +// private JLabel getTokensNotInvestedLabel() { +// if (tokensNotInvestedLabel == null) { +// tokensNotInvestedLabel = new JLabel("Tokens not invested: "); +// } +// return tokensNotInvestedLabel; +// } +// +// private JTextField getTokensEarnedTextField() { +// if (tokensEarnedTextField == null) { +// tokensEarnedTextField = createTextField(); +// } +// return tokensEarnedTextField; +// } +// private JLabel getTokensEarnedLabel() { +// if (tokensEarnedLabel == null) { +// tokensEarnedLabel = new JLabel("Tokens earned by crop production: "); +// } +// return tokensEarnedLabel; +// } +// +// private JTextField getTotalTokensEarnedTextField() { +// if (totalTokensEarnedTextField == null) { +// totalTokensEarnedTextField = createTextField(); +// } +// return totalTokensEarnedTextField; +// +// } +// +// private JLabel getTotalTokensEarnedLabel() { +// if (totalTokensEarnedLabel == null) { +// totalTokensEarnedLabel = new JLabel("Total tokens earned this round: "); +// } +// return totalTokensEarnedLabel; +// } + private JLabel getIrrigationCapacityLabel() { if (irrigationCapacityLabel == null) { irrigationCapacityLabel = new JLabel(); @@ -412,10 +405,10 @@ } } ClientData clientData = clientDataModel.getClientData(); - getWaterCollectedTextField().setText("" + clientData.getWaterCollected()); - getTokensNotInvestedTextField().setText("" + clientData.getUninvestedTokens()); - getTokensEarnedTextField().setText("" + clientData.getTokensEarnedFromWaterCollected()); - getTotalTokensEarnedTextField().setText("" + clientData.getAllTokensEarnedThisRound()); +// getWaterCollectedTextField().setText("" + clientData.getWaterCollected()); +// getTokensNotInvestedTextField().setText("" + clientData.getUninvestedTokens()); +// getTokensEarnedTextField().setText("" + clientData.getTokensEarnedFromWaterCollected()); +// getTotalTokensEarnedTextField().setText("" + clientData.getAllTokensEarnedThisRound()); getMiddleWindowPanel().update(clientDataModel); currentWaterAppliedSeries.clear(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-19 22:56:43 UTC (rev 370) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-20 00:53:21 UTC (rev 371) @@ -61,9 +61,6 @@ private final ServerDataModel serverDataModel; - // private final Object quizSignal = new Object(); - // private int numberOfCompletedQuizzes; - private int submittedClients; private IrrigationPersister persister; @@ -145,9 +142,11 @@ return; } // ignore the request if not every group has submit their tokens. - synchronized (roundSignal) { - roundSignal.notifyAll(); - } + if (isTokenInvestmentComplete()) { + synchronized (roundSignal) { + roundSignal.notifyAll(); + } + } } }); addEventProcessor(new EventTypeProcessor<EndRoundRequest>(EndRoundRequest.class) { @@ -160,10 +159,14 @@ addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { @Override public void handle(BeginChatRoundRequest request) { + // XXX: the participants have already been added to the data model at this point + // so we shuffle them around right before the first practice round's chat. if (getRoundConfiguration().isFirstRound()) { shuffleParticipants(); } - persister.clearChatData(); + else { + persister.clearChatData(); + } // pass it on to all the clients synchronized (clients) { for (Identifier id: clients.keySet()) { @@ -204,7 +207,6 @@ Identifier identifier = event.getId(); ClientData clientData = new ClientData(identifier); synchronized (clients) { - // FIXME: shouldn't add to server data model right away... clients.put(identifier, clientData); serverDataModel.addClient(clientData); } @@ -254,10 +256,13 @@ addEventProcessor(new EventTypeProcessor<InvestedTokensEvent>(InvestedTokensEvent.class) { @Override public void handle(InvestedTokensEvent event) { - ClientData clientData = clients.get(event.getId()); - clientData.setInvestedTokens(event.getInvestedTokens()); + if (isTokenInvestmentComplete()) { + getLogger().severe("Trying to invest more tokens but token investment is already complete:" + event); + return; + } + clients.get(event.getId()).setInvestedTokens(event.getInvestedTokens()); submittedClients++; - if (submittedClients >= clients.size()) { + if (isTokenInvestmentComplete()) { // everyone's submitted their tokens so we can calculate the available bandwidth and // notify each client initializeInfrastructureEfficiency(); @@ -274,8 +279,7 @@ }); addEventProcessor(new EventTypeProcessor<OpenGateEvent>(OpenGateEvent.class) { public void handle(OpenGateEvent event) { - ClientData clientData = clients.get(event.getId()); - clientData.openGate(); + clients.get(event.getId()).openGate(); } }); addEventProcessor(new EventTypeProcessor<CloseGateEvent>(CloseGateEvent.class) { @@ -289,6 +293,10 @@ } }); } + + private boolean isTokenInvestmentComplete() { + return submittedClients >= clients.size(); + } /** * Invoked after every client has submit their tokens Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml 2009-11-19 22:56:43 UTC (rev 370) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml 2009-11-20 00:53:21 UTC (rev 371) @@ -5,6 +5,7 @@ <entry key="practice-round">true</entry> <entry key='reset-infrastructure-efficiency'>true</entry> +<entry key='initial-infrastructure-efficiency'>50</entry> <entry key="instructions"> <![CDATA[ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-20 00:10:23
|
leaving today at 17:00pm (2.5hr) The server would not compile, Seema made some suggestions for files to delete, but it ended up making more errors in the end, and the server will still not compile. On Thu, Nov 19, 2009 at 2:36 PM, Kalin Jonas <kj...@as...> wrote: > Today I'm checking in from home. > I will be checking to see if i can get all the way through the game without > error using seema's new code. > > > On Mon, Nov 16, 2009 at 2:02 PM, Kalin Jonas <kj...@as...> wrote: > >> Leaving today at 14:00 (2.75hr) >> I have modified the code to accept game objects, instead of just blocks. >> This should fix the problem of getting the round from the server (in >> strategyDesign) >> I will test this next time I work >> >> >> On Mon, Nov 16, 2009 at 11:57 AM, Kalin Jonas <kj...@as...> wrote: >> >>> Today I came in at 11:15 to begin working. >>> I have been reading the document that seema sent me, and updating my >>> code. >>> I'll be working on trying to test seema's new methods. >>> >> >> > |
From: <see...@us...> - 2009-11-19 22:56:51
|
Revision: 370 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=370&view=rev Author: seematalele Date: 2009-11-19 22:56:43 +0000 (Thu, 19 Nov 2009) Log Message: ----------- Revised the code. Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-19 07:48:01 UTC (rev 369) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-19 22:56:43 UTC (rev 370) @@ -2,9 +2,7 @@ import org.apache.log4j.Logger; -import edu.asu.commons.mme.entity.Block; import edu.asu.commons.mme.entity.Game; -import edu.asu.commons.mme.service.StartGame; import flex.messaging.MessageBroker; import flex.messaging.messages.AcknowledgeMessage; import flex.messaging.messages.AsyncMessage; @@ -12,7 +10,7 @@ public class MessageHandler { - private static Logger logger = Logger.getLogger(StartGame.class); + private static Logger logger = Logger.getLogger(MessageHandler.class); private PushData pushData; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-19 21:38:20
|
Today I'm checking in from home. I will be checking to see if i can get all the way through the game without error using seema's new code. On Mon, Nov 16, 2009 at 2:02 PM, Kalin Jonas <kj...@as...> wrote: > Leaving today at 14:00 (2.75hr) > I have modified the code to accept game objects, instead of just blocks. > This should fix the problem of getting the round from the server (in > strategyDesign) > I will test this next time I work > > > On Mon, Nov 16, 2009 at 11:57 AM, Kalin Jonas <kj...@as...> wrote: > >> Today I came in at 11:15 to begin working. >> I have been reading the document that seema sent me, and updating my code. >> I'll be working on trying to test seema's new methods. >> > > |
From: <al...@us...> - 2009-11-19 07:48:08
|
Revision: 369 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=369&view=rev Author: alllee Date: 2009-11-19 07:48:01 +0000 (Thu, 19 Nov 2009) Log Message: ----------- minor interface improvement, lifted chat instructions to config file. should look into templating language at some point... Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml Property Changed: ---------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-19 03:42:52 UTC (rev 368) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-19 07:48:01 UTC (rev 369) @@ -48,39 +48,40 @@ } private ChartPanel createChartPanel() { - final XYSeries actualFlowCapacitySeries = new XYSeries("Actual"); - final XYSeries potentialFlowCapacitySeries = new XYSeries("Potential"); - // final XYSeries actualFlowCapacitySeriesY = new XYSeries("Actual"); - final XYSeries initialInfrastructureEfficiencySeries = new XYSeries("Initial"); + final XYSeries postInvestmentInfrastructureEfficiencySeries = new XYSeries("Infrastructure Efficiency After Investment"); + final XYSeries potentialInfrastructureEfficiencySeries = new XYSeries("Infrastructure Efficiency Potential"); + final XYSeries preInvestmentInfrastructureEfficiencySeries = new XYSeries("Infrastructure Efficiency Before Investment"); final XYSeries waterSupplySeries = new XYSeries("Available water supply"); GroupDataModel group = client.getClientDataModel().getGroupDataModel(); final int actualInfrastructureEfficiency = group.getInfrastructureEfficiency(); final int actualFlowCapacity = group.getWaterDeliveryCapacity(); for (int y = 0; y <= actualFlowCapacity; y++) { - actualFlowCapacitySeries.add(actualInfrastructureEfficiency, y); + postInvestmentInfrastructureEfficiencySeries.add(actualInfrastructureEfficiency, y); } RoundConfiguration roundConfiguration = client.getRoundConfiguration(); int maximumInfrastructureEfficiency = roundConfiguration.getMaximumInfrastructureEfficiency(); int waterSupplyCapacity = roundConfiguration.getWaterSupplyCapacity(); for (int x = 0; x <= maximumInfrastructureEfficiency; x++) { int flowCapacity = group.calculateWaterDeliveryCapacity(x); - potentialFlowCapacitySeries.add(x,flowCapacity); + potentialInfrastructureEfficiencySeries.add(x,flowCapacity); waterSupplySeries.add(x, waterSupplyCapacity); } final int infrastructureEfficiencyBeforeInvestment = group.getInfrastructureEfficiencyBeforeInvestment(); final int irrigationCapacityBeforeInvestment = group.getIrrigationCapacityBeforeInvestment(); for (int y = 0; y <= irrigationCapacityBeforeInvestment; y++) { - initialInfrastructureEfficiencySeries.add(infrastructureEfficiencyBeforeInvestment, y); + preInvestmentInfrastructureEfficiencySeries.add(infrastructureEfficiencyBeforeInvestment, y); } final XYSeriesCollection data = new XYSeriesCollection(); - data.addSeries(initialInfrastructureEfficiencySeries); - // the second series gets turned blue. + data.addSeries(potentialInfrastructureEfficiencySeries); data.addSeries(waterSupplySeries); - data.addSeries(actualFlowCapacitySeries); - data.addSeries(potentialFlowCapacitySeries); + data.addSeries(preInvestmentInfrastructureEfficiencySeries); + data.addSeries(postInvestmentInfrastructureEfficiencySeries); + + + final JFreeChart chart = ChartFactory.createXYLineChart( "Water Delivery Capacity vs. Infrastructure Efficiency", "Infrastructure Efficiency (%)", Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-19 03:42:52 UTC (rev 368) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-19 07:48:01 UTC (rev 369) @@ -461,10 +461,10 @@ int irrigationCapacity = clientDataModel.getIrrigationCapacity(); int waterSupply = clientDataModel.getWaterSupplyCapacity(); irrigationCapacityLabel.setText( - String.format("Irrigation capacity: %d cubic feet per second (cfps)", + String.format("Water delivery capacity: %d cubic feet per second (cfps)", irrigationCapacity)); waterSupplyLabel.setText( - String.format("Water supply: %d cubic feet per second (cfps)", + String.format("Available water supply: %d cubic feet per second (cfps)", waterSupply)); revalidate(); } Property changes on: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java ___________________________________________________________________ Added: svn:keywords + Date Id Revision Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-19 03:42:52 UTC (rev 368) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-19 07:48:01 UTC (rev 369) @@ -87,7 +87,11 @@ } public String getInitialInstructions() { - return assistant.getProperty("initial-instructions"); + String initialInstructions = assistant.getProperty("initial-instructions", ""); + if (initialInstructions.contains("%d")) { + return String.format(initialInstructions, getChatDuration()); + } + return initialInstructions; } public String getWelcomeInstructions() { @@ -139,16 +143,11 @@ } public String getChatInstructions() { - return assistant.getProperty("chat-instructions", - String.format( - "<h3>Chat Instructions</h3><p>You now have the opportunity to chat for %d seconds. You can discuss whatever you want" + - " related to the experiment with some restrictions. You may not promise the other participant(s) side " + - "payments or threaten them with any consequence (e.g., physical violence) after the experiment is finished. Also, you may not reveal your real identity." + - "We are monitoring chat traffic - if we notice a violation of the rules we will remove the group from the room until the other groups are finished with the experiment.</p>" + - "<p>You can send messages by typing in the text field at the bottom of the screen and then hit return or click send. " + - "The time left for the discussion is displayed above the text field at the bottom of the screen.</p>", - getChatDuration()) - ); + String chatInstructions = assistant.getProperty("chat-instructions", ""); + if (chatInstructions.contains("%d")) { + return String.format(chatInstructions, getChatDuration()); + } + return chatInstructions; } public String getGameScreenshotInstructions() { Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-19 03:42:52 UTC (rev 368) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-19 07:48:01 UTC (rev 369) @@ -75,7 +75,9 @@ ]]> </entry> - +<!-- FIXME: lots of parameterizable fields here. should make instructions +template-language-pluggable +--> <entry key="initial-instructions"> <![CDATA[ <p> @@ -88,18 +90,19 @@ 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. Given the capacity of the irrigation infrastructure and -the availability of water, you can 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 make a decision as to 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. +irrigation 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 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. </p> <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 60 seconds where you can +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: </p> @@ -114,12 +117,8 @@ We will be monitoring the chat traffic. If we detect any violation of these rules, we will have to remove <b>all members of the group where the violation occurred</b> from the experiment. That group will have to wait until the entire experiment is -finished to receive their payment. +finished to receive payment. </p> -<p> -You will see a text box appear on your screen when a chat period starts. The amount -of time left in the chat period will be displayed <b>below the chat messages window</b>.<br> -</p> ]]> </entry> @@ -284,9 +283,36 @@ ]]> </entry> +<entry key='chat-instructions'> +<![CDATA[ +<h3>Chat Instructions</h3> +You may now chat for %d seconds with the other members of your group. 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 +side-payments or threaten them with any consequence after the experiment is +finished. +</li> +<li>You are <b>not allowed to reveal your real identity</b>.</li> +</ol> +<p> +We will be monitoring the chat traffic. If we detect any violation of these rules, +we will have to remove <b>all members of the group where the violation occurred</b> +from the experiment. That group will have to wait until the entire experiment is +finished to receive payment. +</p> +<p> +You can send messages by typing in the text field at the bottom of the screen +and then pressing the return key or clicking the send button. The time left +for the discussion is displayed with a progress bar above the text field at +the bottom of the screen. +</p> +]]> +</entry> + <entry key="investment-instructions"> <![CDATA[ -<h3>Invest tokens in the irrigation infrastructure</h3> <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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-19 03:43:00
|
Revision: 368 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=368&view=rev Author: alllee Date: 2009-11-19 03:42:52 +0000 (Thu, 19 Nov 2009) Log Message: ----------- minor hygiene / refactoring, renaming Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -177,7 +177,7 @@ } public void initialize(List<Identifier> participants) { - System.err.println("Setting participants: " + participants); + displayMessage("", " ---- chat round starting ---- "); if (HANDLES != null) { return; } @@ -187,7 +187,6 @@ HANDLES[i] = " " + HANDLE_STRING.charAt(i) + " "; chatHandles.put(participants.get(i), HANDLES[i]); } - displayMessage("", " ---- chat round starting ---- "); } public Identifier getClientId() { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -122,7 +122,7 @@ } public int getIrrigationCapacity() { - return groupDataModel.getIrrigationCapacity(); + return groupDataModel.getWaterDeliveryCapacity(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -207,6 +207,7 @@ else { setInstructions(instructionsBuilder.toString()); nextButton.setEnabled(false); + disableQuiz(); } } }); @@ -390,7 +391,7 @@ private void setInstructions(String instructions, boolean caretToEnd) { instructionsEditorPane.setText(instructions); - instructionsEditorPane.setCaretPosition(caretToEnd ? instructions.length() : 0); + instructionsEditorPane.setCaretPosition(caretToEnd ? instructions.length() - 1 : 0); } private void displayInstructions(final String instructions) { @@ -473,19 +474,19 @@ builder.append("<ul><li>Infrastructure efficiency before investment: ") .append(groupDataModel.getInfrastructureEfficiencyBeforeInvestment()) .append("%</li>"); - builder.append("<li>Irrigation capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second</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 irrigation capacity to "); + if (groupDataModel.getWaterDeliveryCapacity() > 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 irrigation capacity. Your group's irrigation capacity is still "); + 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.getActualFlowCapacity()).append(" cubic feet per second</li>"); + builder.append(groupDataModel.getWaterDeliveryCapacity()).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>"); SwingUtilities.invokeLater(new Runnable() { public void run() { contributionInformationEditorPane.setText(builder.toString()); @@ -538,17 +539,17 @@ infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { - infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); + infrastructureEfficiency = Math.max(0, group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor()); } addCenterComponent(getTokenInvestmentPanel()); StringBuilder builder = new StringBuilder(); builder.append( String.format( "<h2>Current infrastructure efficiency: %d%%</h2>" + - "<h2>Current irrigation capacity: %d cubic feet per second</h2>" + + "<h2>Current water delivery capacity: %d cubic feet per second</h2>" + "<h2>Available water supply: %d cubic feet per second</h2>", infrastructureEfficiency, - group.calculateFlowCapacity(infrastructureEfficiency), + group.calculateWaterDeliveryCapacity(infrastructureEfficiency), roundConfiguration.getWaterSupplyCapacity() )); builder.append(getServerConfiguration().getInvestmentInstructions()); @@ -563,18 +564,18 @@ if (! roundConfiguration.isFirstRound()) { instructionsBuilder.append(roundConfiguration.getInstructions()); instructionsBuilder.append("<hr/>"); - int irrigationCapacity = clientDataModel.getGroupDataModel().getIrrigationCapacity(); + int irrigationCapacity = clientDataModel.getGroupDataModel().getWaterDeliveryCapacity(); // int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); if (roundConfiguration.shouldResetInfrastructureEfficiency()) { - instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75%."); + instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75% (water delivery capacity of 35 cfps)."); } else { instructionsBuilder.append( - String.format("<p>The <b>current infrastructure efficiency is %d%%</b> but will <b>decline by %d%%</b> during this round." + - "The <b>current irrigation capacity is %d cfps</b> and the <b>available water supply is %d cfps</b>.</p><hr/>", + String.format("<p>The <b>irrigation infrastructure efficiency is %d%% (water delivery capacity of %d cfps)</b> but will <b>decline by %d%%</b> during this round." + + "The <b>available water supply is %d cfps</b>.</p><br/><hr/>", clientDataModel.getGroupDataModel().getInfrastructureEfficiency(), + irrigationCapacity, roundConfiguration.getInfrastructureDegradationFactor(), - irrigationCapacity, roundConfiguration.getWaterSupplyCapacity() )); } @@ -637,15 +638,11 @@ /** * Should only be invoked when the instructions navigation panel is done. - * How do we know when it's done? When the user adds a new + * How do we know when it's done? */ - public void disableQuiz() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - getInstructionsPanel().remove(getQuizNavigationPanel()); - getInstructionsPanel().revalidate(); - } - }); + private void disableQuiz() { + getInstructionsPanel().remove(getQuizNavigationPanel()); + getInstructionsPanel().revalidate(); } public void showGameScreenshot() { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -55,15 +55,15 @@ final XYSeries waterSupplySeries = new XYSeries("Available water supply"); GroupDataModel group = client.getClientDataModel().getGroupDataModel(); final int actualInfrastructureEfficiency = group.getInfrastructureEfficiency(); - final int actualFlowCapacity = group.getIrrigationCapacity(); + final int actualFlowCapacity = group.getWaterDeliveryCapacity(); for (int y = 0; y <= actualFlowCapacity; y++) { actualFlowCapacitySeries.add(actualInfrastructureEfficiency, y); } RoundConfiguration roundConfiguration = client.getRoundConfiguration(); int maximumInfrastructureEfficiency = roundConfiguration.getMaximumInfrastructureEfficiency(); int waterSupplyCapacity = roundConfiguration.getWaterSupplyCapacity(); - for(int x = 0; x <= maximumInfrastructureEfficiency; x++){ - int flowCapacity = group.calculateFlowCapacity(x); + for (int x = 0; x <= maximumInfrastructureEfficiency; x++) { + int flowCapacity = group.calculateWaterDeliveryCapacity(x); potentialFlowCapacitySeries.add(x,flowCapacity); waterSupplySeries.add(x, waterSupplyCapacity); } @@ -76,14 +76,15 @@ final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(initialInfrastructureEfficiencySeries); + // the second series gets turned blue. + data.addSeries(waterSupplySeries); data.addSeries(actualFlowCapacitySeries); data.addSeries(potentialFlowCapacitySeries); - data.addSeries(waterSupplySeries); final JFreeChart chart = ChartFactory.createXYLineChart( "Water Delivery Capacity vs. Infrastructure Efficiency", - "Infrastructure Efficiency", - "Water Delivery Capacity", + "Infrastructure Efficiency (%)", + "Water Delivery Capacity (cfps)", data, PlotOrientation.VERTICAL, true, Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -124,10 +124,10 @@ private JPanel getMainInterfacePanel() { if(mainInterfacePanel == null){ - scoreBoardLabel = new JLabel("EARNINGS GRAPH"); + scoreBoardLabel = new JLabel(""); scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - gateSwitchLabel = new JLabel("DASHBOARD"); + gateSwitchLabel = new JLabel(""); gateSwitchLabel.setBounds(new Rectangle(13,225+100+35,530,20)); gateSwitchLabel.setHorizontalAlignment(SwingConstants.CENTER); mainInterfacePanel = new JPanel(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -18,7 +18,6 @@ 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.server.ClientData; import edu.asu.commons.irrigation.server.GroupDataModel; import edu.asu.commons.irrigation.server.ServerDataModel; @@ -52,32 +51,28 @@ private JButton showScreenshotButton; - private JButton displayInvestmentButton; +// private JButton displayInvestmentButton; private StringBuilder builder = new StringBuilder(); - private JButton beginExperimentButton; + private JButton overrideButton; /** * This is the default constructor */ public FacilitatorWindow(Facilitator facilitator) { this.facilitator = facilitator; - initGuiComponents(); + initialize(); } - /** - * - * @return void - */ - private void initGuiComponents() { + private void initialize() { setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(getShowInstructionsButton()); - buttonPanel.add(getBeginChatButton()); - buttonPanel.add(getDisplayInvestmentButton()); buttonPanel.add(getShowScreenshotButton()); + buttonPanel.add(getBeginChatButton()); +// buttonPanel.add(getDisplayInvestmentButton()); buttonPanel.add(getStartRoundButton()); buttonPanel.add(getShowQuizButton()); buttonPanel.add(getStartRoundOverrideButton()); @@ -125,28 +120,28 @@ } private JButton getStartRoundOverrideButton() { - if (beginExperimentButton == null) { - beginExperimentButton = new JButton("Override"); - beginExperimentButton.addActionListener(new ActionListener() { + if (overrideButton == null) { + overrideButton = new JButton("Override"); + overrideButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { facilitator.sendStartRoundOverride(); } }); } - return beginExperimentButton; + return overrideButton; } - private JButton getDisplayInvestmentButton() { - if (displayInvestmentButton == null) { - displayInvestmentButton = new JButton("Show Investment Screen"); - displayInvestmentButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - facilitator.transmit(new ShowTokenInvestmentScreenRequest(facilitator.getId())); - } - }); - } - return displayInvestmentButton; - } +// private JButton getDisplayInvestmentButton() { +// if (displayInvestmentButton == null) { +// displayInvestmentButton = new JButton("Show Investment Screen"); +// displayInvestmentButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent event) { +// facilitator.transmit(new ShowTokenInvestmentScreenRequest(facilitator.getId())); +// } +// }); +// } +// return displayInvestmentButton; +// } public Facilitator getFacilitator() { return facilitator; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -96,7 +96,7 @@ totalContributedTokens += clientData.getInvestedTokens(); } updateInfrastructureEfficiency(totalContributedTokens); - currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualFlowCapacity(); + currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualWaterDeliveryCapacity(); } private void updateInfrastructureEfficiency(int totalContributedTokens) { @@ -124,7 +124,7 @@ * @param totalTokens * @return */ - public int calculateFlowCapacity(final int infrastructureEfficiency) { + public int calculateWaterDeliveryCapacity(final int infrastructureEfficiency) { if (infrastructureEfficiency <= 45) { return 0; } @@ -157,15 +157,15 @@ public int getIrrigationCapacityBeforeInvestment() { // return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); - return calculateFlowCapacity(infrastructureEfficiencyBeforeInvestment); + return calculateWaterDeliveryCapacity(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 calculateFlowCapacity(infrastructureEfficiency); + public int getWaterDeliveryCapacity() { + return calculateWaterDeliveryCapacity(infrastructureEfficiency); // return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); } @@ -174,8 +174,8 @@ * of the irrigation capacity and the water supply. * @return */ - public int getActualFlowCapacity() { - return Math.min(getIrrigationCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); + public int getActualWaterDeliveryCapacity() { + return Math.min(getWaterDeliveryCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); } public void resetCurrentlyAvailableFlowCapacity() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-18 07:15:18
|
Revision: 367 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=367&view=rev Author: alllee Date: 2009-11-18 07:15:06 +0000 (Wed, 18 Nov 2009) Log Message: ----------- adding updated screenshot and trying to fix lag in displaying first chat message by "warming up" the interface with an initial message at the start of each round (also serves as a chat round demarcation) Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java Added Paths: ----------- irrigation/trunk/src/main/resources/images/irrigation-game-interface-screenshot.png Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-17 01:31:57 UTC (rev 366) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-18 07:15:06 UTC (rev 367) @@ -101,8 +101,7 @@ message); chatField.setText(""); irrigationClient.transmit(new ChatRequest(getClientId(), message, targetIdentifier)); - - } + } chatField.requestFocusInWindow(); } @@ -164,7 +163,7 @@ add(textEntryPanel, BorderLayout.PAGE_END); } - private void displayMessage(String chatHandle, String message) { + public void displayMessage(String chatHandle, String message) { // String chatHandle = getChatHandle(source); final StyledDocument document = messageWindow.getStyledDocument(); try { @@ -188,6 +187,7 @@ HANDLES[i] = " " + HANDLE_STRING.charAt(i) + " "; chatHandles.put(participants.get(i), HANDLES[i]); } + displayMessage("", " ---- chat round starting ---- "); } public Identifier getClientId() { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-17 01:31:57 UTC (rev 366) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-18 07:15:06 UTC (rev 367) @@ -97,9 +97,10 @@ public ExperimentGameWindow(IrrigationClient client) { this.client = client; this.clientDataModel = client.getClientDataModel(); + initialize(); } - void initialize() { + private void initialize() { cardLayout = new CardLayout(); setLayout(cardLayout); addToCardLayout(getInstructionsPanel()); @@ -121,7 +122,6 @@ tokenInvestmentPanel.setName("Token investment panel"); tokenInvestmentPanel.setLayout(new BorderLayout()); tokenInstructionsEditorPane = createInstructionsEditorPane(); - tokenInstructionsEditorPane.setCaretPosition(0); JScrollPane tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); tokenInvestmentPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); tokenInvestmentPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); @@ -201,7 +201,7 @@ public void actionPerformed(ActionEvent e) { previousButton.setEnabled(true); currentQuizPageNumber++; - if (currentQuizPageNumber < getServerConfiguration().getNumberOfQuestionPages()) { + if (currentQuizPageNumber <= getServerConfiguration().getNumberOfQuizPages()) { setInstructions(getQuizPage()); } else { @@ -286,7 +286,6 @@ instructionsEditorPane.setName("Instructions editor pane"); // create a quiz listener and then initialize the instructions. instructionsEditorPane.setActionListener(createQuizListener(getServerConfiguration())); - instructionsEditorPane.setCaretPosition(0); } return instructionsEditorPane; } @@ -456,7 +455,7 @@ quizPageResponses.put(currentQuizPageNumber, builder.toString()); // no matter what we move on to the next question page // tell them what was right and what was wrong. - if (currentQuizPageNumber <= getServerConfiguration().getNumberOfQuestionPages()) { + if (currentQuizPageNumber <= getServerConfiguration().getNumberOfQuizPages()) { nextButton.setEnabled(true); } quizzesAnswered++; @@ -595,7 +594,7 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { startTimer(getServerConfiguration().getChatDuration() * 1000L); - ChatPanel chatPanel = getChatPanel(); +// ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(clientDataModel.getAllClientIdentifiers()); addCenterComponent( chatPanel ); chatPanel.setFocusInChatField(); @@ -613,6 +612,7 @@ if (timeRemaining < 0) { showTokenInvestmentScreen(); getInvestedTokensTextField().requestFocusInWindow(); +// chatPanel.displayMessage("", "---- chat round ending ----"); timer.stop(); timer = null; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-11-17 01:31:57 UTC (rev 366) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-11-18 07:15:06 UTC (rev 367) @@ -71,9 +71,8 @@ } private void initialize() { - clientDataModel = new ClientDataModel(channel, this); + clientDataModel = new ClientDataModel(channel, this); experimentGameWindow = new ExperimentGameWindow(this); - experimentGameWindow.initialize(); connect(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-17 01:31:57 UTC (rev 366) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-18 07:15:06 UTC (rev 367) @@ -130,7 +130,7 @@ return assistant.getProperty("investment-instructions"); } - public int getNumberOfQuestionPages() { + public int getNumberOfQuizPages() { return assistant.getIntProperty("question-pages", 2); } Added: irrigation/trunk/src/main/resources/images/irrigation-game-interface-screenshot.png =================================================================== (Binary files differ) Property changes on: irrigation/trunk/src/main/resources/images/irrigation-game-interface-screenshot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-17 01:32:07
|
Revision: 366 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=366&view=rev Author: alllee Date: 2009-11-17 01:31:57 +0000 (Tue, 17 Nov 2009) Log Message: ----------- fixing NPE in instructions Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-17 00:42:32 UTC (rev 365) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-17 01:31:57 UTC (rev 366) @@ -102,14 +102,13 @@ void initialize() { cardLayout = new CardLayout(); setLayout(cardLayout); - setInstructions(getServerConfiguration().getWelcomeInstructions()); addToCardLayout(getInstructionsPanel()); -// irrigationGamePanel = new IrrigationGamePanel(client); irrigationGamePanel = new MainIrrigationGameWindow(client); addToCardLayout(irrigationGamePanel); addToCardLayout(getTokenInvestmentPanel()); addToCardLayout(getChatPanel()); addToCardLayout(getContributionInformationPanel()); + setInstructions(getServerConfiguration().getWelcomeInstructions()); } private void addToCardLayout(Component component) { @@ -201,15 +200,13 @@ nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { previousButton.setEnabled(true); - if (currentQuizPageNumber >= quizzesAnswered){ - nextButton.setEnabled(false); - } + currentQuizPageNumber++; if (currentQuizPageNumber < getServerConfiguration().getNumberOfQuestionPages()) { - currentQuizPageNumber++; setInstructions(getQuizPage()); } else { setInstructions(instructionsBuilder.toString()); + nextButton.setEnabled(false); } } }); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-17 00:42:32 UTC (rev 365) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-17 01:31:57 UTC (rev 366) @@ -124,14 +124,12 @@ private JPanel getMainInterfacePanel() { if(mainInterfacePanel == null){ - scoreBoardLabel = new JLabel(); + scoreBoardLabel = new JLabel("EARNINGS GRAPH"); scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - scoreBoardLabel.setText("WATER COLLECTED TO TOKENS EARNED TABLE"); - gateSwitchLabel = new JLabel(); + gateSwitchLabel = new JLabel("DASHBOARD"); gateSwitchLabel.setBounds(new Rectangle(13,225+100+35,530,20)); gateSwitchLabel.setHorizontalAlignment(SwingConstants.CENTER); - gateSwitchLabel.setText("DASHBOARD"); mainInterfacePanel = new JPanel(); mainInterfacePanel.setLayout(null); mainInterfacePanel.setName("Main interface panel"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |