virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 55)
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: Kalin J. <kj...@as...> - 2010-01-13 23:47:18
|
checking out at 16:45pm (3.5hr) Working on resolving communication problem. the messages are being sent to the server, just not pushed back to all clients. On 1/13/10, Kalin Jonas <kj...@as...> wrote: > coming in to work today at 13:15 pm > I'm still trying to get the laptop at home set up for working in flex. > also working on fixing the errors that I left behind yesterday > > On 1/12/10, Kalin Jonas <kj...@as...> wrote: >> Leaving at 16:15(1.5hr) >> worked with seema on the communication problem, making headway >> must fix problem - communication component does not keep track of student >> yet. >> >> On Tue, Jan 12, 2010 at 2:47 PM, Kalin Jonas <kj...@as...> wrote: >> >>> Returning at 14:45 >>> working on second laptop via remote desktop to set it up for flex work. >>> >>> >>> On Tue, Jan 12, 2010 at 2:15 PM, Kalin Jonas <kj...@as...> wrote: >>> >>>> checking out for lunch at 14:15pm (4hr) >>>> linux trial has expired, and therefore no progress has been made. >>>> working >>>> on another computer to try and set it up for use. >>>> >>>> >>>> On Tue, Jan 12, 2010 at 10:10 AM, Kalin Jonas <kj...@as...> wrote: >>>> >>>>> Coming in to work today at 10:15am. >>>>> I will be working on the new Strategy Design component as Seema and I >>>>> discussed: it will have only one list of actions (repeated) and I will >>>>> be >>>>> removing the SuspendRepetition functionality. >>>>> I will begin by backing up the old component now. >>>>> >>>> >>>> >>> >> > |
From: Allen L. (JIRA) <jef...@as...> - 2010-01-13 23:44:22
|
[ http://opensource.asu.edu/jira/browse/COMMONS-10?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved COMMONS-10. ------------------------------ Resolution: Fixed Implemented. > save file conversion > -------------------- > > Key: COMMONS-10 > URL: http://opensource.asu.edu/jira/browse/COMMONS-10 > Project: The Virtual Commons > Issue Type: Task > Components: foraging > Reporter: Allen Lee > Assignee: Allen Lee > > Improve save file conversion, provide time interval (default: 60 s) aggregated statistics for movement, tokens collected, and number of neighboring tokens around a collected token. -- 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: Kalin J. <kj...@as...> - 2010-01-13 20:21:48
|
coming in to work today at 13:15 pm I'm still trying to get the laptop at home set up for working in flex. also working on fixing the errors that I left behind yesterday On 1/12/10, Kalin Jonas <kj...@as...> wrote: > Leaving at 16:15(1.5hr) > worked with seema on the communication problem, making headway > must fix problem - communication component does not keep track of student > yet. > > On Tue, Jan 12, 2010 at 2:47 PM, Kalin Jonas <kj...@as...> wrote: > >> Returning at 14:45 >> working on second laptop via remote desktop to set it up for flex work. >> >> >> On Tue, Jan 12, 2010 at 2:15 PM, Kalin Jonas <kj...@as...> wrote: >> >>> checking out for lunch at 14:15pm (4hr) >>> linux trial has expired, and therefore no progress has been made. >>> working >>> on another computer to try and set it up for use. >>> >>> >>> On Tue, Jan 12, 2010 at 10:10 AM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Coming in to work today at 10:15am. >>>> I will be working on the new Strategy Design component as Seema and I >>>> discussed: it will have only one list of actions (repeated) and I will >>>> be >>>> removing the SuspendRepetition functionality. >>>> I will begin by backing up the old component now. >>>> >>> >>> >> > |
From: Kalin J. <kj...@as...> - 2010-01-12 23:21:20
|
Leaving at 16:15(1.5hr) worked with seema on the communication problem, making headway must fix problem - communication component does not keep track of student yet. On Tue, Jan 12, 2010 at 2:47 PM, Kalin Jonas <kj...@as...> wrote: > Returning at 14:45 > working on second laptop via remote desktop to set it up for flex work. > > > On Tue, Jan 12, 2010 at 2:15 PM, Kalin Jonas <kj...@as...> wrote: > >> checking out for lunch at 14:15pm (4hr) >> linux trial has expired, and therefore no progress has been made. working >> on another computer to try and set it up for use. >> >> >> On Tue, Jan 12, 2010 at 10:10 AM, Kalin Jonas <kj...@as...> wrote: >> >>> Coming in to work today at 10:15am. >>> I will be working on the new Strategy Design component as Seema and I >>> discussed: it will have only one list of actions (repeated) and I will be >>> removing the SuspendRepetition functionality. >>> I will begin by backing up the old component now. >>> >> >> > |
From: Kalin J. <kj...@as...> - 2010-01-12 21:47:28
|
Returning at 14:45 working on second laptop via remote desktop to set it up for flex work. On Tue, Jan 12, 2010 at 2:15 PM, Kalin Jonas <kj...@as...> wrote: > checking out for lunch at 14:15pm (4hr) > linux trial has expired, and therefore no progress has been made. working > on another computer to try and set it up for use. > > > On Tue, Jan 12, 2010 at 10:10 AM, Kalin Jonas <kj...@as...> wrote: > >> Coming in to work today at 10:15am. >> I will be working on the new Strategy Design component as Seema and I >> discussed: it will have only one list of actions (repeated) and I will be >> removing the SuspendRepetition functionality. >> I will begin by backing up the old component now. >> > > |
From: <see...@us...> - 2010-01-12 21:42:54
|
Revision: 427 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=427&view=rev Author: seematalele Date: 2010-01-12 21:42:47 +0000 (Tue, 12 Jan 2010) Log Message: ----------- 1) Added communication question with question type = "communication"for communication round in init-mme.sql so that flex can use it for displaying communication component. 2) Error was coming while creating game, resolved that error. Now it is working fine. 3)Conflict resolution of CommunicationC.mxml. Bugs - 1) MessageHanlder is trying run timer for communication round. But getting error - "(JDBCExceptionReporter.java:101) ERROR org.hibernate.util.JDBCExceptionReporter - Lock wait timeout exceeded; try restarting transaction." Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java Modified: mentalmodels/trunk/flex/src/custom/CommunicationC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2010-01-07 05:17:04 UTC (rev 426) +++ mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2010-01-12 21:42:47 UTC (rev 427) @@ -72,6 +72,8 @@ <mx:method name="sendCommunication" result="messageHandler(event)"/> </mx:RemoteObject> + + <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> <mx:HBox> <mx:TextInput id="txtMessage" width="500"/> Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2010-01-07 05:17:04 UTC (rev 426) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2010-01-12 21:42:47 UTC (rev 427) @@ -4,10 +4,6 @@ -- ------------------------------------------------------ -- Server version 5.1.33-community --- This file contains the refactored MME database. Foolowing records have been removed : - -- Forecasting questions - -- Blocks with "Editing strategy" description and their corresponding question groups, infromation windows and questions - /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; @@ -646,7 +642,7 @@ PRIMARY KEY (`id`), KEY `FKBA823BE6CA626674` (`question_group_id`), CONSTRAINT `FKBA823BE6CA626674` FOREIGN KEY (`question_group_id`) REFERENCES `question_group` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=154 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=156 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -655,7 +651,7 @@ LOCK TABLES `question` WRITE; /*!40000 ALTER TABLE `question` DISABLE KEYS */; -INSERT INTO `question` VALUES (1,0,'Most important goal:',1,'categorical',10),(2,0,'Second most important goal:',2,'categorical',10),(3,0,'Third most important goal:',4,'categorical',10),(4,0,'Compared to the most important goal, this goal is',3,'psychometric',10),(7,0,'An example of a scale would be',1,'psychometric',11),(8,0,'<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r',1,'text',12),(9,0,'Compared to the most important goal, this goal is',5,'psychometric',10),(10,0,'<b>Most important goal:</b>',1,'categorical',13),(11,0,'<b>Second most important goal:</b>',2,'categorical',13),(12,0,'Compared to the most important goal, this goal is',3,'psychometric',13),(13,0,'<b>Third most important goal:</b>',4,'categorical',13),(14,0,'Compared to the most important goal, this goal is',5,'psychometric',13),(15,0,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',14),(16,0,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',14),(17,0,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',14),(18,0,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',14),(19,0,'Do you perceive the group as a team or as competing players?',5,'psychometric',14),(20,0,'How much do you trust the others in your group?',1,'psychometric',15),(21,0,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',15),(22,0,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',15),(23,1,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',15),(24,1,'How much do you think <i>the others</i> are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',15),(25,0,'Do you feel a sense of ‘commitment’ to act in the way you specified in your strategy?',1,'psychometric',16),(26,0,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',16),(27,0,'Do you feel any sort of ‘social pressure’ to act in the way you specified in your strategy?',3,'psychometric',16),(28,0,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',16),(29,0,'Are you afraid of some sort of ‘punishment’ if you had acted differently as specified in your strategy?',5,'psychometric',16),(30,0,'How well did you understand the dynamics of the fish population?',1,'psychometric',17),(31,0,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',17),(32,0,'How confident are you in having developed a strategy that leads to ‘good’ outcomes regarding your goals?',3,'psychometric',17),(33,0,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',17),(34,0,'Would you classify your strategy as ‘safe’ in the sense of having acceptable but suboptimal results for sure, or rather as ‘risky’ in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',17),(37,0,'',1,'strategydesign',9),(39,0,'',1,'daybydaydecisions',24),(40,0,'',1,'psychometric',27),(41,0,'… better understand the dynamics of the fish population.',1,'psychometric',29),(42,0,'… better understand the other fishermen in my group.',2,'psychometric',29),(43,0,'… better understand how to design the strategy.',3,'psychometric',29),(44,0,'… feel a ‘team spirit’ in the group.',4,'psychometric',29),(45,0,'… appraise the other fishermen in my group differently. Now I think about the others…',5,'psychometric',29),(46,0,'… better understand the dynamics of the fish population.',1,'psychometric',30),(47,0,'… better understand the other fishermen.',2,'psychometric',30),(48,0,'… better understand how to design the strategy.',3,'psychometric',30),(49,0,'… feel a ‘team spirit’ in the group.',4,'psychometric',30),(50,0,'… appraise the other fishermen in my group differently. Now I think about the others …',5,'psychometric',30),(51,0,'Did the communication have any form of reference to how to fish or design the strategy?',1,'categorical',31),(54,0,'',1,'psychometric',32),(55,0,'',2,'psychometric',32),(56,0,'',3,'psychometric',32),(57,0,'',4,'psychometric',32),(58,0,'',5,'psychometric',32),(59,0,'How clear is it to you, that you have to fish conforming to this rule, agreement or coordination attempt?',1,'psychometric',33),(60,0,'Do you think the other fishermen understood how they have to act according to this rule?<br>I think the others… ',2,'psychometric',33),(61,0,'Will you follow the rule, agreement, or coordination attempt that emerged from communication?<br>I will follow the rule…',3,'psychometric',33),(62,0,'Do you think, the other fishermen in you group will follow the rule, agreement, or coordination attempt?<br>\rI think, the others will… ',4,'psychometric',33),(63,0,'Considering the effects you expect for following the rule and your expectations of how the group will follow the rule, do you think the group will do better or worse due to the rule?',5,'psychometric',33),(64,0,'New understanding of fish dynamics',1,'text',34),(65,0,'New Expectations on how the others of the group will act',2,'text',34),(66,0,'Ideas for improving your strategy',3,'text',34),(67,0,'How interesting was the experiment for you?',1,'psychometric',35),(68,0,'How would you rate the effort you invested to design your strategy?',2,'psychometric',35),(69,0,'How difficult was it to understand the problem?',3,'psychometric',35),(70,0,'How difficult was it to find a good strategy?',4,'psychometric',35),(71,0,'How clear was it what you had to do?',5,'psychometric',35),(72,0,'How many times have you participated in problem solving experiments similar to this one?',1,'text',36),(73,0,'If you already participated in such experiments, when was the last time?',2,'categorical',36),(74,0,'Comments and Feedback',1,'text',37),(75,0,'',1,'strategydesign',40),(77,0,'',1,'daybydaydecisions',55),(78,0,'',1,'psychometric',58),(79,0,'',2,'psychometric',27),(80,0,'I feel the outcomes are:',3,'psychometric',27),(81,0,'',1,'psychometric',59),(82,0,'',2,'psychometric',59),(83,0,'',3,'psychometric',59),(84,0,'',4,'psychometric',59),(85,0,'',5,'psychometric',59),(86,0,'I did not understand the dynamics of the fish population well enough.',1,'psychometric',60),(87,0,'Some of the other fishermen did not understand the dynamics of the fish population well enough.',2,'psychometric',60),(88,0,'The actions of the others in my group did not help my strategy work well.',3,'psychometric',60),(89,0,'Some of the other fishermen acted too reluctantly (harvested too few).',4,'psychometric',60),(90,0,'Some of the other fishermen acted too aggressively (harvested too much).',5,'psychometric',60),(91,0,'The group was too uncoordinated',6,'psychometric',60),(92,0,'The group did not follow the rules or agreements that emerged from the communication enough.',7,'psychometric',60),(93,0,'The rules or agreements that emerged from the communication did not work out well.',8,'psychometric',60),(94,0,'What were the most important reasons for you to deviate from your strategy during the day-by-day decisions?<br>\rIf you did not deviate from your strategy then please write something like \"No difference\" in the text field.',1,'text',61),(95,0,'New understanding of fish dynamics',1,'text',62),(96,0,'New expectations on how the others of the group will act',2,'text',62),(97,0,'Ideas for improving your strategy',3,'text',62),(98,0,'',2,'psychometric',58),(99,0,'I feel the outcomes are:',3,'psychometric',58),(100,0,'',1,'psychometric',63),(101,0,'',2,'psychometric',63),(102,0,'',3,'psychometric',63),(103,0,'',4,'psychometric',63),(104,0,'',5,'psychometric',63),(105,0,'I did not understand the dynamics of the fish population well enough.',1,'psychometric',64),(106,0,'Some of the other fishermen did not understand the dynamics of the fish population well enough',2,'psychometric',64),(107,0,'The actions of the others in my group did not help my strategy work well.',3,'psychometric',64),(108,0,'Some of the other fishermen acted too reluctantly (harvested too few).',4,'psychometric',64),(109,0,'Some of the other fishermen acted too aggressively (harvested too much).',5,'psychometric',64),(110,0,'The group was too uncoordinated',6,'psychometric',64),(111,0,'The group did not follow the rules or agreements that emerged from the communication enough.',7,'psychometric',64),(112,0,'The rules or agreements that emerged from the communication did not work out well.',8,'psychometric',64),(113,0,'What were the most important reasons for you to deviate from your strategy during the day-by-day decisions?<br>\rIf you did not deviate from your strategy then please write something like \"No difference\" in the text field.',1,'text',65),(114,0,'New understanding of fish dynamics',1,'text',66),(115,0,'New expectations on how the others of the group will act',2,'text',66),(116,0,'Ideas for improving your strategy',3,'text',66),(117,0,'Describe in your own words what the rule, agreement, or other coordination attempt states. Describe how you and the others should act and what would happen if one does not act in this way.<br>\rIf you cannot identify any sort of coordination attempt in the communication, write \"no coordination\" in the field below.<br>\r(The information you write in this field will be available the next time you edit your strategy.)',2,'text',31),(118,0,'How often do you play strategy games (i.e. any games where you have to anticipate the moves of other players and plan your own moves ahead, like computer games, card games, board games, etc)?',3,'categorical',36),(120,0,'<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r',1,'text',42),(121,0,'Most important goal:',1,'categorical',43),(122,0,'Second most important goal:',2,'categorical',43),(123,0,'Compared to the most important goal, this goal is',3,'psychometric',43),(124,0,'Third most important goal:',4,'categorical',43),(125,0,'Compared to the most important goal, this goal is',5,'psychometric',43),(126,0,'<b>Most important goal:</b>',1,'categorical',44),(127,0,'<b>Second most important goal:</b>',2,'categorical',44),(128,0,'Compared to the most important goal, this goal is',3,'psychometric',44),(129,0,'<b>Third most important goal:</b>',4,'categorical',44),(130,0,'Compared to the most important goal, this goal is',5,'psychometric',44),(131,0,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',45),(132,0,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',45),(133,0,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',45),(134,0,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',45),(135,0,'Do you perceive the group as a team or as competing players?',5,'psychometric',45),(136,0,'How much do you trust the others in your group?',1,'psychometric',46),(137,0,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',46),(138,0,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',46),(139,0,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',46),(140,0,'How much do you think <i>the others</i> are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',46),(141,0,'Do you feel a sense of ‘commitment’ to act in the way you specified in your strategy?',1,'psychometric',47),(142,0,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',47),(143,0,'Do you feel any sort of ‘social pressure’ to act in the way you specified in your strategy?',3,'psychometric',47),(144,0,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',47),(145,0,'Are you afraid of some sort of ‘punishment’ if you had acted differently as specified in your strategy?',5,'psychometric',47),(146,0,'How well did you understand the dynamics of the fish population?',1,'psychometric',48),(147,0,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',48),(148,0,'How confident are you in having developed a strategy that leads to ‘good’ outcomes regarding your goals?',3,'psychometric',48),(149,0,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',48),(150,0,'Would you classify your strategy as ‘safe’ in the sense of having acceptable but suboptimal results for sure, or rather as ‘risky’ in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',48),(153,0,'',1,'daybydaydecisions',67); +INSERT INTO `question` VALUES (1,0,'Most important goal:',1,'categorical',10),(2,0,'Second most important goal:',2,'categorical',10),(3,0,'Third most important goal:',4,'categorical',10),(4,0,'Compared to the most important goal, this goal is',3,'psychometric',10),(7,0,'An example of a scale would be',1,'psychometric',11),(8,0,'<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r',1,'text',12),(9,0,'Compared to the most important goal, this goal is',5,'psychometric',10),(10,0,'<b>Most important goal:</b>',1,'categorical',13),(11,0,'<b>Second most important goal:</b>',2,'categorical',13),(12,0,'Compared to the most important goal, this goal is',3,'psychometric',13),(13,0,'<b>Third most important goal:</b>',4,'categorical',13),(14,0,'Compared to the most important goal, this goal is',5,'psychometric',13),(15,0,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',14),(16,0,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',14),(17,0,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',14),(18,0,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',14),(19,0,'Do you perceive the group as a team or as competing players?',5,'psychometric',14),(20,0,'How much do you trust the others in your group?',1,'psychometric',15),(21,0,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',15),(22,0,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',15),(23,1,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',15),(24,1,'How much do you think <i>the others</i> are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',15),(25,0,'Do you feel a sense of ‘commitment’ to act in the way you specified in your strategy?',1,'psychometric',16),(26,0,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',16),(27,0,'Do you feel any sort of ‘social pressure’ to act in the way you specified in your strategy?',3,'psychometric',16),(28,0,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',16),(29,0,'Are you afraid of some sort of ‘punishment’ if you had acted differently as specified in your strategy?',5,'psychometric',16),(30,0,'How well did you understand the dynamics of the fish population?',1,'psychometric',17),(31,0,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',17),(32,0,'How confident are you in having developed a strategy that leads to ‘good’ outcomes regarding your goals?',3,'psychometric',17),(33,0,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',17),(34,0,'Would you classify your strategy as ‘safe’ in the sense of having acceptable but suboptimal results for sure, or rather as ‘risky’ in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',17),(37,0,'',1,'daybydaydecisions',9),(39,0,'',1,'daybydaydecisions',24),(40,0,'',1,'psychometric',27),(41,0,'… better understand the dynamics of the fish population.',1,'psychometric',29),(42,0,'… better understand the other fishermen in my group.',2,'psychometric',29),(43,0,'… better understand how to design the strategy.',3,'psychometric',29),(44,0,'… feel a ‘team spirit’ in the group.',4,'psychometric',29),(45,0,'… appraise the other fishermen in my group differently. Now I think about the others…',5,'psychometric',29),(46,0,'… better understand the dynamics of the fish population.',1,'psychometric',30),(47,0,'… better understand the other fishermen.',2,'psychometric',30),(48,0,'… better understand how to design the strategy.',3,'psychometric',30),(49,0,'… feel a ‘team spirit’ in the group.',4,'psychometric',30),(50,0,'… appraise the other fishermen in my group differently. Now I think about the others …',5,'psychometric',30),(51,0,'Did the communication have any form of reference to how to fish or design the strategy?',1,'categorical',31),(54,0,'',1,'psychometric',32),(55,0,'',2,'psychometric',32),(56,0,'',3,'psychometric',32),(57,0,'',4,'psychometric',32),(58,0,'',5,'psychometric',32),(59,0,'How clear is it to you, that you have to fish conforming to this rule, agreement or coordination attempt?',1,'psychometric',33),(60,0,'Do you think the other fishermen understood how they have to act according to this rule?<br>I think the others… ',2,'psychometric',33),(61,0,'Will you follow the rule, agreement, or coordination attempt that emerged from communication?<br>I will follow the rule…',3,'psychometric',33),(62,0,'Do you think, the other fishermen in you group will follow the rule, agreement, or coordination attempt?<br>\rI think, the others will… ',4,'psychometric',33),(63,0,'Considering the effects you expect for following the rule and your expectations of how the group will follow the rule, do you think the group will do better or worse due to the rule?',5,'psychometric',33),(64,0,'New understanding of fish dynamics',1,'text',34),(65,0,'New Expectations on how the others of the group will act',2,'text',34),(66,0,'Ideas for improving your strategy',3,'text',34),(67,0,'How interesting was the experiment for you?',1,'psychometric',35),(68,0,'How would you rate the effort you invested to design your strategy?',2,'psychometric',35),(69,0,'How difficult was it to understand the problem?',3,'psychometric',35),(70,0,'How difficult was it to find a good strategy?',4,'psychometric',35),(71,0,'How clear was it what you had to do?',5,'psychometric',35),(72,0,'How many times have you participated in problem solving experiments similar to this one?',1,'text',36),(73,0,'If you already participated in such experiments, when was the last time?',2,'categorical',36),(74,0,'Comments and Feedback',1,'text',37),(75,0,'',1,'daybydaydecisions',40),(77,0,'',1,'daybydaydecisions',55),(78,0,'',1,'psychometric',58),(79,0,'',2,'psychometric',27),(80,0,'I feel the outcomes are:',3,'psychometric',27),(81,0,'',1,'psychometric',59),(82,0,'',2,'psychometric',59),(83,0,'',3,'psychometric',59),(84,0,'',4,'psychometric',59),(85,0,'',5,'psychometric',59),(86,0,'I did not understand the dynamics of the fish population well enough.',1,'psychometric',60),(87,0,'Some of the other fishermen did not understand the dynamics of the fish population well enough.',2,'psychometric',60),(88,0,'The actions of the others in my group did not help my strategy work well.',3,'psychometric',60),(89,0,'Some of the other fishermen acted too reluctantly (harvested too few).',4,'psychometric',60),(90,0,'Some of the other fishermen acted too aggressively (harvested too much).',5,'psychometric',60),(91,0,'The group was too uncoordinated',6,'psychometric',60),(92,0,'The group did not follow the rules or agreements that emerged from the communication enough.',7,'psychometric',60),(93,0,'The rules or agreements that emerged from the communication did not work out well.',8,'psychometric',60),(94,0,'What were the most important reasons for you to deviate from your strategy during the day-by-day decisions?<br>\rIf you did not deviate from your strategy then please write something like \"No difference\" in the text field.',1,'text',61),(95,0,'New understanding of fish dynamics',1,'text',62),(96,0,'New expectations on how the others of the group will act',2,'text',62),(97,0,'Ideas for improving your strategy',3,'text',62),(98,0,'',2,'psychometric',58),(99,0,'I feel the outcomes are:',3,'psychometric',58),(100,0,'',1,'psychometric',63),(101,0,'',2,'psychometric',63),(102,0,'',3,'psychometric',63),(103,0,'',4,'psychometric',63),(104,0,'',5,'psychometric',63),(105,0,'I did not understand the dynamics of the fish population well enough.',1,'psychometric',64),(106,0,'Some of the other fishermen did not understand the dynamics of the fish population well enough',2,'psychometric',64),(107,0,'The actions of the others in my group did not help my strategy work well.',3,'psychometric',64),(108,0,'Some of the other fishermen acted too reluctantly (harvested too few).',4,'psychometric',64),(109,0,'Some of the other fishermen acted too aggressively (harvested too much).',5,'psychometric',64),(110,0,'The group was too uncoordinated',6,'psychometric',64),(111,0,'The group did not follow the rules or agreements that emerged from the communication enough.',7,'psychometric',64),(112,0,'The rules or agreements that emerged from the communication did not work out well.',8,'psychometric',64),(113,0,'What were the most important reasons for you to deviate from your strategy during the day-by-day decisions?<br>\rIf you did not deviate from your strategy then please write something like \"No difference\" in the text field.',1,'text',65),(114,0,'New understanding of fish dynamics',1,'text',66),(115,0,'New expectations on how the others of the group will act',2,'text',66),(116,0,'Ideas for improving your strategy',3,'text',66),(117,0,'Describe in your own words what the rule, agreement, or other coordination attempt states. Describe how you and the others should act and what would happen if one does not act in this way.<br>\rIf you cannot identify any sort of coordination attempt in the communication, write \"no coordination\" in the field below.<br>\r(The information you write in this field will be available the next time you edit your strategy.)',2,'text',31),(118,0,'How often do you play strategy games (i.e. any games where you have to anticipate the moves of other players and plan your own moves ahead, like computer games, card games, board games, etc)?',3,'categorical',36),(120,0,'<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r',1,'text',42),(121,0,'Most important goal:',1,'categorical',43),(122,0,'Second most important goal:',2,'categorical',43),(123,0,'Compared to the most important goal, this goal is',3,'psychometric',43),(124,0,'Third most important goal:',4,'categorical',43),(125,0,'Compared to the most important goal, this goal is',5,'psychometric',43),(126,0,'<b>Most important goal:</b>',1,'categorical',44),(127,0,'<b>Second most important goal:</b>',2,'categorical',44),(128,0,'Compared to the most important goal, this goal is',3,'psychometric',44),(129,0,'<b>Third most important goal:</b>',4,'categorical',44),(130,0,'Compared to the most important goal, this goal is',5,'psychometric',44),(131,0,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',45),(132,0,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',45),(133,0,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',45),(134,0,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',45),(135,0,'Do you perceive the group as a team or as competing players?',5,'psychometric',45),(136,0,'How much do you trust the others in your group?',1,'psychometric',46),(137,0,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',46),(138,0,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',46),(139,0,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',46),(140,0,'How much do you think <i>the others</i> are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',46),(141,0,'Do you feel a sense of ‘commitment’ to act in the way you specified in your strategy?',1,'psychometric',47),(142,0,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',47),(143,0,'Do you feel any sort of ‘social pressure’ to act in the way you specified in your strategy?',3,'psychometric',47),(144,0,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',47),(145,0,'Are you afraid of some sort of ‘punishment’ if you had acted differently as specified in your strategy?',5,'psychometric',47),(146,0,'How well did you understand the dynamics of the fish population?',1,'psychometric',48),(147,0,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',48),(148,0,'How confident are you in having developed a strategy that leads to ‘good’ outcomes regarding your goals?',3,'psychometric',48),(149,0,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',48),(150,0,'Would you classify your strategy as ‘safe’ in the sense of having acceptable but suboptimal results for sure, or rather as ‘risky’ in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',48),(153,0,'',1,'daybydaydecisions',67),(155,1,'',1,'communication',28); /*!40000 ALTER TABLE `question` ENABLE KEYS */; UNLOCK TABLES; @@ -910,4 +906,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-11-30 19:23:38 +-- Dump completed on 2010-01-12 21:34:16 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 2010-01-07 05:17:04 UTC (rev 426) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2010-01-12 21:42:47 UTC (rev 427) @@ -58,14 +58,14 @@ private int blockSeqNo; - + MessageHandler msgHandler; - + static final String roundNo = "SELECT gameRound.seqNo " + - "FROM GameRound gameRound, Game game " + - "where gameRound.gameConfig =:gameConfig and gameRound.round =:currentRound"; - - + "FROM GameRound gameRound, Game game " + + "where gameRound.gameConfig =:gameConfig and gameRound.round =:currentRound"; + + public GameService() { } @@ -94,41 +94,41 @@ public Game createGame(Game game) { - //getLogger().debug("game came from flex is : " + game.getGameCode()); + //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()); + 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); - getDao().save(newGame); - String str = newGame.getGameCode()+newGame.getId(); + //FIXME: Currently using default GameConfiguration whose id is 1 + GameConfig gameConfig = gameConfigDao.find(1L); + newGame.setGameConfig(gameConfig); + getDao().save(newGame); + String str = newGame.getGameCode()+newGame.getId(); - if(getDao().findAllByProperty("gameCode", str).size() != 0) - { - //getLogger().debug("in if loop "); - newGame = null; - } - else - { - newGame.setGameCode(str); - getDao().save(newGame); - getLogger().info("Created the game: " + newGame.getId()); - //setAllLocations(gameConfig); - initializeGame(newGame); - } - }catch(Exception e) - { - e.printStackTrace(); - } - getLogger().debug("current game from flex is: " + newGame.getId()); - return newGame; + if(getDao().findAllByProperty("gameCode", str).size() != 0) + { + //getLogger().debug("in if loop "); + newGame = null; + } + else + { + newGame.setGameCode(str); + getDao().save(newGame); + getLogger().info("Created the game: " + newGame.getId()); + //setAllLocations(gameConfig); + initializeGame(newGame); + } + }catch(Exception e) + { + e.printStackTrace(); + } + getLogger().debug("current game from flex is: " + newGame.getId()); + return newGame; } @@ -144,7 +144,7 @@ public boolean startGame(Game game) { boolean flag = false; - + if(isSufficientStudents(game)) { assignGroups(game); @@ -156,7 +156,7 @@ { flag = false; } - + return flag; } @@ -167,7 +167,7 @@ Game currentGame = getDao().find(game.getId()); if(getStudentDao().findAllByProperty("game", currentGame).size() > 0) flag = true; - + return flag; } @@ -184,32 +184,32 @@ int i=0; try { - i++; - newGameState = getBlock(game); - game = newGameState; - if(newGameState == null) - { - getLogger().debug("game state is null..."); - msgHandler.sendBlock(null); - } - else - { - getLogger().debug("game state is NOT null..."); - block = newGameState.getCurrentBlock(); - initializeGame(newGameState); - msgHandler.sendBlock(newGameState); - } - + i++; + newGameState = getBlock(game); + game = newGameState; + if(newGameState == null) + { + getLogger().debug("game state is null..."); + msgHandler.sendBlock(null); + } + else + { + getLogger().debug("game state is NOT null..."); + block = newGameState.getCurrentBlock(); + initializeGame(newGameState); + msgHandler.sendBlock(newGameState); + } + }catch (Exception e) { - getLogger().debug(e); + e.printStackTrace(); } } public void pushNextData(Game game) { // TODO Auto-generated method stub pushBlock(game); - + } - + public void assignGroups(Game currentGame) { @@ -324,10 +324,10 @@ grp.setNumber(++groupNo); groupDao.save(grp); getLogger().info("Group is created with id: " + grp.getId()); - + //set all location for the group setAllLocations(grp,groupSize); - + int studentNo = 1; int j = 0; for(int i = 0; i <= groupSize-1 ; i++) @@ -358,8 +358,8 @@ getLogger().info("in setAllLocations...group size is: " + groupSize); double maxCapacity = 0.0; double initCapacity = 0.0; - - + + List<Location> locations = new ArrayList<Location>(); locations = locationDao.findAll(); for(Location location:locations) @@ -369,13 +369,13 @@ groupLocation.setGroup(groupDao.find(grp.getId())); if(location.getLocationName().equalsIgnoreCase("bay1")) { - + groupLocation.setLocation(location); maxCapacity = 3.0*groupSize; - + groupLocation.setMaxCapacity(maxCapacity); initCapacity = maxCapacity/2; - + groupLocation.setInitialPopulation(initCapacity); //groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); @@ -390,50 +390,50 @@ groupLocation.setMaxCapacity(maxCapacity); 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")) { groupLocation.setLocation(location); maxCapacity = 10.0*groupSize; - + groupLocation.setMaxCapacity(maxCapacity); initCapacity = maxCapacity/2; - + groupLocation.setInitialPopulation(initCapacity); - + getLogger().info("initiali population set is: " + initCapacity); /*groupLocation.setCurrentPopulation(initCapacity); groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); -*/ + */ } if(location.getLocationName().equalsIgnoreCase("harbor")) { groupLocation.setLocation(location); maxCapacity = 0.0*groupSize; - + groupLocation.setMaxCapacity(maxCapacity); 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); groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); - + } } @@ -524,7 +524,7 @@ return locations; } -*/ + */ public Module getNextModule(int sequenceNo) { return getModule(sequenceNo); @@ -830,8 +830,8 @@ } } } - + Module module = block.getModule(); Hibernate.initialize(module); initializeModule(module); @@ -909,11 +909,11 @@ if(query.list().size() == 1) roundNo = (Integer) query.list().get(0); } - + return roundNo; } - + public boolean isGameFinished(Game game) { GameConfig gameConfig = game.getGameConfig(); List<GameRound> gameRounds = getGameRoundDao().findAllByProperty("gameConfig",game.getGameConfig()); @@ -1083,7 +1083,7 @@ private void initializeRound(Round round) { // TODO Auto-generated method stub Hibernate.initialize(round); - + } public void setBlockSeqNo(int blockSeqNo) { @@ -1183,5 +1183,5 @@ this.groupLocationDao = groupLocationDao; } - + } 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 2010-01-07 05:17:04 UTC (rev 426) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2010-01-12 21:42:47 UTC (rev 427) @@ -89,13 +89,13 @@ { //int duration = game.getBlock().getDuration(); - /* if(game.getCurrentBlock().getDescription().equalsIgnoreCase("Day-by-day decisions game")) + /*if(game.getCurrentBlock().getDescription().equalsIgnoreCase("Day-by-day decisions game")) { //start 10 sec timer //i = max days hardcoded for(int i =0;i<30;i++) { - int duration = 11; + duration = 11; Timer timer = new Timer(); Long startTime = System.currentTimeMillis()/1000; System.out.println("Started time is : " + System.currentTimeMillis()/1000); @@ -114,8 +114,7 @@ send(studentDecisions); } } - else */ - if(game.getCurrentBlock().getDescription().equalsIgnoreCase("Communication")){ + else*/ if(game.getCurrentBlock().getDescription().equalsIgnoreCase("Communication")){ duration = game.getCurrentBlock().getDuration(); } else @@ -136,23 +135,23 @@ pushData.pushNextData(game); } - //} - else - { - System.out.println("Game is Over..." + msg); - } + //} + else + { + System.out.println("Game is Over..." + msg); + } - /*AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); + /*AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); logger.info("Ack received from client for message " + msg + "is : " + ack); - */ -} + */ + } -@Override -public void setApplicationContext(ApplicationContext applicationContext) -throws BeansException { - // TODO Auto-generated method stub - this.ctx = applicationContext; + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + // TODO Auto-generated method stub + this.ctx = applicationContext; + } } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2010-01-12 21:15:35
|
checking out for lunch at 14:15pm (4hr) linux trial has expired, and therefore no progress has been made. working on another computer to try and set it up for use. On Tue, Jan 12, 2010 at 10:10 AM, Kalin Jonas <kj...@as...> wrote: > Coming in to work today at 10:15am. > I will be working on the new Strategy Design component as Seema and I > discussed: it will have only one list of actions (repeated) and I will be > removing the SuspendRepetition functionality. > I will begin by backing up the old component now. > |
From: Kalin J. <kj...@as...> - 2010-01-12 17:11:05
|
Coming in to work today at 10:15am. I will be working on the new Strategy Design component as Seema and I discussed: it will have only one list of actions (repeated) and I will be removing the SuspendRepetition functionality. I will begin by backing up the old component now. |
From: Kalin J. <kj...@as...> - 2010-01-07 23:05:15
|
Seema and I have discussed what I'll be working on until monday. checking out at 16:00pm (5hr) Windows partition is still inoperable, but I recovered the data. I will be committing the changes I made shortly. On Thu, Jan 7, 2010 at 11:05 AM, Kalin Jonas <kj...@as...> wrote: > checking in at 11:00 am > attempting to recover data from defunct section of harddrive. > Will try to assess why the operating system will not load; try to repair. > |
From: Kalin J. <kj...@as...> - 2010-01-07 18:05:30
|
checking in at 11:00 am attempting to recover data from defunct section of harddrive. Will try to assess why the operating system will not load; try to repair. |
From: <al...@us...> - 2010-01-07 05:17:14
|
Revision: 426 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=426&view=rev Author: alllee Date: 2010-01-07 05:17:04 +0000 (Thu, 07 Jan 2010) Log Message: ----------- added aggregate spatial distribution Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-05 20:36:23 UTC (rev 425) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-07 05:17:04 UTC (rev 426) @@ -57,6 +57,7 @@ // new AllDataProcessor(), new AggregateTimeIntervalProcessor(), // new SummaryProcessor(), + new AggregateTokenSpatialDistributionProcessor(), // new CollectedTokenSpatialDistributionProcessor(), // new MovementStatisticsProcessor(), new AggregateCollectedTokenNeighborProcessor() @@ -217,7 +218,7 @@ } } } - + private static class CollectedTokenSpatialDistributionProcessor extends SaveFileProcessor.Base { @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { @@ -233,36 +234,37 @@ TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; Point point = tokenCollectedEvent.getLocation(); Identifier id = tokenCollectedEvent.getId(); - ClientSpatialDistribution clientDistribution = clientSpatialDistributionMap.get(id); - clientDistribution.columnCounts[point.x]++; - clientDistribution.rowCounts[point.y]++; - clientDistribution.tokens++; + ClientSpatialDistribution spatialDistribution = clientSpatialDistributionMap.get(id); + spatialDistribution.columnCounts[point.x]++; + spatialDistribution.rowCounts[point.y]++; + spatialDistribution.tokens++; } } // calculate for group - ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + writeData(writer, serverDataModel, clientSpatialDistributionMap); + } + + private void writeData( + PrintWriter writer, + ServerDataModel serverDataModel, + Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { + ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); for (GroupDataModel group: groups) { - writer.println("Group # " + groups.indexOf(group) + "\n----------------------"); - writer.println("Identifier, # tokens, row stdev, column stdev"); + String groupLabel = "Group #" + groups.indexOf(group); + writer.println("Identifier, Group, # tokens, row stdev, column stdev"); double groupWeightedSpatialMetric = 0.0d; int totalTokens = 0; for (Identifier id: group.getClientIdentifiers()) { ClientSpatialDistribution spatialDistribution = clientSpatialDistributionMap.get(id); spatialDistribution.calculateStandardDeviation(); groupWeightedSpatialMetric += spatialDistribution.weightedSpatialMetric; - writer.println(String.format("%s, %s, %s, %s", id, spatialDistribution.tokens, spatialDistribution.rowStandardDeviation, spatialDistribution.columnStandardDeviation)); + writer.println(String.format("%s, %s, %s, %s, %s", id, groupLabel, spatialDistribution.tokens, spatialDistribution.rowStandardDeviation, spatialDistribution.columnStandardDeviation)); totalTokens += spatialDistribution.tokens; } groupWeightedSpatialMetric /= totalTokens; - writer.println(groupWeightedSpatialMetric); + writer.println(groupLabel + " weighted spatial metric: " + groupWeightedSpatialMetric); } - // for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { - // Identifier id = entry.getKey(); - // ClientSpatialDistribution spatialDistribution = entry.getValue(); - // spatialDistribution.calculateStandardDeviation(); - // writer.println(String.format("%s, %s", id, spatialDistribution.weightedSpatialMetric)); - // } - } + } @Override public String getOutputFileExtension() { @@ -270,6 +272,67 @@ } } + private static class AggregateTokenSpatialDistributionProcessor extends SaveFileProcessor.Base { + @Override + public void process(SavedRoundData savedRoundData, PrintWriter writer) { + ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); + SortedSet<PersistableEvent> actions = savedRoundData.getActions(); + Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap = new HashMap<Identifier, ClientSpatialDistribution>(); + Dimension boardSize = new Dimension(serverDataModel.getBoardWidth(), serverDataModel.getBoardHeight()); + for (ClientData clientData : serverDataModel.getClientDataMap().values()) { + clientSpatialDistributionMap.put(clientData.getId(), new ClientSpatialDistribution(boardSize)); + } + for (PersistableEvent event : actions) { + int elapsedTime = savedRoundData.getElapsedTimeInSeconds(event); + if (isIntervalElapsed(elapsedTime)) { + writeData(writer, serverDataModel, clientSpatialDistributionMap); + } + if (event instanceof TokenCollectedEvent) { + TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; + Point point = tokenCollectedEvent.getLocation(); + Identifier id = tokenCollectedEvent.getId(); + ClientSpatialDistribution spatialDistribution = clientSpatialDistributionMap.get(id); + spatialDistribution.columnCounts[point.x]++; + spatialDistribution.rowCounts[point.y]++; + spatialDistribution.tokens++; + } + } + // write last interval out + writeData(writer, serverDataModel, clientSpatialDistributionMap); + } + + private void writeData( + PrintWriter writer, + ServerDataModel serverDataModel, + Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap) { + ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + for (GroupDataModel group: groups) { + String groupLabel = "Group # " + groups.indexOf(group); + writer.println("Time, Identifier, Group, # tokens, row stdev, column stdev"); + double groupWeightedSpatialMetric = 0.0d; + int totalTokens = 0; + for (Identifier id: group.getClientIdentifiers()) { + ClientSpatialDistribution spatialDistribution = clientSpatialDistributionMap.get(id); + spatialDistribution.calculateStandardDeviation(); + groupWeightedSpatialMetric += spatialDistribution.weightedSpatialMetric; + writer.println(String.format("%d, %s, %s, %s, %s, %s", getIntervalEnd(), id, groupLabel, spatialDistribution.tokens, spatialDistribution.rowStandardDeviation, spatialDistribution.columnStandardDeviation)); + totalTokens += spatialDistribution.tokens; + } + groupWeightedSpatialMetric /= totalTokens; + writer.println(groupLabel + " weighted spatial metric: " + groupWeightedSpatialMetric); + } + // clear data after processing all groups. + for (ClientSpatialDistribution spatialDistribution : clientSpatialDistributionMap.values()) { + spatialDistribution.zeroRowColumnCounts(); + } + } + + @Override + public String getOutputFileExtension() { + return "-aggregated-spatial-distribution.txt"; + } + } + private static class ClientSpatialDistribution { private int[] rowCounts; private double standardizedRowDistribution; @@ -283,12 +346,18 @@ private ClientSpatialDistribution(Dimension boardSize) { rowCounts = new int[boardSize.height]; columnCounts = new int[boardSize.width]; + zeroRowColumnCounts(); + } + + public void zeroRowColumnCounts() { Arrays.fill(rowCounts, 0); Arrays.fill(columnCounts, 0); } + public String toString() { return String.format("tokens: %d, row: %s, col: %s", tokens, standardizedRowDistribution, standardizedColumnDistribution); } + private void calculateStandardDeviation() { rowStandardDeviation = stdDev(rowCounts); columnStandardDeviation = stdDev(columnCounts); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 20:36:34
|
Revision: 425 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=425&view=rev Author: alllee Date: 2010-01-05 20:36:23 +0000 (Tue, 05 Jan 2010) Log Message: ----------- aggregate statistics were missing the last interval as the isIntervalElapsed() was never triggered (no movement events at t=240) Modified Paths: -------------- foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2010-01-05 20:31:55 UTC (rev 424) +++ foraging/trunk/pom.xml 2010-01-05 20:36:23 UTC (rev 425) @@ -46,21 +46,12 @@ <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> - <!-- - <repository> - <id>java.net</id> - <name>java.net</name> - <url>http://download.java.net/maven/2</url> - <layout>default</layout> - </repository> - --> </repositories> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> - <scope>test</scope> </dependency> <dependency> <groupId>edu.asu.commons</groupId> @@ -87,6 +78,17 @@ <finalName>foraging</finalName> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.6.1</version> + <configuration> + <links> + <link>http://commons.asu.edu/api/csidex/</link> + </links> + <detectLinks>true</detectLinks> + </configuration> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2010-01-05 20:31:55 UTC (rev 424) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2010-01-05 20:36:23 UTC (rev 425) @@ -179,7 +179,7 @@ * @return */ public int getSanctionMultiplier() { - return getIntProperty("sanction-multiplier", 1); + return getIntProperty("sanction-multiplier", 2); } public int getSanctionPenalty() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-05 20:31:55 UTC (rev 424) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-05 20:36:23 UTC (rev 425) @@ -46,6 +46,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ +@SuppressWarnings("unused") public class ForagingSaveFileConverter { public static boolean convert(String saveDataDirectory) { @@ -557,17 +558,7 @@ int elapsedTimeInSeconds = savedRoundData.getElapsedTimeInSeconds(event); if (isIntervalElapsed(elapsedTimeInSeconds)) { - // write all collected data - for (Map.Entry<Identifier, Integer[]> entry : collectedTokenNeighbors.entrySet()) { - Identifier id = entry.getKey(); - Integer[] neighboringTokens = entry.getValue(); - writer.println(Utils.join(',', elapsedTimeInSeconds - 1, id, - Utils.join(',', neighboringTokens))); - // replace old neighboring tokens with new array - Integer[] freshNeighbors = new Integer[9]; - Arrays.fill(freshNeighbors, 0); - entry.setValue(freshNeighbors); - } + writeAggregateStatistics(writer, collectedTokenNeighbors); } if (event instanceof ResourceAddedEvent) { ResourceAddedEvent rae = (ResourceAddedEvent) event; @@ -587,9 +578,25 @@ collectedTokenNeighbors.get(id)[numberOfNeighboringTokens]++; } } - + // write out last interval + writeAggregateStatistics(writer, collectedTokenNeighbors); } + private void writeAggregateStatistics(PrintWriter writer, + Map<Identifier, Integer[]> collectedTokenNeighbors) { + // write all collected data + for (Map.Entry<Identifier, Integer[]> entry : collectedTokenNeighbors.entrySet()) { + Identifier id = entry.getKey(); + Integer[] neighboringTokens = entry.getValue(); + writer.println(Utils.join(',', getIntervalEnd(), id, + Utils.join(',', Arrays.asList(neighboringTokens)))); + // replace old neighboring tokens with new array + Integer[] freshNeighbors = new Integer[9]; + Arrays.fill(freshNeighbors, 0); + entry.setValue(freshNeighbors); + } + } + @Override public String getOutputFileExtension() { return "-collected-token-neighbors.txt"; @@ -600,7 +607,6 @@ public static class AggregateTimeIntervalProcessor extends SaveFileProcessor.Base { - private static int secondsPerInterval = 60; public void process(SavedRoundData savedRoundData, PrintWriter writer) { // populate the ordered identifiers, try directly from the participant tokens map that // is persisted in later versions of the experiment. @@ -657,40 +663,15 @@ ); writer.println(header); - int currentInterval = 0; for (PersistableEvent event: savedRoundData.getActions()) { int secondsElapsed = savedRoundData.getElapsedTimeInSeconds(event); - int endOfInterval = (currentInterval + 1) * secondsPerInterval; - // System.err.println("seconds elapsed: " + secondsElapsed); - // System.err.println("end of interval: " + endOfInterval); - // see if the current persistable event is past the threshold, // meaning we should take a snapshot of our currently // accumulated stats - if (secondsElapsed >= endOfInterval) { + if (isIntervalElapsed(secondsElapsed)) { // generate group expected token counts - List<Double> expectedTokenProbabilities = getExpectedTokenProbabilities(serverDataModel); - // report summary stats and reset - List<Integer> movesTaken = new ArrayList<Integer>(); - List<Integer> harvestedTokens = new ArrayList<Integer>(); - List<Integer> tokensLeft = getTokensLeft(groups); - List<Double> distances = getClientDistances(groups); - for (Identifier id : orderedIdentifiers) { - ClientMovementTokenCount stats = clientStatistics.get(id); - movesTaken.add(stats.moves); - harvestedTokens.add(stats.tokens); - stats.reset(); - } - String dataline = - Utils.join(',', endOfInterval, - Utils.join(',', movesTaken), - Utils.join(',', harvestedTokens), - Utils.join(',', expectedTokenProbabilities), - Utils.join(',', tokensLeft), - Utils.join(',', distances) - ); - writer.println(dataline); - currentInterval++; + writeAggregateStatistics(writer, serverDataModel, + clientStatistics, orderedIdentifiers, groups); } // next, process the current persistable event ClientMovementTokenCount stats = clientStatistics.get(event.getId()); @@ -730,8 +711,38 @@ resourcesAddedEvent.getGroup().addResources(resourcesAddedEvent.getResources()); } } + writeAggregateStatistics(writer, serverDataModel, + clientStatistics, orderedIdentifiers, groups); } + private void writeAggregateStatistics(PrintWriter writer, + ServerDataModel serverDataModel, + Map<Identifier, ClientMovementTokenCount> clientStatistics, + TreeSet<Identifier> orderedIdentifiers, + List<GroupDataModel> groups) { + List<Double> expectedTokenProbabilities = getExpectedTokenProbabilities(serverDataModel); + // report summary stats and reset + List<Integer> movesTaken = new ArrayList<Integer>(); + List<Integer> harvestedTokens = new ArrayList<Integer>(); + List<Integer> tokensLeft = getTokensLeft(groups); + List<Double> distances = getClientDistances(groups); + for (Identifier id : orderedIdentifiers) { + ClientMovementTokenCount stats = clientStatistics.get(id); + movesTaken.add(stats.moves); + harvestedTokens.add(stats.tokens); + stats.reset(); + } + String dataline = + Utils.join(',', getIntervalEnd(), + Utils.join(',', movesTaken), + Utils.join(',', harvestedTokens), + Utils.join(',', expectedTokenProbabilities), + Utils.join(',', tokensLeft), + Utils.join(',', distances) + ); + writer.println(dataline); + } + private List<Double> getClientDistances(List<GroupDataModel> groups) { List<Double> distances = new ArrayList<Double>(); for (GroupDataModel group: groups) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 20:32:36
|
Revision: 424 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=424&view=rev Author: alllee Date: 2010-01-05 20:31:55 +0000 (Tue, 05 Jan 2010) Log Message: ----------- fixing SaveFileProcessor interval handling to not include interval end in the interval, i.e., [intervalStart, intervalEnd). In other words, an interval of 60 seconds is 0-59, 60-119, 120-179, 180-239. When converting the data files this means we often have to manually write out the aggregate statistics for the last interval since the isIntervalElapsed check never actually reaches the threshold. Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2010-01-05 19:28:43 UTC (rev 423) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2010-01-05 20:31:55 UTC (rev 424) @@ -58,7 +58,7 @@ public boolean isIntervalElapsed(int secondsElapsed) { intervalEnd = (currentInterval + 1) * secondsPerInterval; - if (secondsElapsed > intervalEnd) { + if (secondsElapsed >= intervalEnd) { currentInterval++; return true; } Modified: csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 19:28:43 UTC (rev 423) +++ csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 20:31:55 UTC (rev 424) @@ -140,7 +140,7 @@ public int compareTo(SocketIdentifier socketId) { int comparison = 0; - if (stationNumber != null) { + if (stationNumber != null && socketId.stationNumber != null) { comparison = stationNumber.compareTo(socketId.stationNumber); } if (comparison == 0) { Modified: csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java =================================================================== --- csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java 2010-01-05 19:28:43 UTC (rev 423) +++ csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java 2010-01-05 20:31:55 UTC (rev 424) @@ -40,17 +40,18 @@ public void testIntervals() { int secondsPerInterval = 60; processor.setSecondsPerInterval(secondsPerInterval); - for (int i = 0; i <= secondsPerInterval; i++) { - assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-60", processor.isIntervalElapsed(i)); + for (int i = 0; i < secondsPerInterval; i++) { + assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-59", processor.isIntervalElapsed(i)); } - assertTrue("interval of 60 seconds should return true for isIntervalElapsed(61)", processor.isIntervalElapsed(61)); - assertFalse("should now return false for 60 seconds", processor.isIntervalElapsed(61)); - for (int i = 0; i <= secondsPerInterval*2; i++) { - assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-120", processor.isIntervalElapsed(i)); + assertTrue("interval of 60 seconds should return true for isIntervalElapsed(60)", processor.isIntervalElapsed(60)); + assertFalse("should now return false for 60 seconds", processor.isIntervalElapsed(60)); + for (int i = 0; i < secondsPerInterval*2; i++) { + assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-119", processor.isIntervalElapsed(i)); } - assertTrue("interval of 60 seconds should return true for isIntervalElapsed(121)", processor.isIntervalElapsed(121)); + assertTrue("interval of 60 seconds should return true for isIntervalElapsed(120)", processor.isIntervalElapsed(120)); + assertFalse("interval has already elapsed for isIntervalElapsed(120)", processor.isIntervalElapsed(120)); processor.resetCurrentInterval(); - for (int i = 0; i <= secondsPerInterval; i++) { + for (int i = 0; i < secondsPerInterval; i++) { assertFalse("after reset, interval of 60 seconds should return false for isIntervalElapsed from 0-60", processor.isIntervalElapsed(i)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 19:28:53
|
Revision: 423 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=423&view=rev Author: alllee Date: 2010-01-05 19:28:43 +0000 (Tue, 05 Jan 2010) Log Message: ----------- NPE fix for SocketIdentifier.compareTo Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java Modified: csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 08:04:55 UTC (rev 422) +++ csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 19:28:43 UTC (rev 423) @@ -20,6 +20,7 @@ private final InetSocketAddress localSocketAddress; private final InetSocketAddress remoteSocketAddress; + // FIXME: refactor, is this necessary if we're also maintaining the station number? logic is convoluted. private boolean stationed; private Integer stationNumber; @@ -107,8 +108,8 @@ */ public String toString() { - int stationNumber = getStationNumber(); - return (stationed) ? String.format("Station %d:%d", stationNumber, id) : remoteSocketAddress.toString(); + int stationNumberInt = getStationNumber(); + return (stationed) ? String.format("Station %d:%d", stationNumberInt, id) : remoteSocketAddress.toString(); } /** @@ -139,11 +140,11 @@ public int compareTo(SocketIdentifier socketId) { int comparison = 0; - if (stationed) { + if (stationNumber != null) { comparison = stationNumber.compareTo(socketId.stationNumber); } if (comparison == 0) { - // ensure that these two are .equals. + // if these two socket ids are .equals, comparison of 0 is fine. Otherwise go by the id. if (! equals(socketId)) { comparison = Integer.valueOf(id).compareTo(Integer.valueOf(socketId.id)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 08:05:04
|
Revision: 422 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=422&view=rev Author: alllee Date: 2010-01-05 08:04:55 +0000 (Tue, 05 Jan 2010) Log Message: ----------- adding int array specialization to Utils.join Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2010-01-05 08:00:41 UTC (rev 421) +++ csidex/trunk/pom.xml 2010-01-05 08:04:55 UTC (rev 422) @@ -14,6 +14,9 @@ several concrete experiments developed by the Virtual Commons, namely the foraging and irrigation experiments. </description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> <licenses> <license> <name>GNU General Public License, Version 3.0</name> @@ -26,15 +29,15 @@ </scm> <repositories> <repository> + <id>dev.commons.asu.edu</id> + <name>dev.commons archiva repo</name> + <url>http://dev.commons.asu.edu/archiva/repository/internal</url> + </repository> + <repository> <id>dev.tdar.org</id> <name>tDAR archiva repo</name> <url>http://dev.tdar.org/archiva/repository/internal</url> </repository> - <repository> - <id>dev.commons.asu.edu</id> - <name>dev.commons archiva repo</name> - <url>http://dev.commons.asu.edu/archiva/repository/internal</url> - </repository> </repositories> <dependencies> <dependency> Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2010-01-05 08:00:41 UTC (rev 421) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2010-01-05 08:04:55 UTC (rev 422) @@ -42,20 +42,37 @@ // FIXME: not thread safe for concurrent usage when reusing the same SaveFileProcessor in multiple threads // on multiple save files. - private int secondsPerInterval = 60; + private int secondsPerInterval; private int currentInterval = 0; + private int intervalEnd = 0; private String roundSaveFile; + public Base() { + this(60); + } + + public Base(int secondsPerInterval) { + this.secondsPerInterval = secondsPerInterval; + } + public boolean isIntervalElapsed(int secondsElapsed) { - int numberOfSecondsAtIntervalEnd = (currentInterval + 1) * secondsPerInterval; - if (secondsElapsed > numberOfSecondsAtIntervalEnd) { + intervalEnd = (currentInterval + 1) * secondsPerInterval; + if (secondsElapsed > intervalEnd) { currentInterval++; return true; } return false; } + /** + * Returns the total number of seconds that must elapse before the current interval ends (e.g., 60, 120, 180). + * @return the total number of seconds that must elapse before the current interval ends + */ + protected int getIntervalEnd() { + return intervalEnd; + } + protected void resetCurrentInterval() { currentInterval = 0; } Modified: csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2010-01-05 08:00:41 UTC (rev 421) +++ csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2010-01-05 08:04:55 UTC (rev 422) @@ -121,6 +121,18 @@ return builder.toString(); } + public static String join(char delimiter, int[] ints) { + StringBuilder builder = new StringBuilder(ints.length * 2); + for (int i = 0; i < ints.length; i++) { + builder.append(String.valueOf(ints[i])); + if (i < ints.length - 1) { + builder.append(delimiter); + } + } + return builder.toString(); + + } + private static void addString(StringBuilder builder, String string, boolean shouldQuote) { if (shouldQuote) { if (string.contains("'")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 08:00:48
|
Revision: 421 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=421&view=rev Author: alllee Date: 2010-01-05 08:00:41 +0000 (Tue, 05 Jan 2010) Log Message: ----------- adding aggregated neighboring tokens of collected tokens statistic to save file converter Modified Paths: -------------- foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Removed Paths: ------------- foraging/trunk/src/main/java/TestEnforcement.java Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2010-01-05 07:21:29 UTC (rev 420) +++ foraging/trunk/pom.xml 2010-01-05 08:00:41 UTC (rev 421) @@ -73,6 +73,11 @@ <version>1.1.1-rc6</version> </dependency> <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> <groupId>javax.media</groupId> <artifactId>jmf</artifactId> <version>2.1.1e</version> Deleted: foraging/trunk/src/main/java/TestEnforcement.java =================================================================== --- foraging/trunk/src/main/java/TestEnforcement.java 2010-01-05 07:21:29 UTC (rev 420) +++ foraging/trunk/src/main/java/TestEnforcement.java 2010-01-05 08:00:41 UTC (rev 421) @@ -1,33 +0,0 @@ -import java.awt.Color; -import java.awt.Container; -import java.awt.FlowLayout; - -import javax.swing.JFrame; - -import edu.asu.commons.foraging.client.EnforcementPanel; - - -public class TestEnforcement { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - //ForagingClient client = new ForagingClient(); - - EnforcementPanel testEnforcement = new EnforcementPanel(); - testEnforcement.initialize(); - JFrame f = new JFrame("This is a test"); - f.setSize(1000, 1000); - Container content = f.getContentPane(); - content.setBackground(Color.white); - content.setLayout(new FlowLayout()); - content.add(testEnforcement); - //f.setDefaultCloseOperation(0); - f.setVisible(true); - - - } - -} Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2010-01-05 07:21:29 UTC (rev 420) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2010-01-05 08:00:41 UTC (rev 421) @@ -105,6 +105,26 @@ } } + public int getNumberOfNeighboringTokens(Point referencePoint) { + int numberOfNeighboringTokens = 0; + int currentX = referencePoint.x; + int currentY = referencePoint.y; + int endX = currentX + 2; + int endY = currentY + 2; + for (int x = currentX - 1; x < endX; x++) { + for (int y = currentY - 1; y < endY; y++) { + Point point = new Point(x, y); + if (point.equals(referencePoint)) continue; + // only add a point to the neighborhood set if it doesn't already have a resource. + if (serverDataModel.isValidPosition(point) && resourceDistribution.containsKey(point)) { + numberOfNeighboringTokens++; + } + } + } + return numberOfNeighboringTokens; + + } + private double rankToValue(int rank) { switch (rank) { case 0: return 1.0d; Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2010-01-05 07:21:29 UTC (rev 420) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2010-01-05 08:00:41 UTC (rev 421) @@ -140,9 +140,9 @@ channel.handle(new AddClientEvent(clientData, group, clientData.getPosition())); } - public void addResource(GroupDataModel group, Resource position) { - group.addResource(position); - channel.handle(new ResourceAddedEvent(group, position)); + public void addResource(GroupDataModel group, Resource resource) { + group.addResource(resource); + channel.handle(new ResourceAddedEvent(group, resource)); } public void moveResources(GroupDataModel group, Collection<Point> removedPoints, Collection<Point> addedPoints) { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-05 07:21:29 UTC (rev 420) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2010-01-05 08:00:41 UTC (rev 421) @@ -53,12 +53,13 @@ if (allSaveFilesDirectory.exists() && allSaveFilesDirectory.isDirectory()) { List<SaveFileProcessor> processors = new ArrayList<SaveFileProcessor>(); processors.addAll(Arrays.asList( - new AllDataProcessor(), +// new AllDataProcessor(), new AggregateTimeIntervalProcessor(), - new SummaryProcessor(), - new CollectedTokenSpatialDistributionProcessor(), - new MovementStatisticsProcessor(), - new MovieCreatorProcessor() +// new SummaryProcessor(), +// new CollectedTokenSpatialDistributionProcessor(), +// new MovementStatisticsProcessor(), + new AggregateCollectedTokenNeighborProcessor() +// new MovieCreatorProcessor() )); Persister.processSaveFiles(allSaveFilesDirectory, processors); return true; @@ -71,7 +72,12 @@ System.err.println("Usage: java " + ForagingSaveFileConverter.class + " <save-data-directory>"); System.exit(0); } - convert(args[0]); + if (convert(args[0])) { + System.err.println("Successfully converted files in " + args[0]); + } + else { + System.err.println(args[0] + " doesn't appear to be a valid save file directory."); + } } private static class MovementStatisticsProcessor extends SaveFileProcessor.Base { @@ -521,10 +527,80 @@ } } } + + public static class AggregateCollectedTokenNeighborProcessor extends SaveFileProcessor.Base { + + public AggregateCollectedTokenNeighborProcessor() { + setSecondsPerInterval(60); + } + + public void process(SavedRoundData savedRoundData, PrintWriter writer) { + // populate the ordered identifiers, try directly from the participant tokens map that + // is persisted in later versions of the experiment. + ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); + TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); + // write out neighboring tokens for collected tokens statistics first. + ArrayList<String> collectedTokenNeighborHeader = new ArrayList<String>(); + for (int i = 0; i < 9; i++) { + collectedTokenNeighborHeader.add(String.valueOf(i)); + } + writer.println( + Utils.join(',', "Time", "Client ID", + Utils.join(',', collectedTokenNeighborHeader))); + Map<Identifier, Integer[]> collectedTokenNeighbors = new LinkedHashMap<Identifier, Integer[]>(); + for (Identifier id: orderedIdentifiers) { + Integer[] neighbors = new Integer[9]; + Arrays.fill(neighbors, 0); + collectedTokenNeighbors.put(id, neighbors); + } + for (PersistableEvent event: savedRoundData.getActions()) { + int elapsedTimeInSeconds = savedRoundData.getElapsedTimeInSeconds(event); + + if (isIntervalElapsed(elapsedTimeInSeconds)) { + // write all collected data + for (Map.Entry<Identifier, Integer[]> entry : collectedTokenNeighbors.entrySet()) { + Identifier id = entry.getKey(); + Integer[] neighboringTokens = entry.getValue(); + writer.println(Utils.join(',', elapsedTimeInSeconds - 1, id, + Utils.join(',', neighboringTokens))); + // replace old neighboring tokens with new array + Integer[] freshNeighbors = new Integer[9]; + Arrays.fill(freshNeighbors, 0); + entry.setValue(freshNeighbors); + } + } + if (event instanceof ResourceAddedEvent) { + ResourceAddedEvent rae = (ResourceAddedEvent) event; + // FIXME: check that rae.getGroup() is the same as the groups in the server data model + assert serverDataModel.getGroup(rae.getId()).equals(rae.getGroup()); + rae.getGroup().addResource(rae.getResource()); + } + else if (event instanceof ResourcesAddedEvent) { + ResourcesAddedEvent rae = (ResourcesAddedEvent) event; + assert serverDataModel.getGroup(rae.getId()).equals(rae.getGroup()); + rae.getGroup().addResources(rae.getResources()); + } + else if (event instanceof TokenCollectedEvent) { + TokenCollectedEvent tce = (TokenCollectedEvent) event; + Identifier id = tce.getId(); + int numberOfNeighboringTokens = serverDataModel.getGroup(id).getNumberOfNeighboringTokens(tce.getLocation()); + collectedTokenNeighbors.get(id)[numberOfNeighboringTokens]++; + } + } + } + @Override + public String getOutputFileExtension() { + return "-collected-token-neighbors.txt"; + } + + + } + + public static class AggregateTimeIntervalProcessor extends SaveFileProcessor.Base { - private static int secondsPerInterval = 5; + private static int secondsPerInterval = 60; public void process(SavedRoundData savedRoundData, PrintWriter writer) { // populate the ordered identifiers, try directly from the participant tokens map that // is persisted in later versions of the experiment. @@ -536,15 +612,9 @@ RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + - // XXX: not really any better than the below, and actually more inefficient to boot. Damn. - // List<String> foo = Utils.map(orderedIdentifiers, new Utils.MapOp<Identifier, String>() { - // public String apply(Identifier id) { - // return id + " movement"; - // } - // }); - - + List<String> movementHeader = new ArrayList<String>(); List<String> collectedTokensHeader = new ArrayList<String>(); for (Identifier id: orderedIdentifiers) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 07:21:49
|
Revision: 420 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=420&view=rev Author: alllee Date: 2010-01-05 07:21:29 +0000 (Tue, 05 Jan 2010) Log Message: ----------- test for interval scheduling Added Paths: ----------- csidex/trunk/src/test/java/edu/asu/commons/experiment/ csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java Added: csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java =================================================================== --- csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java (rev 0) +++ csidex/trunk/src/test/java/edu/asu/commons/experiment/SaveFileProcessorTest.java 2010-01-05 07:21:29 UTC (rev 420) @@ -0,0 +1,58 @@ +package edu.asu.commons.experiment; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.PrintWriter; + +import org.junit.Before; +import org.junit.Test; + +/** + * $Id$ + * + * @version $Rev$ + * @author <a href='mailto:all...@as...'>Allen Lee</a> + */ +public class SaveFileProcessorTest { + + private static class IntervalProcessor extends SaveFileProcessor.Base { + + @Override + public void process(SavedRoundData savedRoundData, PrintWriter writer) { + + } + + @Override + public String getOutputFileExtension() { + return "-test-interval.txt"; + } + } + + private IntervalProcessor processor; + + @Before + public void setUp() { + processor = new IntervalProcessor(); + } + + @Test + public void testIntervals() { + int secondsPerInterval = 60; + processor.setSecondsPerInterval(secondsPerInterval); + for (int i = 0; i <= secondsPerInterval; i++) { + assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-60", processor.isIntervalElapsed(i)); + } + assertTrue("interval of 60 seconds should return true for isIntervalElapsed(61)", processor.isIntervalElapsed(61)); + assertFalse("should now return false for 60 seconds", processor.isIntervalElapsed(61)); + for (int i = 0; i <= secondsPerInterval*2; i++) { + assertFalse("interval of 60 seconds should return false for isIntervalElapsed from 0-120", processor.isIntervalElapsed(i)); + } + assertTrue("interval of 60 seconds should return true for isIntervalElapsed(121)", processor.isIntervalElapsed(121)); + processor.resetCurrentInterval(); + for (int i = 0; i <= secondsPerInterval; i++) { + assertFalse("after reset, interval of 60 seconds should return false for isIntervalElapsed from 0-60", processor.isIntervalElapsed(i)); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-01-05 06:54:24
|
Revision: 419 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=419&view=rev Author: alllee Date: 2010-01-05 06:54:18 +0000 (Tue, 05 Jan 2010) Log Message: ----------- adding interval helpers Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2009-12-28 08:02:14 UTC (rev 418) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2010-01-05 06:54:18 UTC (rev 419) @@ -6,7 +6,7 @@ import java.io.PrintWriter; /** - * $ Id: Exp $ + * $Id$ * * Concrete implementations of this interface are used as callback hooks that contain whatever custom savefile processing code is * needed. @@ -41,13 +41,35 @@ public abstract static class Base implements SaveFileProcessor { // FIXME: not thread safe for concurrent usage when reusing the same SaveFileProcessor in multiple threads // on multiple save files. + + private int secondsPerInterval = 60; + private int currentInterval = 0; + private String roundSaveFile; - public void process(SavedRoundData savedRoundData, String roundSaveFile) { + public boolean isIntervalElapsed(int secondsElapsed) { + int numberOfSecondsAtIntervalEnd = (currentInterval + 1) * secondsPerInterval; + if (secondsElapsed > numberOfSecondsAtIntervalEnd) { + currentInterval++; + return true; + } + return false; + } + + protected void resetCurrentInterval() { + currentInterval = 0; + } + + public void setSecondsPerInterval(int secondsPerInterval) { + this.secondsPerInterval = secondsPerInterval; + } + + public void process(SavedRoundData savedRoundData, String roundSaveFile) { this.roundSaveFile = roundSaveFile; FileOutputStream defaultFileOutputStream = null; try { defaultFileOutputStream = new FileOutputStream( getOutputFileName() ); + currentInterval = 0; process(savedRoundData, defaultFileOutputStream); } catch (IOException e) { @@ -78,10 +100,10 @@ } /** - * Returns a unique output file name for this save file processor. + * Returns an output file name for this save file processor based on the output file extension. */ public String getOutputFileName() { - return roundSaveFile.concat( getOutputFileExtension() ); + return roundSaveFile + getOutputFileExtension(); } public void dispose() { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (JIRA) <jef...@as...> - 2010-01-03 20:11:22
|
[ http://opensource.asu.edu/jira/browse/COMMONS-3?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved COMMONS-3. ----------------------------- Resolution: Fixed Interface has been simplified quite a bit, with much less instructions. > clarify water supply vs irrigation capacity in interface design and instructions > -------------------------------------------------------------------------------- > > Key: COMMONS-3 > URL: http://opensource.asu.edu/jira/browse/COMMONS-3 > Project: The Virtual Commons > Issue Type: Bug > Components: irrigation > Affects Versions: irrigation.asu.fall.2009 > Reporter: Allen Lee > Assignee: Allen Lee > Fix For: irrigation.asu.fall.2009 > > > The notion of water supply as different from irrigation capacity needs to be clarified in the interface including the charts and graphs as well as the primary game interface. There should be a water supply label in addition to the irrigation capacity label. -- 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: Allen L. (JIRA) <jef...@as...> - 2010-01-03 20:07:54
|
save file conversion -------------------- Key: COMMONS-10 URL: http://opensource.asu.edu/jira/browse/COMMONS-10 Project: The Virtual Commons Issue Type: Task Components: foraging Reporter: Allen Lee Assignee: Allen Lee Improve save file conversion, provide time interval (default: 60 s) aggregated statistics for movement, tokens collected, and number of neighboring tokens around a collected token. -- 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-12-28 08:02:22
|
Revision: 418 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=418&view=rev Author: alllee Date: 2009-12-28 08:02:14 +0000 (Mon, 28 Dec 2009) Log Message: ----------- fixing import and source encoding for pom Modified Paths: -------------- foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2009-12-28 07:16:34 UTC (rev 417) +++ foraging/trunk/pom.xml 2009-12-28 08:02:14 UTC (rev 418) @@ -11,6 +11,19 @@ <version>1.0-SNAPSHOT</version> <name>foraging</name> <url>http://commons.asu.edu/foraging</url> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <licenses> + <license> + <name>GNU General Public License, Version 3.0</name> + <url>http://www.gnu.org/copyleft/gpl.html</url> + <distribution>repo</distribution> + </license> + </licenses> + <scm> + <url>https://virtualcommons.svn.sourceforge.net/svnroot/virtualcommons/foraging</url> + </scm> <repositories> <repository> <id>dev.commons.asu.edu</id> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java 2009-12-28 07:16:34 UTC (rev 417) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java 2009-12-28 08:02:14 UTC (rev 418) @@ -1,7 +1,7 @@ package edu.asu.commons.foraging.event; -import edu.asu.commons.event.AbstractEvent; +import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-12-28 07:16:42
|
Revision: 417 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=417&view=rev Author: alllee Date: 2009-12-28 07:16:34 +0000 (Mon, 28 Dec 2009) Log Message: ----------- new convenience constructor in AbstractPersistableEvent, same with methods in Utils/Duration fixing broken archiva reference in pom and added javadoc plugin Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java csidex/trunk/src/main/java/edu/asu/commons/util/Duration.java csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2009-12-25 05:17:14 UTC (rev 416) +++ csidex/trunk/pom.xml 2009-12-28 07:16:34 UTC (rev 417) @@ -27,27 +27,20 @@ <repositories> <repository> <id>dev.tdar.org</id> - <name>tDAR Maven2 archiva repo</name> + <name>tDAR archiva repo</name> <url>http://dev.tdar.org/archiva/repository/internal</url> </repository> <repository> - <id>csid.asu.edu</id> - <name>CSID Maven2 archiva repo</name> - <url>http://csid.asu.edu/archiva/repository/internal</url> + <id>dev.commons.asu.edu</id> + <name>dev.commons archiva repo</name> + <url>http://dev.commons.asu.edu/archiva/repository/internal</url> </repository> - <repository> - <id>java.net</id> - <name>java.net</name> - <url>http://download.java.net/maven/2</url> - <layout>default</layout> - </repository> </repositories> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> - <scope>test</scope> </dependency> <dependency> <groupId>com.thoughtworks.xstream</groupId> @@ -64,6 +57,17 @@ <finalName>csidex</finalName> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.6.1</version> + <configuration> + <links> + <link>http://xstream.codehaus.org/javadoc/</link> + </links> + <detectLinks>true</detectLinks> + </configuration> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> Modified: csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java 2009-12-25 05:17:14 UTC (rev 416) +++ csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java 2009-12-28 07:16:34 UTC (rev 417) @@ -17,12 +17,16 @@ private static final long serialVersionUID = -8335415577272927846L; - private static long classCounter = 0; + private volatile static long classCounter = 0; private final long ordinal; public AbstractPersistableEvent(Identifier id) { - super(id); + this(id, null); + } + + public AbstractPersistableEvent(Identifier id, String message) { + super(id, message); synchronized (AbstractPersistableEvent.class) { ordinal = classCounter++; } Modified: csidex/trunk/src/main/java/edu/asu/commons/util/Duration.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/Duration.java 2009-12-25 05:17:14 UTC (rev 416) +++ csidex/trunk/src/main/java/edu/asu/commons/util/Duration.java 2009-12-28 07:16:34 UTC (rev 417) @@ -117,6 +117,10 @@ public long getTimeLeft() { return endTime - currentTime(); } + + public int getTimeLeftInSeconds() { + return toSeconds( getTimeLeft() ); + } public long getElapsedTime() { return currentTime() - startTime; Modified: csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2009-12-25 05:17:14 UTC (rev 416) +++ csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2009-12-28 07:16:34 UTC (rev 417) @@ -22,12 +22,12 @@ * @version $Revision$ */ -public abstract class Utils { +public final class Utils { // private final static Logger logger = Logger.getLogger(Utils.class.getName()); - private Utils() { - } + // cannot be instantiated or subclassed. + private Utils() { } public static void waitOn(final Object lock) { synchronized (lock) { @@ -160,6 +160,10 @@ } return list; } + + public static boolean isNullOrEmpty(String string) { + return (string == null) || string.isEmpty(); + } public static <T, R> List<R> map(Collection<T> in, MapOp<T, R> op) { List<R> out = new ArrayList<R>(in.size()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-12-25 05:17:30
|
Revision: 416 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=416&view=rev Author: alllee Date: 2009-12-25 05:17:14 +0000 (Fri, 25 Dec 2009) Log Message: ----------- merging r385:r415 into trunk Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EmbeddedChatPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GridView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ClientData.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Added Paths: ----------- foraging/trunk/src/main/java/TestEnforcement.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/RegulationPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/EnforcementMechanismUpdateEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/EnforcementRankingRequest.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/MonitorTaxEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/RegulationRankingRequest.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/RegulationSubmissionUpdateEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/RegulationUpdateEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/EnforcementMechanism.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ForagingRole.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/RegulationData.java foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/ foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round5.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round6.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round7.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml Removed Paths: ------------- foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round5.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round6.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round7.xml foraging/trunk/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml Property Changed: ---------------- foraging/trunk/ Property changes on: foraging/trunk ___________________________________________________________________ Added: svn:mergeinfo + /foraging/branches/deepak-branch-fall-09:386-415 Copied: foraging/trunk/src/main/java/TestEnforcement.java (from rev 415, foraging/branches/deepak-branch-fall-09/src/main/java/TestEnforcement.java) =================================================================== --- foraging/trunk/src/main/java/TestEnforcement.java (rev 0) +++ foraging/trunk/src/main/java/TestEnforcement.java 2009-12-25 05:17:14 UTC (rev 416) @@ -0,0 +1,33 @@ +import java.awt.Color; +import java.awt.Container; +import java.awt.FlowLayout; + +import javax.swing.JFrame; + +import edu.asu.commons.foraging.client.EnforcementPanel; + + +public class TestEnforcement { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + //ForagingClient client = new ForagingClient(); + + EnforcementPanel testEnforcement = new EnforcementPanel(); + testEnforcement.initialize(); + JFrame f = new JFrame("This is a test"); + f.setSize(1000, 1000); + Container content = f.getContentPane(); + content.setBackground(Color.white); + content.setLayout(new FlowLayout()); + content.add(testEnforcement); + //f.setDefaultCloseOperation(0); + f.setVisible(true); + + + } + +} Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2009-12-25 05:17:14 UTC (rev 416) @@ -102,7 +102,7 @@ add(targetHandlePanel, BorderLayout.NORTH); add(chatField, BorderLayout.CENTER); - add(sendButton, BorderLayout.SOUTH); +// add(sendButton, BorderLayout.SOUTH); setChatFieldFocus(); } @@ -199,6 +199,7 @@ setName("Chat panel"); messageWindow = new JTextPane(); messageWindow.setEditable(false); + messageWindow.setBackground(Color.WHITE); messageScrollPane = new JScrollPane(messageWindow); addStylesToMessageWindow(); @@ -249,13 +250,12 @@ chatInstructionsPane.setContentType("text/html"); chatInstructionsPane.setEditorKit(new HTMLEditorKit()); chatInstructionsPane.setEditable(false); + chatInstructionsPane.setBackground(Color.WHITE); JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); chatInstructionsPane.setText(client.getDataModel().getRoundConfiguration().getChatInstructions()); add(chatInstructionsScrollPane, BorderLayout.NORTH); add(messageScrollPane, BorderLayout.CENTER); - // if (client.getDataModel().getRoundConfiguration().shouldD - // add(participantButtonPanel, BorderLayout.EAST); add(textEntryPanel, BorderLayout.SOUTH); textEntryPanel.setChatFieldFocus(); } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java 2009-12-25 05:17:14 UTC (rev 416) @@ -16,6 +16,8 @@ private static final long serialVersionUID = 6400834001276229287L; + private static final double FUDGE_FACTOR = 0.1d; + private Point center; private final double radius; @@ -28,7 +30,7 @@ if (point == null) { throw new IllegalArgumentException("Null point passed to Circle.contains()"); } - return center.distance(point) <= radius; + return center.distance(point) <= (radius + FUDGE_FACTOR); } public void setCenter(Point center) { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-12-25 05:17:14 UTC (rev 416) @@ -14,8 +14,10 @@ import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.model.ClientData; +import edu.asu.commons.foraging.model.EnforcementMechanism; import edu.asu.commons.foraging.model.ForagingDataModel; import edu.asu.commons.foraging.model.GroupDataModel; +import edu.asu.commons.foraging.model.RegulationData; import edu.asu.commons.foraging.model.Resource; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Duration; @@ -39,7 +41,7 @@ // FIXME: can obtain tokensConsumed from the clientDataMap now. private int currentTokens; - + // these are the subjects whom we have sanctioned private Map<Identifier, Duration> sanctioned = new HashMap<Identifier, Duration>(); @@ -57,9 +59,27 @@ public void toggleExplicitCollectionMode() { explicitCollectionMode = !explicitCollectionMode; - client.transmit(new ExplicitCollectionModeRequest(client.getId(), - explicitCollectionMode)); + client.transmit(new ExplicitCollectionModeRequest(client.getId(), explicitCollectionMode)); } + + public Identifier getMonitorId() { + if (groupDataModel.getActiveMonitor() != null) { + return groupDataModel.getActiveMonitor().getId(); + } + return Identifier.NULL; + } + + public boolean isSanctioningAllowed() { + return getClientData().isSanctioningAllowed() || isSanctioningEnabled(); + } + + public boolean isHarvestingAllowed() { + return getClientData().isHarvestingAllowed(); + } + + public boolean isMonitor() { + return getClientData().getForagingRole().isMonitor(); + } /* * public Map<Identifier, Duration> getSanctioned() { return sanctioned; } @@ -101,7 +121,17 @@ groupDataModel = null; } } - + + public List<RegulationData> getSubmittedRegulations() { + return groupDataModel.getSubmittedRegulations(); + } + + public EnforcementMechanism getActiveEnforcementMechanism() { + return groupDataModel.getActiveEnforcementMechanism(); + } + + + public void initialize(GroupDataModel groupDataModel) { clear(); this.groupDataModel = groupDataModel; @@ -257,4 +287,12 @@ public Set<Resource> getRemovedResources() { return groupDataModel.getRemovedResources(); } + + public void setActiveRegulation(RegulationData regulationData) { + groupDataModel.setActiveRegulation(regulationData); + } + + public RegulationData getActiveRegulation() { + return groupDataModel.getActiveRegulation(); + } } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EmbeddedChatPanel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EmbeddedChatPanel.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EmbeddedChatPanel.java 2009-12-25 05:17:14 UTC (rev 416) @@ -34,7 +34,7 @@ /** * $Id$ * - * Chat panel used to communicate with other players. + * Chat panel used to communicate with other players within the 3D foraging visualization. * * FIXME: randomize mappings from handle (e.g., A -> 1, B -> 2, C -> 3 ...) so that it's * not linear. Copied: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java (from rev 415, foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java) =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java 2009-12-25 05:17:14 UTC (rev 416) @@ -0,0 +1,363 @@ +package edu.asu.commons.foraging.client; + + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ScrollPaneConstants; + +import edu.asu.commons.foraging.event.EnforcementRankingRequest; +import edu.asu.commons.foraging.model.EnforcementMechanism; +import edu.asu.commons.net.Identifier; + +/** + * $Id: EnforcementPanel.java 45 2008-08-21 00:47:39Z dbarge $ + * + * Enforcement panel is used to vote enforcement mechanism + * + * @author dbarge + * @version $Revision: 45 $ + */ + +@SuppressWarnings("serial") +public class EnforcementPanel extends JPanel { + + private ForagingClient client; + + + private String[] votes = { "1", "2", "3","4"}; + private EnforcementMechanism[] enforcementOptions = EnforcementMechanism.values(); + // private String[] enforcementOptions = { + // "No Enforcement - Click here for more info ", + // "Everyone sanctions - Click here for more info ", + // "Randomly picked monitering - Click here for more info", + // "Random sanctioning - Click here for more info " + // }; + + private String[] enforcementText = { + "Everybody can harvest. Nobody can subtract tokens<br>" + + "from others<br>", + + "Each participant can reduce the token amount of<br>" + + "another participant by two tokens at a cost of <br>" + + "one by pressing the numeric key that identifies<br>" + + "the other participant.<br>", + + "Randomly one of the participants is selected to<br>" + + "be the monitoring participant. This participant<br>" + + "can not harvest, but can force another particip<br>" + + "ant to pay a token to the monitoring participan<br>" + + "by pressing the responding numeric key. At the <br>" + + "end of the round each participant who could har<br>" + + "vest pays 25% of the earning to the monitoring <br>" + + "participant.<br>", + + "Same as two, but now each participant takes turns<br>" + + "of 48 seconds randomly assigned by the computer.<br>" + }; + + public EnforcementPanel (ForagingClient client) { + this(); + this.client = client; + this.clientId = client.getId(); + } + + private Identifier clientId; + private JPanel votingPanel; +// private JButton reset; +// private JButton sendMyVotes; + private JPanel instructionsPanel; + private SixChoicePanel[] newPanel; + + private int noOfEnforcements = EnforcementMechanism.values().length; + + private int currentRankingInformation[]; + + private JPanel buttonPanel; + + public EnforcementPanel () + { + newPanel = new SixChoicePanel[4]; + } + + public String getVotedEnforcementOptions(int index){ + return this.enforcementText[index]; + } + + private JPanel getInstructionPanel() + { + JPanel instructionPanel = new JPanel(); + + //instructionPanel.setBackground(color); + instructionPanel.setLayout(new BoxLayout(instructionPanel, BoxLayout.X_AXIS)); + instructionPanel.setBorder(BorderFactory.createTitledBorder("Enforcement Instructions")); + + //create Text area and JSCroll pane for it + String instructions = client.getDataModel().getRoundConfiguration().getVotingInstructions(); + + JTextArea instructionText = new JTextArea(instructions,3,50); + instructionText.setWrapStyleWord(true); + JScrollPane scrollForRegulationText = new JScrollPane(instructionText); + instructionPanel.add(scrollForRegulationText); + + return instructionPanel; + + } + + private Color getColor(int i) + { + Color color = null; + if(i==0) color = new Color(153,153,204); + if(i==1) color = new Color(204,153,153); + if(i==2) color = new Color(153,204,102); + if(i==3) color = new Color(204,204,102); + if(i==4) color = new Color(255,255,153); + return color; + } + + // FIXME: this is extremely inefficient, reimplement later + private void updateVotingPanel(int currentActive){ + int r,c,i; + SixChoicePanel temp = null; +// boolean enableSendButton = true; + + + for(r = 0; r < noOfEnforcements; r++) + { + +// if(newPanel[r].currentRanking == -1)enableSendButton = false; + + if((newPanel[currentActive].currentRanking == newPanel[r].currentRanking) && (r != currentActive)) + { + newPanel[r].currentRanking = -1; + newPanel[r].group.clearSelection(); + } + } + + + for(r = 0; r < noOfEnforcements-1; r++) + { + for(c = 0; c < noOfEnforcements-1; c++) + { + if((newPanel[c].currentRanking > newPanel[c+1].currentRanking)&&(newPanel[c+1].currentRanking != -1)) + { + temp = newPanel[c]; + newPanel[c] = newPanel[c+1]; + newPanel[c+1] = temp; + } + if((newPanel[c].currentRanking < newPanel[c+1].currentRanking)&&(newPanel[c].currentRanking == -1)) + { + temp = newPanel[c]; + newPanel[c] = newPanel[c+1]; + newPanel[c+1] = temp; + } + } + } + for(c = 0; c < noOfEnforcements; c++) + { + // System.out.print(newPanel[c].getCurrentRanking() +" "); + } + + votingPanel.setVisible(false); + remove(votingPanel); + votingPanel = new JPanel(); + votingPanel.setLayout(new BoxLayout(votingPanel, BoxLayout.Y_AXIS)); + + votingPanel.add(getInstructionPanel()); + + + for(i=0; i < noOfEnforcements; i++) { + votingPanel.add(newPanel[i].enforcementPanel); + } + + votingPanel.setVisible(true); + add(votingPanel, BorderLayout.CENTER); + +// if(enableSendButton) { +// sendMyVotes.setEnabled(true); +// buttonPanel.setVisible(true); +// add(buttonPanel, BorderLayout.SOUTH); +// } + revalidate(); + } + + private String getVoteString(){ + + StringBuilder sb = new StringBuilder(); + + for(int c = 0; c < noOfEnforcements; c++) + { + sb.append("\nEnforcement "+(newPanel[c].getCurrentRanking()+1)); + } + return(sb.toString()); + } + + public void sendEnforcementVotes() { + int i; + for(i=0; i < noOfEnforcements; i++) { + if(newPanel[i].currentRanking == -1) + this.currentRankingInformation[i] = -1; + else + this.currentRankingInformation[i] = newPanel[i].getCurrentRanking(); + } + client.transmit(new EnforcementRankingRequest(clientId, currentRankingInformation)); + } + + public void initGuiComponents(){ + + // remove(enforcementInstructionsScrollPane); + // remove(messageScrollPane); + this.currentRankingInformation = new int[4]; + this.newPanel = new SixChoicePanel[4]; + setBackground(Color.lightGray); + setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + + votingPanel = new JPanel(); + votingPanel.setLayout(new BoxLayout(votingPanel, BoxLayout.Y_AXIS)); + + //add the instruction panel as the first panel in voting panel. + instructionsPanel = getInstructionPanel(); + votingPanel.add(instructionsPanel); + + + + + for(int i=0; i<noOfEnforcements; i++) { + + //newPanel[i] = new SixChoicePanel(s, votes, enforcementData.getEnforcementID(), getColor(i)); + //newPanel[i] = new SixChoicePanel(s, votes, client.getEnforcementID(), getColor(i)); + newPanel[i] = new SixChoicePanel(enforcementOptions[i], votes, i, getColor(i)); + votingPanel.add(newPanel[i].getEnforcementPanel(i)); + } + + add(votingPanel, BorderLayout.CENTER); +// reset = new JButton("Reset All Ranks"); +// reset.setAlignmentX(Component.CENTER_ALIGNMENT); +// reset.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// for(int i=0; i<noOfEnforcements; i++) { +// for(int j=0; j<noOfEnforcements; j++) { +// newPanel[i].option[j].setEnabled(true); +// newPanel[i].group.clearSelection(); +// newPanel[i].currentRanking = -1; +// } +// } +// } +// }); +// sendMyVotes = new JButton("Send votes"); +// sendMyVotes.setAlignmentX(Component.CENTER_ALIGNMENT); +// sendMyVotes.setEnabled(false); +// sendMyVotes.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// +// int n = JOptionPane.showConfirmDialog( +// null, "Are you sure to submit your votes ?"+ +// "\nBelow is order of your voting" + +// getVoteString(), +// "Confirm and send votes", +// JOptionPane.YES_NO_OPTION); +// +// if (n == JOptionPane.YES_OPTION) { +// GameWindow2D.duration.expire(); +// } +// if (n == JOptionPane.NO_OPTION) { +// +// } +// +// } +// }); +// buttonPanel = new JPanel(); +// //buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); +// buttonPanel.setLayout(new GridLayout(1,2)); +// buttonPanel.add(reset); +// buttonPanel.add(sendMyVotes); +// buttonPanel.setVisible(true); +// buttonPanel.repaint(); +// add(buttonPanel, BorderLayout.SOUTH); + } + + public void initialize() { + initGuiComponents(); + } + + private class SixChoicePanel implements ActionListener{ + String title; + String description; + String [] buttonLabels; + int enforcementID; + int currentRanking; + JPanel enforcementPanel; + JPanel rankPanel; + ButtonGroup group; + JRadioButton option []; + Color color; + + + public SixChoicePanel(EnforcementMechanism enforcementMechanism, String[] buttonLabels, int enforcementID, Color color ) { + this.title = enforcementMechanism.getTitle(); + this.description = enforcementMechanism.getDescription(); + this.buttonLabels = buttonLabels; + this.enforcementID = enforcementID; + this.color = color; + this.currentRanking = -1; + this.option = new JRadioButton[4]; + } + public int getCurrentRanking(){ + return enforcementID; + } + + public void actionPerformed(ActionEvent e) { + String choice = group.getSelection().getActionCommand(); + int buttonNo = Integer.parseInt(choice); + System.out.println("ACTION Choice Selected: " + choice); + System.out.println("Bno: " + buttonNo); + System.out.println("CurrentActive : "+this.enforcementID); + this.currentRanking = buttonNo; + updateVotingPanel(this.enforcementID); + } + + + public JPanel getEnforcementPanel(int i){ + enforcementPanel = new JPanel(); + enforcementPanel.setBackground(color); + enforcementPanel.setLayout(new BoxLayout(enforcementPanel, BoxLayout.Y_AXIS)); + enforcementPanel.setBorder(BorderFactory.createTitledBorder(title)); + + //create Text area and JSCroll pane for it + + JTextArea regulationText = new JTextArea(title,3,50); + regulationText.setText(description); + regulationText.setWrapStyleWord(true); + JScrollPane scrollForRegulationText = new JScrollPane(regulationText); + enforcementPanel.add(scrollForRegulationText); + + rankPanel = new JPanel(); + rankPanel.setBackground(color); + rankPanel.setLayout(new BoxLayout(rankPanel, BoxLayout.X_AXIS)); + rankPanel.setBorder(BorderFactory.createTitledBorder("Rank")); + group = new ButtonGroup(); + int length = buttonLabels.length; // Assumes even length + + for(int j=0; j<length; j++) { + option[j] = new JRadioButton(buttonLabels[j]); + option[j].setActionCommand(buttonLabels[j]); + group.add(option[j]); + option[j].addActionListener(this); + rankPanel.add(option[j]); + } + enforcementPanel.add(rankPanel); + return enforcementPanel; + } + + } + +} Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java 2009-12-25 05:17:14 UTC (rev 416) @@ -8,6 +8,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import edu.asu.commons.client.BaseClient; import edu.asu.commons.event.ClientMessageEvent; @@ -23,10 +24,13 @@ import edu.asu.commons.foraging.event.ClientPositionUpdateEvent; import edu.asu.commons.foraging.event.CollectTokenRequest; import edu.asu.commons.foraging.event.EndRoundEvent; +import edu.asu.commons.foraging.event.EnforcementMechanismUpdateEvent; import edu.asu.commons.foraging.event.LockResourceEvent; import edu.asu.commons.foraging.event.PostRoundSanctionRequest; import edu.asu.commons.foraging.event.PostRoundSanctionUpdateEvent; import edu.asu.commons.foraging.event.RealTimeSanctionRequest; +import edu.asu.commons.foraging.event.RegulationSubmissionUpdateEvent; +import edu.asu.commons.foraging.event.RegulationUpdateEvent; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; @@ -65,8 +69,9 @@ private ClientDataModel dataModel; private MessageQueue messageQueue; - private JPanel panel = new JPanel(); + private JPanel clientPanel = new JPanel(); + public ForagingClient(ServerConfiguration configuration) { this(configuration, new Dimension(800, 600)); } @@ -77,12 +82,11 @@ if (configuration.shouldInitialize2D()) { gameWindow2D = new GameWindow2D(this, screenSize); } - if (configuration.shouldInitialize3D()) { + else if (configuration.shouldInitialize3D()) { gameWindow3D = new GameWindow3D(this); } - panel.setLayout(new BorderLayout()); - panel.add(configuration.getCurrentParameters().is2dExperiment() - ? gameWindow2D : gameWindow3D.getPanel(), + clientPanel.setLayout(new BorderLayout()); + clientPanel.add(configuration.getCurrentParameters().is2dExperiment() ? gameWindow2D : gameWindow3D.getPanel(), BorderLayout.CENTER); } @@ -108,7 +112,7 @@ return gameWindow3D; } } - + public void sendAvatarInfo(boolean male, Color hairColor, Color skinColor, Color shirtColor, Color trouserColor, Color shoesColor) { transmit(new AgentInfoRequest(getId(), male, hairColor, skinColor, shirtColor, trouserColor, shoesColor)); gameWindow3D.removeAgentDesigner(); @@ -128,19 +132,19 @@ dataModel.setRoundConfiguration(configuration); SwingUtilities.invokeLater(new Runnable() { public void run() { - panel.removeAll(); - panel.invalidate(); + clientPanel.removeAll(); + clientPanel.invalidate(); if (dataModel.is2dExperiment()) { - panel.add(gameWindow2D, BorderLayout.CENTER); + clientPanel.add(gameWindow2D, BorderLayout.CENTER); if (gameWindow3D != null) { gameWindow3D.dispose(); } } else { - panel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); + clientPanel.add(gameWindow3D.getPanel(), BorderLayout.CENTER); } - panel.validate(); - panel.repaint(); + clientPanel.validate(); + clientPanel.repaint(); getGameWindow().init(); } }); @@ -163,11 +167,13 @@ state = ClientState.RUNNING; } }); + addEventProcessor(new EventTypeProcessor<EndRoundEvent>(EndRoundEvent.class) { public void handle(final EndRoundEvent event) { if (state == ClientState.RUNNING) { dataModel.setGroupDataModel(event.getGroupDataModel()); getGameWindow().endRound(event); + getGameWindow().resetPanels(); if (dataModel.is2dExperiment()) { messageQueue.stop(); } @@ -221,17 +227,37 @@ addEventProcessor(new EventTypeProcessor<ClientMessageEvent>(ClientMessageEvent.class) { public void handle(ClientMessageEvent event) { - gameWindow2D.displayErrorMessage(event.toString()); + gameWindow2D.displayErrorMessage(event.toString(),0); } }); + addEventProcessor(new EventTypeProcessor<EnforcementMechanismUpdateEvent>(EnforcementMechanismUpdateEvent.class) { + public void handle(final EnforcementMechanismUpdateEvent event) { + dataModel.setGroupDataModel(event.getGroupDataModel()); + gameWindow2D.displayActiveEnforcementMechanism(); + } + }); + addEventProcessor(new EventTypeProcessor<RegulationSubmissionUpdateEvent>(RegulationSubmissionUpdateEvent.class) { + public void handle(final RegulationSubmissionUpdateEvent event) { + dataModel.setGroupDataModel(event.getGroupDataModel()); + gameWindow2D.initializeRegulationVotingPanel(); + } + }); + addEventProcessor(new EventTypeProcessor<RegulationUpdateEvent>(RegulationUpdateEvent.class) { + public void handle(final RegulationUpdateEvent event) { + dataModel.setActiveRegulation(event.getRegulationData()); + gameWindow2D.displayActiveRegulation(); + } + }); } public boolean canPerformRealTimeSanction() { - return dataModel.getRoundConfiguration().isRealTimeSanctioningEnabled() && dataModel.getCurrentTokens() > 0; + return dataModel.isMonitor() + || (dataModel.isSanctioningAllowed() && dataModel.getCurrentTokens() > 0); } public void transmit(PostRoundSanctionRequest request) { if (state == ClientState.WAITING) { + //System.out.println("Sending post round sanction request"); gameWindow2D.switchInstructionsPane(); super.transmit(request); } @@ -255,7 +281,7 @@ private int messagesSent; // samples are collected over 3 seconds. - private final static int SAMPLE_TIME = 3; +// private final static int SAMPLE_TIME = 3; private int totalMessagesPerSample; private int averageMessagesPerSecond; @@ -304,10 +330,6 @@ System.err.println("Discarding event: " + request + " - already sent " + messagesSent); } } - - public void clear() { - stop(); - } public void start() { running = true; @@ -346,10 +368,6 @@ // } // } - public int size() { - return actions.size(); - } - private void tick() { if (secondTick.hasExpired()) { secondTick.restart(); @@ -389,15 +407,25 @@ public static void main(String[] args) { Runnable createGuiRunnable = new Runnable() { public void run() { - Dimension defaultDimension = new Dimension(800, 600); - JFrame frame = new JFrame(); + //System.out.println("inside client"); + //Dimension defaultDimension = new Dimension(600, 600); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch(Exception e) { + e.printStackTrace(); + System.err.println("Couldn't set native look and feel: "+ e); + } + Dimension defaultDimension = new Dimension(600, 600); + JFrame frame = new JFrame(); ForagingClient client = new ForagingClient(new ServerConfiguration(), defaultDimension); client.connect(); frame.setTitle("Client Window: " + client.getId()); frame.setSize(defaultDimension); - frame.add(client.panel); + frame.add(client.clientPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); + } }; SwingUtilities.invokeLater(createGuiRunnable); Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow.java 2009-12-25 05:17:14 UTC (rev 416) @@ -17,5 +17,6 @@ public void init(); public void update(long millisecondsLeft); public void showInstructions(); + public void resetPanels(); } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-24 22:42:09 UTC (rev 415) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-25 05:17:14 UTC (rev 416) @@ -1,5 +1,6 @@ package edu.asu.commons.foraging.client; + import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -21,11 +22,13 @@ import java.util.Map; import java.util.Properties; +import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.Timer; @@ -45,6 +48,7 @@ import edu.asu.commons.foraging.event.QuizCompletedEvent; import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; +import edu.asu.commons.foraging.event.SubmitRegulationRequest; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; import edu.asu.commons.net.Identifier; @@ -70,21 +74,39 @@ // the data model private final ClientDataModel dataModel; - // instructions components. - + // instructions components. + private Component currentCenterComponent; - + private JScrollPane instructionsScrollPane; - private HtmlEditorPane instructionsEditorPane; - + private HtmlEditorPane instructionsEditorPane; + private JPanel messagePanel; private JScrollPane errorMessageScrollPane; private JTextPane errorMessageTextPane; private JPanel labelPanel; + + // FIXME: this shouldn't be public + public static Duration duration; + private ChatPanel chatPanel; + public final static String[] roleDescription = { + "Monitor: You cannot harvest but can sanction other participants\n" + + "To sanction press numbers from 1-5. At the end of the round you\n" + + "will receive 25% tokens from every other participant", + "Harvest: You can collect tokens as in earlier rounds. But you \n" + + "cannot sanction", + "Sanction: You cannot harvest but only sanction \n", + "Harvest and Sanction: You can collect tokens and at the same & \n" + + "at the same time sanction other participants"}; + + private RegulationPanel regulationPanel; + + private EnforcementPanel enforcementPanel; + private JLabel informationLabel; private JLabel timeLeftLabel; @@ -92,17 +114,26 @@ private JPanel subjectWindow; private ForagingClient client; - + private SubjectView subjectView; - private Timer timer; + public Timer timer; + public static final Object regulationSignal = new Object(); + + public static final Object enforcementVotesSignal = new Object(); + + public static final Object regulationVotesSignal = new Object(); + + public static final Object clientRoleSignal = new Object(); + private final StringBuilder instructionsBuilder = new StringBuilder(); - + private EventChannel channel; - + + private CardLayout cardLayout; - + // private EnergyLevel energyLevel; public GameWindow2D(ForagingClient client, Dimension size) { @@ -110,11 +141,12 @@ this.dataModel = client.getDataModel(); // FIXME: set the actual screen size dimensions after this JPanel has been initialized... this.channel = client.getEventChannel(); - // feed subject view the avaiable screen size so that + // feed subject view the available screen size so that // it can adjust appropriately when given a board size Dimension subjectViewSize = new Dimension((int) Math.floor(size.getWidth()), (int) Math.floor(size.getHeight() * 0.85)); subjectView = new SubjectView(subjectViewSize, dataModel); + // subjectView.addKeyListener(this); initGuiComponents(); } @@ -136,6 +168,8 @@ }); } + + /** * In certain cases, init() _can_ be called before endRound() is finished. Need to lock * access! @@ -148,22 +182,22 @@ } // don't display next round time, instead wait for the // facilitator signal. - + timeLeftLabel.setText("Waiting for facilitator's signal."); informationLabel.setText("Waiting for facilitator's signal."); // add the next round instructions to the existing debriefing text set by the previous // EndRoundEvent. } - - - + + + private ActionListener createQuizListener(final RoundConfiguration configuration) { return new ActionListener() { public void actionPerformed(ActionEvent e) { // System.err.println("In action performed with event: " + e); HtmlEditorPane.FormActionEvent formEvent = (HtmlEditorPane.FormActionEvent) e; Properties actualAnswers = formEvent.getData(); -// actualAnswers.list(System.err); + // actualAnswers.list(System.err); List<String> incorrectAnswers = new ArrayList<String>(); // iterate through expected answers for (Map.Entry<String, String> entry : configuration.getQuizAnswers().entrySet()) { @@ -200,16 +234,112 @@ subjectView.collectToken(position); } + private void startRegulationDisplayTimer(){ + if (timer == null) { + final Duration duration = Duration.create(dataModel.getRoundConfiguration().getRegulationDisplayDuration()); + timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (duration.hasExpired()) { + timeLeftLabel.setText("Regulation voting will start soon."); + timer.stop(); + timer = null; + initializeEnforcementVotingPanel(); + } + else { + timeLeftLabel.setText( String.format("Voting for the enforcement mechanism will start in %d seconds.", duration.getTimeLeft() / 1000L) ); + } + } + }); + timer.start(); + } + } + + private void startEnforcementVotingTimer() { + + if (timer == null) { + //FIXME: Need to fetch this value from the round4.xml + duration = Duration.create(dataModel.getRoundConfiguration().getEnforcementVotingDuration()); + timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (duration.hasExpired()) { + timeLeftLabel.setText("Voting is now disabled."); + timer.stop(); + timer = null; + getEnforcementPanel().sendEnforcementVotes(); + displayVotingWaitMessage(); + } + else { + timeLeftLabel.setText( String.format("Voting period will end in %d seconds.", duration.getTimeLeft() / 1000L) ); + } + } + }); + timer.start(); + } + } + + + private void startRegulationVotingTimer() { + + if (timer == null) { + duration = Duration.create(dataModel.getRoundConfiguration().getRegulationVotingDuration()); + + timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (duration.hasExpired()) { + timeLeftLabel.setText("Voting is now disabled. Next round begins shortly."); + + //new code + //Need to add the enforcementVotingPane over here + //instead of the instructionsScrollPane + timer.stop(); + timer = null; + //remove(sanctioningPanel); + //getSanctioningPanel().stopTimer(); + getRegulationPanel().sendRegulationVotes(); + displayVotingWaitMessage(); + } + else { + timeLeftLabel.setText( String.format("Voting period will end in %d seconds.", duration.getTimeLeft() / 1000L) ); + } + } + }); + timer.start(); + } + } + + + private void startRegulationSubmissionTimer() { + if (timer == null) { + duration = Duration.create(dataModel.getRoundConfiguration().getRegulationSubmissionDuration()); + timer = new Timer(1000, new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (duration.hasExpired()) { + timeLeftLabel.setText("Time's up."); + timer.stop(); + timer = null; + String regulation = regulationTextArea.getText(); + client.transmit(new SubmitRegulationRequest(client.getId(), regulation)); + displayVotingWaitMessage(); + } + else { + timeLeftLabel.setText( String.format("You have %d second(s) left to write your regulation.", duration.getTimeLeft() / 1000L) ); + } + } + }); + timer.start(); + } + } private void startChatTimer() { - if (timer == null) { - final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); + if (timer == null) { + // final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); + final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { if (duration.hasExpired()) { - timeLeftLabel.setText("Chat is now disabled. The next round will begin shortly."); - addCenterComponent(instructionsScrollPane); - timer.stop(); + timeLeftLabel.setText("Chat is now disabled."); + timer.stop(); timer = null; + initializeRegulationPanel(); } else { timeLeftLabel.setText( String.format("Chat will end in %d seconds.", duration.getTimeLeft() / 1000L) ); @@ -217,7 +347,7 @@ } }); timer.start(); - } + } } private String getInformationLabelText() { @@ -250,7 +380,7 @@ long secondsLeft = roundTimeLeft / 1000L; return "Time left: " + secondsLeft + " second(s)"; } - + private void setInstructions(String s) { instructionsEditorPane.setText(s); instructionsEditorPane.setCaretPosition(0); @@ -262,18 +392,25 @@ private HtmlEditorPane createInstructionsEditorPane() { // JEditorPane pane = new JEditorPane("text/html", - // "Costly Sanctioning Experiment"); + // "Costly Sanctioning Experiment"); final HtmlEditorPane htmlPane = new HtmlEditorPane(); htmlPane.setPreferredSize(new Dimension(400, 400)); htmlPane.setEditable(false); + htmlPane.setBackground(Color.WHITE); htmlPane.setFont(new Font("sansserif", Font.PLAIN, 12)); return htmlPane; } + private RegulationPanel updateRegulationVotingPanel(){ + RegulationPanel regulationPanel = getRegulationPanel(); + regulationPanel.initRegulationVotingComponents(); + return regulationPanel; + } + private void initGuiComponents() { // FIXME: replace with CardLayout for easier switching between panels -// cardLayout = new CardLayout(); - + // cardLayout = new CardLayout(); + setLayout(new BorderLayout(4, 4)); instructionsEditorPane = createInstructionsEditorPane(); instructionsScrollPane = new JScrollPane(instructionsEditorPane); @@ -284,6 +421,7 @@ subjectWindow.setBackground(Color.WHITE); subjectWindow.setForeground(Color.BLACK); subjectWindow.add(subjectView, BorderLayout.CENTER); + // setBackground(SubjectView.FIELD_OF_VISION_COLOR); setBackground(Color.WHITE); // replace with progress bar. timeLeftLabel = new JLabel("Connecting ..."); @@ -291,7 +429,20 @@ // latencyLabel = new JLabel("Latency: 0"); informationLabel.setBackground(Color.YELLOW); informationLabel.setForeground(Color.BLUE); - + + // getSanctioningPanel().initializeVotingPaneWithRegulations(); + + // regulationVotingPane = new JPanel(); + // //regulationVotingPane.setLayout(new BoxLayout(regulationVotingPane, BoxLayout.LINE_AXIS)); + // regulationVotingPane.setLayout(new BorderLayout(4,4)); + // + // regulationVotingIntructions = new JEditorPane(); + // regulationVotingIntructions.setContentType("text/html"); + // regulationVotingIntructions.setEditorKit(new HTMLEditorKit()); + // regulationVotingIntructions.setEditable(false); + // regulationVotingIntructions.setBorder(BorderFactory.createTitledBorder("Regulation voting instructions")); + // regulationVotingIntructionsScrollPane = new JScrollPane(regulationVotingIntructions); + labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); labelPanel.setBackground(Color.WHITE); @@ -299,14 +450,17 @@ labelPanel.add(Box.createHorizontalGlue()); labelPanel.add(informationLabel); add(labelPanel, BorderLayout.NORTH); - + // add message window. messagePanel = new JPanel(new BorderLayout()); -// messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS)); + // messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS)); messagePanel.add(new JLabel("System Messages"), BorderLayout.NORTH); errorMessageTextPane = new JTextPane(); errorMessageTextPane.setEditable(false); errorMessageTextPane.setFont(new Font("arial", Font.BOLD, 12)); + errorMessageTextPane.setBackground(Color.WHITE); + + addStyles(errorMessageTextPane.getStyledDocument()); errorMessageScrollPane = new JScrollPane(errorMessageTextPane); Dimension scrollPaneSize = new Dimension(getPreferredSize().width, 50); @@ -315,15 +469,16 @@ errorMessageScrollPane.setMaximumSize(scrollPaneSize); messagePanel.add(errorMessageScrollPane, BorderLayout.CENTER); add(messagePanel, BorderLayout.SOUTH); - - + + addKeyListener( createGameWindowKeyListener() ); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { requestFocusInWindow(); } }); - + + // resize listener addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent event) { Component component = event.getComponent(); @@ -331,12 +486,13 @@ Dimension size = new Dimension(component.getWidth(), subjectViewHeight); subjectView.setScreenSize(size); subjectView.setImageSizes(); - repaint(); + GameWindow2D.this.revalidate(); + GameWindow2D.this.repaint(); } }); // add component listeners, chat panel, and sanctioning window IF chat/sanctioning are enabled, and after the end of the round... } - + /** * IMPORTANT: this method handles client keyboard inputs within the game. * @return @@ -351,6 +507,7 @@ public void keyReleased(KeyEvent keyEvent) { keyReleased = true; } + // FIXME: refactor this method if possible. @Override public void keyPressed(KeyEvent keyEvent) { int keyChar = (int) keyEvent.getKeyChar(); @@ -363,13 +520,24 @@ switch (keyCode) { // token request handling case KeyEvent.VK_SPACE: - event = new CollectTokenRequest(client.getId()); + if(dataModel.isHarvestingAllowed()) { + event = new CollectTokenRequest(client.getId()); + } + else { + displayErrorMessage("You cannot harvest at this time.", 1); + } break; // real-time sanctioning keycode handling - case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_3: case KeyEvent.VK_4: - case KeyEvent.VK_5: case KeyEvent.VK_6: case KeyEvent.VK_7: case KeyEvent.VK_8: - case KeyEvent.VK_9: + case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_3: + case KeyEvent.VK_4: case KeyEvent.VK_5: case KeyEvent.VK_6: + case KeyEvent.VK_7: case KeyEvent.VK_8: case KeyEvent.VK_9: + if (! dataModel.isSanctioningAllowed()) { + // get rid of magic constants + displayErrorMessage("You aren't allowed to reduce other participants tokens at this time.", 1); + return; + } if (client.canPerformRealTimeSanction()) { + //System.out.println("Can do sanctioning"); int assignedNumber = keyChar - 48; Identifier sanctionee = dataModel.getClientId(assignedNumber); if (sanctionee == null || sanctionee.equals(dataModel.getId())) { @@ -379,11 +547,16 @@ // only allow sanctions for subjects within this subject's field of vision Point subjectPosition = dataModel.getClientDataMap().get(sanctionee).getPoint(); if (dataModel.getClientData().isSubjectInFieldOfVision(subjectPosition)) { + // System.out.println("sanctioning event sent"); event = new RealTimeSanctionRequest(dataModel.getId(), sanctionee); + // below function must be used for enforcement type4 dataModel.sanction(dataModel.getId(), sanctionee); + } + else { + displayErrorMessage("The participant is out of range ", 1); + return; } } - else return; break; // reset token distribution request handling case KeyEvent.VK_R: @@ -410,11 +583,11 @@ dataModel.getClientData().setPosition(newPosition); subjectView.repaint(); } - */ + */ } if (keyReleased) { // FIXME: have client directly render these requests? Would - // make the app more "responsive" and less tied to server latency. + // make the app more "responsive" and less tied to server latency. channel.handle(event); keyReleased = false; } @@ -422,7 +595,7 @@ }; } - + private boolean canResetTokenDistribution() { RoundConfiguration configuration = dataModel.getRoundConfiguration(); return configuration.isPracticeRound() && configuration.isPrivateProperty(); @@ -434,17 +607,17 @@ remove(currentCenterComponent); add(newCenterComponent, BorderLayout.CENTER); newCenterComponent.setVisible(true); - revalidate(); } currentCenterComponent = newCenterComponent; + revalidate(); } public void startRound() { final RoundConfiguration configuration = dataModel.getRoundConfiguration(); - if (timer != null) { - timer.stop(); - timer = null; - } + if (timer != null) { + timer.stop(); + timer = null; + } // currentExperimentConfiguration = configuration; Runnable runnable = new Runnable() { public void run() { @@ -462,11 +635,14 @@ }; SwingUtilities.invokeLater(runnable); } - - public void displayErrorMessage(String errorMessage) { + + public void displayErrorMessage(String errorMessage, int par) { // String chatHandle = getChatHandle(source); + if(par==1)errorMessageTextPane.setForeground(Color.RED); + else errorMessageTextPane.setForeground(Color.BLACK); + StyledDocument document = errorMessageTextPane.getStyledDocument(); - try { + try { document.insertString(document.getLength(), errorMessage + "\n", document.getStyle("bold")); errorMessageTextPane.setCaretPosition(document.getLength()); } @@ -475,7 +651,7 @@ throw new RuntimeException(e); } } - + // FIXME: add to some common GUI package? private void addStyles(StyledDocument styledDocument) { // and why not have something like... StyleContext.getDefaultStyle() to @@ -490,25 +666,26 @@ StyleConstants.setItalic(styledDocument .addStyle("italic", defaultStyle), true); } - + + private double getIncome(float numTokens) { if (dataModel.getRoundConfiguration().isPracticeRound()) { return 0.0f; } return dataModel.getRoundConfiguration().getDollarsPerToken() * numTokens; } - + private void addDebriefingText(EndRoundEvent event) { instructionsBuilder.delete(0, instructionsBuilder.length()); instructionsBuilder.append( String.format("<h3>Your stats in this round:</h3>" + - "<ul>" + - "<li>Tokens collected: %d</li>" + - "<li>Income: $%3.2f</li>" + + "<ul>" + + "<li>Tokens collected: %d</li>" + + "<li>Income: $%3.2f</li>" + "</ul>", event.getCurrentTokens(), getIncome(event.getCurrentTokens())) - ); + ); double showUpFee = dataModel.getRoundConfiguration().getParentConfiguration().getShowUpFee(); instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", showUpFee, dataModel.getTotalIncome() + showUpFee)); @@ -518,7 +695,7 @@ } setInstructions(instructionsBuilder.toString()); } - + private void postSanctionDebriefingText(final PostRoundSanctionUpdateEvent event) { instructionsBuilder.delete(0, instructionsBuilder.length()); ClientData clientData = event.getClientData(); @@ -538,7 +715,7 @... [truncated message content] |
Revision: 415 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=415&view=rev Author: alllee Date: 2009-12-24 22:42:09 +0000 (Thu, 24 Dec 2009) Log Message: ----------- configuration should be using these variables instead of hardcoded values Modified Paths: -------------- foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml Modified: foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml 2009-12-13 20:46:31 UTC (rev 414) +++ foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/round1.xml 2009-12-24 22:42:09 UTC (rev 415) @@ -38,7 +38,7 @@ <p> Each of you has been assigned a number from 1 to 5. The other four players will appear on the screen as blue dots -<img src="http://localhost:8080/foraging/images/gem-other.gif"> with a white +<img src="http://@CODEBASE_URL@/images/gem-other.gif"> with a white number embedded in the dot. On the top right corner of the screen you can see how many tokens each player has collected. </p> Modified: foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml 2009-12-13 20:46:31 UTC (rev 414) +++ foraging/branches/deepak-branch-fall-09/src/main/resources/configuration/asu-experiments/voting-regulation-enforcement/server.xml 2009-12-24 22:42:09 UTC (rev 415) @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Costly Sanctioning XML-ized experiment round configuration</comment> -<entry key="hostname">localhost</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">16001</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> 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-18 21:14:28
|
I'm checking out at 14:15 (2.5hr) I've commented a couple files, and changed a small bit of code, but will commit the next time i work On Fri, Dec 18, 2009 at 11:44 AM, Kalin Jonas <kj...@as...> wrote: > Working from home today at 11:45am > I will be working on commenting the rest of my code this time. > |