virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 28)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bitbucket <com...@bi...> - 2011-08-23 01:57:41
|
2 new changesets in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/fa62ea89ee26/ changeset: fa62ea89ee26 user: alllee date: 2011-08-23 03:56:57 summary: fixing slight typo affected #: 2 files (151 bytes) --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Wed Aug 17 13:27:14 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Mon Aug 22 18:56:57 2011 -0700 @@ -40,9 +40,7 @@ <entry key="quiz-instructions"><![CDATA[ <p> -Before we begin the practice round you need to answer the following questions -correctly. You can only continue when you have answered all questions -correctly. If an error is made you will need to answer the questions again. +Before we begin the practice round please answer the following questions. </p><br><form> @@ -93,11 +91,11 @@ </p><p> -Player 2 has the following decision to make. You have to chose for each of the 4 +Player 2 has the following decision to make. You have to choose for each of the 4 possible cases how much to receive from player 1 how much to keep and how much to -send back to player 1. -We ask you to fill in the tables for player 1 as well as for player 2, and we will -drawn whether you are player 1 or 2 after you have made the decisions. +send back to player 1. We ask you to fill in the tables for player 1 as well as for +player 2, and we will drawn whether you are player 1 or 2 after you have made the +decisions. </p><p> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/server.xml Wed Aug 17 13:27:14 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/server.xml Mon Aug 22 18:56:57 2011 -0700 @@ -62,7 +62,7 @@ In this experiment you can collect green diamond shaped tokens <img src="@CODEBASE_URL@/images/gem-token.gif"> and earn two cents for each collected token. To collect a token, move your yellow dot over a green token and press the <b>space -bar</b>. If you move over a token without pressing the <b>space bar</> you do NOT +bar</b>. If you move over a token without pressing the <b>space bar</b> you do NOT collect that token. </p> http://bitbucket.org/virtualcommons/foraging/changeset/5044409b38a8/ changeset: 5044409b38a8 user: alllee date: 2011-08-23 03:57:38 summary: adding pretest configuration, will create separate treatment config folders next. affected #: 8 files (36.6 KB) --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round0.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="resource-width">13</entry> +<entry key="resource-depth">13</entry> +<entry key="practice-round">true</entry> +<entry key="private-property">true</entry> +<entry key="duration">240</entry> + +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<entry key="quiz">true</entry> +<entry key="q1">C</entry> +<entry key="q2">B</entry> + +<entry key='instructions'> +<![CDATA[ +<h3>Practice Round Instructions</h3> +<hr> +<p> +You will now have four minutes to practice with the experimental environment. +The decisions you make in this round will NOT influence your earnings. At the +At the beginning of the practice round half of the cells are occupied +with green tokens. The environment is a 13 x 13 grid of cells. +</p> +<p> +During this practice round, and <b>only during</b> this practice round, you are able +to reset the tokens displayed on the screen by pressing the <b>R</b> key. When you +press the <b>R</b> key you will reset the resource to its initial distribution, +randomly filling half of the cells. +</p> +<p><b> Please do not communicate with any other participant.</b></p> +<p>If you have any questions please raise your hand. <b>Do you have any +questions so far?</b></p> +]]> +</entry> + +<entry key="quiz-instructions"> +<![CDATA[ +<p> +Before we begin the practice round please answer the following questions. +</p> +<br> +<form> +<span class='q1'>Q1. Which of the statements is <b><u>incorrect</u></b>?</span><br> +<input type="radio" name="q1" value="A">A. Your decisions of where to collect tokens affects the regeneration of tokens.<br> +<input type="radio" name="q1" value="B">B. When you have collected all tokens on the screen, no new tokens will appear.<br> +<input type="radio" name="q1" value="C">C. Tokens grow from the middle of the +screen.<br> +<input type="radio" name="q1" value="D">D. In order to collect a token you need +to press the space bar while your yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"> is on a cell with a token.<br> +<br><br> + +<span class='q2'>Q2. Which sequence of situations is <b><u>not possible</u></b>?</span><br> +<img src="@CODEBASE_URL@/images/question2.jpg"><br> +<input type="radio" name="q2" value="A">A<br> +<input type="radio" name="q2" value="B">B<br> +<input type="radio" name="q2" value="C">C<br> +<br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> + +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to choose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. We ask you to fill in the tables for player 1 as well as for +player 2, and we will drawn whether you are player 1 or 2 after you have made the +decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> + +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round1.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> +<entry key='in-round-chat-enabled'>true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 1 Instructions</h3> +<hr> +<p> +This is the first round of the experiment. The length of the round is 4 +minutes. As in the practice round you can collect green tokens but now +you will earn <b>two cents</b> for each token collected. You <b>cannot</b> +reset the distribution of green tokens. +</p> +<p> +In this round the renewable resource will become five times bigger. You will share this +larger environment with four other players in this room that have been randomly +selected. Each group's resource environment is distinct from the other groups. +</p> +<p> +Each of you has been assigned a number from 1 to 5. These numbers will remain the +same throughout the experiment but you will <b>not</b> be able to identify which +person in the room has been assigned which number, so your anonymity is guaranteed. +</p> + +<p> +The other four players will appear on the screen as blue dots +<img src="@CODEBASE_URL@/images/gem-other.gif"> with a white +number embedded in the dot. On the top right corner of the screen you can see +how many tokens each player has collected. On the top left corner of the screen you can see +a clock that displays the remaining time in the round.</p> +<p>Since you can only see the resource within your vision you may neither see all +the other participants nor all the resource units. The figure below indicates the +vision range compared to the whole environment</p> +<img src="@CODEBASE_URL@/images/vision-range.jpg"> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round2.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + + +<!-- enable field of vision for tokens and subjects --> +<entry key='initial-distribution'>.25</entry> + +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> +<entry key='in-round-chat-enabled'>true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 2 Instructions</h3> +<hr> +<p> +Round 2 is the same as round 1. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round3.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<!-- enable field of vision for tokens and subjects --> +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- resource regrowth parameters --> +<entry key="initial-distribution">.25</entry> + +<entry key='resource-generator'>mobile</entry> +<entry key='in-round-chat-enabled'>true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 3 Instructions</h3> +<hr> +<p> +Round 3 is the same as round 2. Except now the resources move. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round4.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,228 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<!-- enable field of vision for tokens and subjects --> +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key='in-round-chat-enabled'>true</entry> + +<!-- enable sanctioning --> +<entry key="sanction-type">real-time</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> + +<entry key='resource-generator'>top-bottom-patchy</entry> + + +<entry key="initial-distribution">.25</entry> + +<!-- enable quiz --> +<entry key='quiz'>true</entry> +<entry key='q1'>B</entry> +<entry key='q2'>C</entry> +<entry key='q3'>B</entry> +<entry key='q4'>B</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<hr> +<p> +Round 4 is the same as the previous two rounds with two exceptions. +</p> +<p> +The resource dynamics have changed. One section of the resource has a high growth +rate, and another section has a low growth rate. +</p> +<p> +During the next round you will have the option to reduce the earnings of another +participant at a cost to your own earnings. +</p> +<ul> +<li>If you press the numeric key 1-5 corresponding to another participant, you +will reduce the number of tokens they have collected in this round by two +tokens. This will also reduce your own token amount by one token. The decision +whether or when to use this option is up to you. +<li>When you reduce the number of tokens of another participant, they will +receive a message stating that you have reduced their tokens. Likewise, if +another participant reduces your number of tokens, you will also receive a +message. These messages will be displayed on the bottom of your screen. +<li>If your tokens are being reduced or you are reducing another participant's +tokens, you will receive some visual cues. When you are sanctioned your yellow dot will turn red briefly with a blue background. The participant sanctioning you will turn purple with a white background. +<li>You may sanction other participants as long as there are +tokens remaining on the screen and while both you and the other participant +have a positive number of tokens collected during the round. <b>Each time</b> +you press the numeric key corresponding to another participant your token +amount is reduced by <b>one</b>, and their token amount is reduced by +<b>two</b>. <b>Note:</b> You can only remove tokens from a participant that is +visible to you. +</ul> +<p> + +<p> +The length of this round is four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> +<entry key="quiz-instructions"> +<![CDATA[ +<p>Before the next round begins you must complete the quiz below. You can +only continue when you have answered all questions correctly. If an error is +made you will need to answer the questions again. +</p> + +<form> +<span class='q1'>Q1. Each time I press the numeric keys between 1-5 my tokens will be reduced +by:</span><br> +<input type="radio" name="q1" value="A">A. 0 tokens<br> +<input type="radio" name="q1" value="B">B. 1 token<br> +<input type="radio" name="q1" value="C">C. 2 tokens<br> +<input type="radio" name="q1" value="D">D. 4 tokens<br> +<br><br> + +<span class='q2'>Q2. Each time I press the numeric keys between 1-5 the number of tokens of the +corresponding participant is reduced by:</span><br> +<input type="radio" name="q2" value="A">A. 0 tokens<br> +<input type="radio" name="q2" value="B">B. 1 token<br> +<input type="radio" name="q2" value="C">C. 2 tokens<br> +<input type="radio" name="q2" value="D">D. 4 tokens<br> +<br><br> + +<span class='q3'>Q3. The background of your yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"> turns blue. What does this represent?</span><br> +<input type="radio" name="q3" value="A">A. You collected a token<br> +<input type="radio" name="q3" value="B">B. Another participant is subtracting two +tokens from you<br> +<input type="radio" name="q3" value="C">C. You are subtracting two tokens from another +participant<br> +<input type="radio" name="q3" value="D">D. You are moving too fast<br> +<br><br> + +<span class='q4'>Q4. Every time I press the numeric keys between 1-5:</span><br> +<input type="radio" name="q4" value="A">A. Two tokens are subtracted from my tokens +collected this round<br> +<input type="radio" name="q4" value="B">B. One token is subtracted from my tokens +collected this round<br> +<input type="radio" name="q4" value="C">C. The background of my yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"> turns blue +momentarily<br> +<input type="radio" name="q4" value="D">D. My yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif"> is paused for two seconds<br> + +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round5.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<!-- enable field of vision for tokens and subjects --> +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> + +<!-- enable sanctioning --> +<entry key="sanction-type">real-time</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + + +<entry key="initial-distribution">.25</entry> +<entry key='resource-generator'>top-bottom-patchy</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 5 Instructions</h3> +<hr> +<p> +Round 5 is the same as round 4.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> + +<entry key='private-chat-instructions'> +<![CDATA[ +You may send private messages to a specific participant by clicking on the +appropriately labeled button (1, 2, 3, 4, or 5) before typing your message in +the chat box and sending it. By default you are communicating with all +members of your group. +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> + +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/round6.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key='tokens-field-of-vision'>true</entry> +<entry key='subjects-field-of-vision'>true</entry> +<!-- enable sanctioning --> +<entry key="sanction-type">real-time</entry> +<entry key="sanction-cost">1</entry> +<entry key="sanction-multiplier">2</entry> + +<entry key="initial-distribution">.25</entry> +<entry key='resource-generator'>top-bottom-patchy</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 6 Instructions</h3> +<hr> +<p> +Round 6 is the same as round 5.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="last-round-debriefing"> +<![CDATA[ +<p> +This was the last round, but not the end of the experiment. We will now +determine your payments. While we are doing this, we request that you +carefully fill out a brief survey. +</p> +<p> +When we are ready we will call you one by one to the room next door. We will +pay you there in private. Please wait until your computer number is called, +and then proceed to the room next door to turn in your computer number and +your survey. +</p> +<p> +Please answer the survey carefully and thank you for participating. +</p> +]]> +</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> + +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +</properties> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/pretest/server.xml Mon Aug 22 18:57:38 2011 -0700 @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Costly Sanctioning XML-ized experiment round configuration</comment> +<entry key="hostname">@SERVER_ADDRESS@</entry> +<entry key="port">@PORT_NUMBER@</entry> +<entry key="round0">round0.xml</entry> +<entry key="round1">round1.xml</entry> +<entry key="round2">round2.xml</entry> +<entry key="round3">round3.xml</entry> +<entry key="round4">round4.xml</entry> +<entry key="round5">round5.xml</entry> +<entry key="round6">round6.xml</entry> +<entry key="wait-for-participants">true</entry> +<entry key="number-of-rounds">7</entry> +<entry key="facilitator-instructions"> +<![CDATA[ +<h3>Facilitator Instructions</h3> +<p> +Welcome to the facilitator interface. This interface allows you to control +the experiment. You may only modify configuration parameters <b>before</b> +you start the experiment by selecting the Configuration menu. When all the +participants are ready to begin the experiment, you can start the experiment +by selecting Experiment -> Start. After a round has been completed you +will be able to view the statistics for all of the participants. You can +begin the next round by selecting Round -> Start. +</p> +]]> +</entry> + +<entry key='field-of-vision-instructions'> +<![CDATA[ +Your vision is limited in this experiment. The area that is visible to you will be +shaded. +]]> +</entry> + +<entry key="welcome-instructions"> +<![CDATA[ +<h3>Welcome to the experiment. The experiment will begin shortly after everyone has been +assigned a station.</h3> +<p> +Please <b>wait quietly</b> and <b>do not close this window or open any other applications</b>. +</p> +]]> +</entry> + +<entry key="general-instructions"> +<![CDATA[ +<h3>General Instructions</h3> +<p> +Welcome. You have already earned 5 dollars by showing up at this experiment. You can +earn more, up to a maximum of 40 dollars, by participating in this experiment, which +will take about an hour to an hour and a half. The amount of money you earn depends +on your decisions as well as the decisions of other people in this room during the +six rounds of the experiment. +</p> +<p> +You appear on the screen as a yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif">. +You move by pressing the four arrow keys on your keyboard. You can move up, down, +left, or right. You have to press a key for each and every move of your yellow dot. +In this experiment you can collect green diamond shaped tokens +<img src="@CODEBASE_URL@/images/gem-token.gif"> and earn two cents for each collected token. +To collect a token, move your yellow dot over a green token and press the <b>space +bar</b>. If you move over a token without pressing the <b>space bar</b> you do NOT +collect that token. +</p> + +<p> +The tokens that you collect have the potential to regenerate. After you have +collected a green token, a new token can re-appear on that empty cell. +However, the rate at which new tokens will appear depends on the number of +adjacent cells with tokens. The more tokens in the eight cells around +an empty cell, the faster a new token will appear on that empty cell. In other +words, <b>existing tokens can generate new tokens</b>. To illustrate this, please +refer to Image 1 and Image 2. The middle cell in Image 1 denoted with an X has +a greater chance of regeneration than the middle cell in Image 2. When all +neighboring cells are empty, there is <b>no chance for regeneration</b>. + +<table width="100%"> +<tr> +<td align="center"><b>Image 1</b></td> +<td align="center"><b>Image 2</b></td> +</tr> +<tr> +<td align="center"> +<img src="@CODEBASE_URL@/images/8neighbors.jpg" alt="image 1"> +</td> +<td align="center"> +<img src="@CODEBASE_URL@/images/5neighbors.jpg" alt="image 2"> +</td> +</tr> +</table> +]]> +</entry> + + +</properties> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-22 23:24:30
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/cbe705908b1b/ changeset: cbe705908b1b user: alllee date: 2011-08-23 01:24:16 summary: updated activity + availability data from 8/17 pretest affected #: 1 file (1.7 KB) --- a/vcweb/lighterprints/fixtures/initial_data.json Fri Aug 12 01:11:11 2011 -0700 +++ b/vcweb/lighterprints/fixtures/initial_data.json Mon Aug 22 16:24:16 2011 -0700 @@ -82,7 +82,7 @@ "summary": "Heating or cooling buildings less saves energy", "savings": "5.50", "cooldown": 1, - "icon": "lighterprints/activity-icons/93-thermometer.png", + "icon": "lighterprints/activity-icons/93-thermometer_1.png", "name": "adjust-thermostat" } }, @@ -92,14 +92,14 @@ "fields": { "display_name": "Eat locally grown food for lunch", "description": "The food we eat comes from all over the world. How much CO2 this emits depends on your specific location and menu. On average, a person in the USA can save 1,400 pounds of CO2 per year by switching to locally grown food. We assume that one lunch is equivalent of 1.5 pounds of CO2 saved.", - "available_all_day": true, + "available_all_day": false, "url": "http://www.huffingtonpost.com/bill-chameides/carbon-savings-at-home_b_113551.html", "level": 1, "group_activity": false, "summary": "Less energy is used for transportation when only locally grown food is consumed", "savings": "1.50", "cooldown": 1, - "icon": "lighterprints/activity-icons/80-shopping-cart.png", + "icon": "lighterprints/activity-icons/80-shopping-cart_1.png", "name": "eat-local-lunch" } }, @@ -116,7 +116,7 @@ "summary": "Your computer consumes less energy when it's asleep or turned off", "savings": "0.98", "cooldown": 1, - "icon": "lighterprints/activity-icons/69-display.png", + "icon": "lighterprints/activity-icons/69-display_1.png", "name": "enable-computer-sleep" } }, @@ -133,7 +133,7 @@ "summary": "Recycling processes used materials into new products to prevent waste of potentially useful materials.", "savings": "0.31", "cooldown": 1, - "icon": "lighterprints/activity-icons/142-wine-bottle.png", + "icon": "lighterprints/activity-icons/51-recycle.png", "name": "recycle" } }, @@ -148,9 +148,9 @@ "level": 1, "group_activity": false, "summary": "Carpooling is more energy efficient than travelling alone in your car.", - "savings": "2.85", + "savings": "9.40", "cooldown": 1, - "icon": "lighterprints/activity-icons/car.png", + "icon": "lighterprints/activity-icons/81-dashboard_1.png", "name": "share-your-ride" } }, @@ -165,9 +165,9 @@ "level": 2, "group_activity": false, "summary": "Reduce fossil fuel consumption and emissions by not driving a car", - "savings": "9.40", + "savings": "7.52", "cooldown": 1, - "icon": "lighterprints/activity-icons/102-walk.png", + "icon": "lighterprints/activity-icons/47-bicycle-to.png", "name": "bike-public-transport" } }, @@ -184,7 +184,7 @@ "summary": "Don't leave the water running while you're brushing your teeth", "savings": "0.76", "cooldown": 1, - "icon": "lighterprints/activity-icons/186-toothbrush.png", + "icon": "lighterprints/activity-icons/186-toothbrush_1.png", "name": "brushing-your-teeth" } }, @@ -201,7 +201,7 @@ "summary": "Save energy and turn off your computer when it's not needed.", "savings": "1.37", "cooldown": 1, - "icon": "lighterprints/activity-icons/screen_sleep_glossy.png", + "icon": "lighterprints/activity-icons/126-moon_1.png", "name": "computer-off" } }, @@ -218,7 +218,7 @@ "summary": "Beef production is very energy intensive", "savings": "4.26", "cooldown": 1, - "icon": "lighterprints/activity-icons/109-chicken.png", + "icon": "lighterprints/activity-icons/109-chicken_1.png", "name": "no-beef" } }, @@ -228,14 +228,14 @@ "fields": { "display_name": "Recycle paper", "description": "The average number of pounds of CO2 equivalent per person per year that could be saved by recycling paper is 14.86 pounds for magazines, 89.76 pounds for newspapers, and 100 pounds for junk mail. These add up to 0.56 pounds per day.", - "available_all_day": false, + "available_all_day": true, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 2, "group_activity": false, "summary": "Saving paper resources and production by recycling", "savings": "0.56", "cooldown": 1, - "icon": "lighterprints/activity-icons/166-newspaper.png", + "icon": "lighterprints/activity-icons/166-newspaper_1.png", "name": "recycle-paper" } }, @@ -252,7 +252,7 @@ "summary": "Air drying your clothes saves gas or electricity", "savings": "1.98", "cooldown": 1, - "icon": "lighterprints/activity-icons/67-tshirt.png", + "icon": "lighterprints/activity-icons/67-tshirt_1.png", "name": "air-dry-clothes" } }, @@ -269,7 +269,7 @@ "summary": "Reduce the amount of waste you produce at lunch time.", "savings": "1.37", "cooldown": 1, - "icon": "lighterprints/activity-icons/organic_1.bmp", + "icon": "lighterprints/activity-icons/48-fork-and-knife_1.png", "name": "green-lunch" } }, @@ -286,7 +286,7 @@ "summary": "Turning lights off in areas that don't need them saves energy.", "savings": "2.28", "cooldown": 1, - "icon": "lighterprints/activity-icons/84-lightbulb.png", + "icon": "lighterprints/activity-icons/84-lightbulb_1.png", "name": "lights-off" } }, @@ -303,7 +303,7 @@ "summary": "Raising animals for meat is resource intensive", "savings": "4.41", "cooldown": 1, - "icon": "lighterprints/activity-icons/lettuce.png", + "icon": "lighterprints/activity-icons/125-food_1.png", "name": "vegan-for-a-day" } }, @@ -320,11 +320,10 @@ "summary": "Save energy by not heating water", "savings": "1.10", "cooldown": 1, - "icon": "lighterprints/activity-icons/mwcold.png", + "icon": "lighterprints/activity-icons/24-washing-new.png", "name": "wash-cold-water" } }, - { "pk": 4, "model": "lighterprints.activityavailability", @@ -344,25 +343,25 @@ } }, { - "pk": 2, + "pk": 9, "model": "lighterprints.activityavailability", "fields": { "available_start_time": "08:00:00", "available_end_time": "10:00:00", - "activity": 10 + "activity": 3 } }, { - "pk": 3, + "pk": 17, "model": "lighterprints.activityavailability", "fields": { "available_start_time": "16:00:00", "available_end_time": "18:00:00", - "activity": 10 + "activity": 3 } }, { - "pk": 7, + "pk": 2, "model": "lighterprints.activityavailability", "fields": { "available_start_time": "18:00:00", @@ -383,9 +382,72 @@ "pk": 6, "model": "lighterprints.activityavailability", "fields": { - "available_start_time": "21:00:00", + "available_start_time": "22:00:00", "available_end_time": "23:59:59", "activity": 6 } + }, + { + "pk": 10, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "23:00:00", + "available_end_time": "07:00:00", + "activity": 7 + } + }, + { + "pk": 11, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "18:00:00", + "available_end_time": "19:00:00", + "activity": 9 + } + }, + { + "pk": 15, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "23:00:00", + "available_end_time": "06:00:00", + "activity": 14 + } + }, + { + "pk": 13, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "12:00:00", + "available_end_time": "14:00:00", + "activity": 13 + } + }, + { + "pk": 12, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "18:00:00", + "available_end_time": "23:00:00", + "activity": 11 + } + }, + { + "pk": 16, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "07:00:00", + "available_end_time": "09:00:00", + "activity": 12 + } + }, + { + "pk": 14, + "model": "lighterprints.activityavailability", + "fields": { + "available_start_time": "16:00:00", + "available_end_time": "23:00:00", + "activity": 15 + } } ] Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 20:27:20
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/1d4efd66a959/ changeset: 1d4efd66a959 user: alllee date: 2011-08-17 22:27:14 summary: almost ready. affected #: 17 files (4.4 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Wed Aug 17 13:27:14 2011 -0700 @@ -112,7 +112,7 @@ private void sendMessage() { String message = chatField.getText(); - // System.err.println("message: " + message); + System.err.println("sending message: " + message); if (message == null || "".equals(message) || targetIdentifier == null) { return; } @@ -134,7 +134,7 @@ private final static String HANDLE_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - private static String[] HANDLES; + private String[] HANDLES; private Identifier clientId; @@ -239,12 +239,17 @@ JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); chatInstructionsPane.setText(client.getCurrentRoundConfiguration().getChatInstructions()); - add(chatInstructionsScrollPane, BorderLayout.NORTH); +// add(chatInstructionsScrollPane, BorderLayout.NORTH); + add(new JLabel("In round chat"), BorderLayout.NORTH); add(messageScrollPane, BorderLayout.CENTER); add(textEntryPanel, BorderLayout.SOUTH); textEntryPanel.setChatFieldFocus(); } + public void setTextFieldFocus() { + textEntryPanel.setChatFieldFocus(); + } + public TextEntryPanel getTextEntryPanel() { return textEntryPanel; } --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 17 13:27:14 2011 -0700 @@ -283,7 +283,7 @@ * */ private class MessageQueue implements Runnable { - private final static int DEFAULT_MESSAGES_PER_SECOND = 8; + private final static int DEFAULT_MESSAGES_PER_SECOND = 10; private final LinkedList<Event> actions = new LinkedList<Event>(); @@ -360,6 +360,7 @@ // moveClient(request); transmit(request); } +// Utils.sleep(100); Thread.yield(); } } --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 17 13:27:14 2011 -0700 @@ -25,13 +25,13 @@ import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.Timer; -import javax.swing.text.BadLocationException; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; @@ -55,7 +55,6 @@ import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Duration; import edu.asu.commons.util.HtmlEditorPane; -import javax.swing.JEditorPane; @@ -123,8 +122,8 @@ this.channel = client.getEventChannel(); // 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)); +// int width = (int) Math.min(Math.floor(size.getWidth()), Math.floor(size.getHeight() * 0.85)); + Dimension subjectViewSize = new Dimension((int) size.getWidth(), (int) (size.getHeight() * 0.85)); subjectView = new SubjectView(subjectViewSize, dataModel); initGuiComponents(); } @@ -405,8 +404,9 @@ private void setInstructions(String s) { instructionsEditorPane.setText(s); instructionsEditorPane.setCaretPosition(0); - repaint(); + instructionsScrollPane.repaint(); instructionsScrollPane.requestFocusInWindow(); +// repaint(); } private HtmlEditorPane createInstructionsEditorPane() { @@ -449,24 +449,24 @@ labelPanel.add(informationLabel); add(labelPanel, BorderLayout.NORTH); - // add message window. - messagePanel = new JPanel(new BorderLayout()); - // messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS)); - messagePanel.add(new JLabel("Messages"), BorderLayout.NORTH); - messageTextPane = new JTextPane(); - messageTextPane.setEditable(false); - messageTextPane.setFont(new Font("arial", Font.BOLD, 12)); - messageTextPane.setBackground(Color.WHITE); - - - addStyles(messageTextPane.getStyledDocument()); - messageScrollPane = new JScrollPane(messageTextPane); - Dimension scrollPaneSize = new Dimension(getPreferredSize().width, 50); - messageScrollPane.setMinimumSize(scrollPaneSize); - messageScrollPane.setPreferredSize(scrollPaneSize); - messageScrollPane.setMaximumSize(scrollPaneSize); - messagePanel.add(messageScrollPane, BorderLayout.CENTER); - add(messagePanel, BorderLayout.SOUTH); +// // add message window. +// messagePanel = new JPanel(new BorderLayout()); +// // messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS)); +// messagePanel.add(new JLabel("Messages"), BorderLayout.NORTH); +// messageTextPane = new JTextPane(); +// messageTextPane.setEditable(false); +// messageTextPane.setFont(new Font("arial", Font.BOLD, 12)); +// messageTextPane.setBackground(Color.WHITE); +// +// +// addStyles(messageTextPane.getStyledDocument()); +// messageScrollPane = new JScrollPane(messageTextPane); +// Dimension scrollPaneSize = new Dimension(getPreferredSize().width, 50); +// messageScrollPane.setMinimumSize(scrollPaneSize); +// messageScrollPane.setPreferredSize(scrollPaneSize); +// messageScrollPane.setMaximumSize(scrollPaneSize); +// messagePanel.add(messageScrollPane, BorderLayout.CENTER); +// add(messagePanel, BorderLayout.SOUTH); addKeyListener( createGameWindowKeyListener() ); addMouseListener(new MouseAdapter() { @@ -479,13 +479,14 @@ addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent event) { Component component = event.getComponent(); - // offset by 35 to allow for chat message box + // offset by 35 to allow for message box int subjectViewHeight = component.getHeight() - 35; Dimension size = new Dimension(component.getWidth(), subjectViewHeight); subjectView.setScreenSize(size); subjectView.setImageSizes(); GameWindow2D.this.revalidate(); - GameWindow2D.this.repaint(); + currentCenterComponent.repaint(); +// GameWindow2D.this.repaint(); } }); // add component listeners, chat panel, and sanctioning window IF chat/sanctioning are enabled, and after the end of the round... @@ -557,6 +558,10 @@ } break; // reset token distribution request handling + case KeyEvent.VK_ENTER: + if (dataModel.getRoundConfiguration().isInRoundChatEnabled()) { + getChatPanel().setTextFieldFocus(); + } case KeyEvent.VK_R: if (canResetTokenDistribution()) { event = new ResetTokenDistributionRequest(client.getId()); @@ -608,6 +613,7 @@ } currentCenterComponent = newCenterComponent; revalidate(); + repaint(); } public void startRound() { @@ -629,11 +635,11 @@ if (configuration.isInRoundChatEnabled()) { ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(); - Dimension chatPanelSize = new Dimension(200, getSize().height); + Dimension chatPanelSize = new Dimension(250, getSize().height); chatPanel.setPreferredSize(chatPanelSize); add(chatPanel, BorderLayout.EAST); } - add(messagePanel, BorderLayout.SOUTH); +// add(messagePanel, BorderLayout.SOUTH); addCenterComponent(subjectWindow); requestFocusInWindow(); @@ -652,16 +658,16 @@ public void displayMessage(String errorMessage, Color color) { // String chatHandle = getChatHandle(source); - messageTextPane.setForeground(color); - StyledDocument document = messageTextPane.getStyledDocument(); - try { - document.insertString(document.getLength(), errorMessage + "\n", document.getStyle("bold")); - messageTextPane.setCaretPosition(document.getLength()); - } - catch (BadLocationException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } +// messageTextPane.setForeground(color); +// StyledDocument document = messageTextPane.getStyledDocument(); +// try { +// document.insertString(document.getLength(), errorMessage + "\n", document.getStyle("bold")); +// messageTextPane.setCaretPosition(document.getLength()); +// } +// catch (BadLocationException e) { +// e.printStackTrace(); +// throw new RuntimeException(e); +// } } // FIXME: add to some common GUI package? @@ -701,6 +707,10 @@ double showUpFee = dataModel.getRoundConfiguration().getParentConfiguration().getShowUpPayment(); instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", showUpFee, dataModel.getTotalIncome() + showUpFee)); + for (String trustGameLog: event.getTrustGameLog()) { + instructionsBuilder.append(trustGameLog); + } + if (event.isLastRound()) { instructionsBuilder.append(client.getDataModel().getRoundConfiguration().getLastRoundDebriefing()); timeLeftLabel.setText("The experiment is now over."); @@ -749,18 +759,21 @@ if (roundConfiguration.isTrustGameEnabled()) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); - JEditorPane instructionEditorPane = new JEditorPane(); - instructionEditorPane.setContentType("text/html"); - instructionEditorPane.setEditorKit(new HTMLEditorKit()); - instructionEditorPane.setEditable(false); - instructionEditorPane.setBackground(Color.WHITE); - JScrollPane scrollPane = new JScrollPane(instructionEditorPane); - instructionEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); + JEditorPane trustGameInstructionsEditorPane = new JEditorPane(); + trustGameInstructionsEditorPane.setContentType("text/html"); + trustGameInstructionsEditorPane.setEditorKit(new HTMLEditorKit()); + trustGameInstructionsEditorPane.setEditable(false); + trustGameInstructionsEditorPane.setBackground(Color.WHITE); + JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); + trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); panel.add(scrollPane, BorderLayout.NORTH); TrustGamePanel trustGamePanel = new TrustGamePanel(client); + trustGamePanel.setPreferredSize(new Dimension(300, 400)); panel.add(trustGamePanel, BorderLayout.CENTER); addCenterComponent(panel); + panel.revalidate(); + panel.repaint(); } } @@ -786,10 +799,13 @@ } setInstructions(instructionsBuilder.toString()); + switchInstructionsPane(); } public void switchInstructionsPane() { // instructionsEditorPane.setText("<b>Please wait while we compute your new token totals.</b>"); addCenterComponent(instructionsScrollPane); + revalidate(); + repaint(); } public void displayActiveEnforcementMechanism() { @@ -861,9 +877,13 @@ instructionsEditorPane.setText("Waiting for updated round totals from the server..."); addCenterComponent(instructionsScrollPane); } + if (chatPanel != null) { + remove(chatPanel); + chatPanel = null; + } // generate debriefing text from data culled from the Event addDebriefingText(event); - messageTextPane.setText(""); +// messageTextPane.setText(""); } }; try { @@ -880,7 +900,7 @@ public void run() { ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(); - remove( messagePanel ); +// remove( messagePanel ); addCenterComponent( chatPanel ); startChatTimer(); } --- a/src/main/java/edu/asu/commons/foraging/client/SubjectView.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/SubjectView.java Wed Aug 17 13:27:14 2011 -0700 @@ -70,6 +70,8 @@ * prior to invocation of this method. */ public void setup(RoundConfiguration configuration) { + viewSubjectsField = null; + viewTokensField = null; synchronized (collectedTokens) { collectedTokens.clear(); tokenFieldOfVision = configuration.isTokensFieldOfVisionEnabled(); @@ -150,6 +152,7 @@ int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); Point currentPosition = dataModel.getCurrentPosition(); if (subjectFieldOfVision) { + System.err.println("field of vision is set"); // paint a transparent circle centered on the current position of the subject. int radius = viewSubjectsRadius; viewSubjectsField.setCenter(currentPosition); @@ -169,6 +172,7 @@ for (Map.Entry<Identifier, ClientData> entry : positions.entrySet()) { Identifier id = entry.getKey(); Point subjectLocation = entry.getValue().getPosition(); + System.err.println("view subjects field: " + viewSubjectsField); // optimized conditional if (viewSubjectsField == null || id.equals(dataModel.getId()) || viewSubjectsField.contains(subjectLocation)) { // only draw if: --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Aug 17 13:27:14 2011 -0700 @@ -411,7 +411,7 @@ //Should always return true for 3d experiments public boolean isChatEnabled() { - return ! isPrivateProperty() && getBooleanProperty("chat-enabled"); + return ! isPrivateProperty() && (getBooleanProperty("chat-enabled") || isInRoundChatEnabled()); } public int getMaximumResourceAge() { @@ -557,15 +557,26 @@ instructionsBuilder.append("<hr><b>"); instructionsBuilder.append(getFieldOfVisionInstructions()).append("</b>"); } - if (isChatEnabled()) { + if (isCensoredChat()) { + instructionsBuilder.append("<hr><b>"); + instructionsBuilder.append(getCensoredChatInstructions()).append("</b>"); + } + else if (isInRoundChatEnabled()) { + instructionsBuilder.append("<hr><b>"); + instructionsBuilder.append(getInRoundChatInstructions()).append("</b>"); + } + else if (isChatEnabled()) { instructionsBuilder.append("<hr><b>"); // FIXME: hard-coded, need to make instructions template-able, perhaps // via FreeMarker or Velocity. instructionsBuilder.append("Before the beginning of this round you will be able to chat with the other members of your group for ").append(getChatDuration()).append(" seconds.</b>"); } - if (isCensoredChat()) { - instructionsBuilder.append("<hr><b>"); - instructionsBuilder.append(getCensoredChatInstructions()).append("</b>"); + String resourceGeneratorType = getResourceGeneratorType(); + if (resourceGeneratorType.equals("mobile")) { + instructionsBuilder.append("<hr>").append(getMobileResourceInstructions()); + } + else if (resourceGeneratorType.equals("top-bottom-patchy")) { + instructionsBuilder.append("<hr>").append(getPatchyResourceInstructions()); } // and add the quiz instructions if the quiz is enabled. @@ -575,9 +586,21 @@ } return instructionsBuilder; } + + private String getMobileResourceInstructions() { + return getProperty("mobile-resource-instructions", "The resource can move around in a semblance of free will / agency."); + } + + private String getPatchyResourceInstructions() { + return getProperty("patch-resource-instructiosn", "The resource is not uniformly distributed. There are patches of high growth and low growth."); + } + + private String getInRoundChatInstructions() { + return getProperty("in-round-chat-instructions", "You can chat during this round with all players visible on the screen."); + } public String getTrustGameInstructions() { - return getProperty("trust-game-instructions", "Instructions: You will be randomly matched with another person in your group."); + return getProperty("trust-game-instructions", "You will be randomly matched with another person in your group."); } } --- a/src/main/java/edu/asu/commons/foraging/event/EndRoundEvent.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/EndRoundEvent.java Wed Aug 17 13:27:14 2011 -0700 @@ -1,5 +1,6 @@ package edu.asu.commons.foraging.event; +import java.util.List; import java.util.Map; import edu.asu.commons.event.AbstractEvent; @@ -54,6 +55,10 @@ public int getTotalNumberOfTokens() { return clientData.getTotalTokens(); } + + public List<String> getTrustGameLog() { + return clientData.getTrustGameLog(); + } public boolean isLastRound() { return lastRound; --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Aug 17 13:27:14 2011 -0700 @@ -5,6 +5,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import java.util.Queue; import java.util.concurrent.TimeUnit; @@ -590,4 +591,8 @@ public void logTrustGameEarnings(String log) { trustGameLog.add(log); } + + public List<String> getTrustGameLog() { + return trustGameLog; + } } --- a/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java Wed Aug 17 13:27:14 2011 -0700 @@ -90,7 +90,7 @@ } public void initialize(RoundConfiguration roundConfiguration) { - Type resourceGeneratorType = Type.find( roundConfiguration.getResourceGeneratorType() ); + ResourceDispenser.Type resourceGeneratorType = ResourceDispenser.Type.find( roundConfiguration.getResourceGeneratorType() ); currentResourceGenerator = getResourceGenerator( resourceGeneratorType ); currentResourceGenerator.initialize(roundConfiguration); } --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Aug 17 13:27:14 2011 -0700 @@ -397,10 +397,15 @@ } public void calculateTrustGame(ClientData playerOne, ClientData playerTwo) { + if (playerOne.getId().equals(playerTwo.getId())) { + logger.warning("Tried to calculate trust game with self, aborting"); + return; + } double p1AmountToKeep = playerOne.getTrustGamePlayerOneAmountToKeep(); double[] p2AmountsToKeep = playerTwo.getTrustGamePlayerTwoAmountsToKeep(); - double amountSent = 1.0d - p1AmountToKeep; + double amountSent = 1.0d - p1AmountToKeep; + logger.info(String.format("Player one (%s) sent %s", playerOne, amountSent)); if (amountSent > 0) { double p2AmountToKeep = 0.0d; int index = 0; @@ -424,6 +429,12 @@ logger.info(playerTwoLog); playerTwo.logTrustGameEarnings(playerTwoLog); playerTwo.addTrustGameEarnings(p2AmountToKeep); - } + } + else { + String playerOneLog = "Player one " + playerOne + " didn't send any money and kept: " + p1AmountToKeep; + playerOne.logTrustGameEarnings(playerOneLog); + playerOne.addTrustGameEarnings(p1AmountToKeep); + playerTwo.logTrustGameEarnings(playerOneLog + " - you were player two and didn't receive anything."); + } } } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Aug 17 13:27:14 2011 -0700 @@ -283,14 +283,13 @@ addEventProcessor(new EventTypeProcessor<ChatRequest>(ChatRequest.class) { public void handle(final ChatRequest request) { RoundConfiguration configuration = getCurrentRoundConfiguration(); + if (! configuration.isChatEnabled()) { + logger.warning("configuration doesn't allow for chat but received " + request); + return; + } if (configuration.isCensoredChat()) { transmit(new FacilitatorCensoredChatRequest(facilitatorId, request)); } - else if (configuration.isInRoundChatEnabled()) { - // FIXME: add configuration parameter for chat in field of vision - - - } else { relayChatRequest(request); } @@ -692,6 +691,7 @@ if (iter.hasNext()) { playerTwo = iter.next(); } + logger.info(String.format("Pairing %s with %s for trust game", playerOne, playerTwo)); serverDataModel.calculateTrustGame(playerOne, playerTwo); } } @@ -746,6 +746,8 @@ // check for field of vision RoundConfiguration currentConfiguration = getCurrentRoundConfiguration(); if (currentConfiguration.isFieldOfVisionEnabled()) { + // FIXME: replace with clientData.getFieldOfVision? + Circle circle = new Circle(clientData.getPosition(), currentConfiguration.getViewSubjectsRadius()); sendChatEvent(request, clientData.getGroupDataModel().getClientIdentifiersWithin(circle)); } @@ -785,6 +787,7 @@ } roundProcessor.execute(); +// Thread.yield(); Utils.sleep(SERVER_SLEEP_INTERVAL); break; case WAITING: --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Wed Aug 17 13:27:14 2011 -0700 @@ -10,7 +10,6 @@ <entry key='tokens-field-of-vision'>true</entry><entry key='subjects-field-of-vision'>true</entry> -<entry key='in-round-chat-enabled'>true</entry><entry key="quiz">true</entry><entry key="q1">C</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round1.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round1.xml Wed Aug 17 13:27:14 2011 -0700 @@ -8,11 +8,9 @@ <entry key="resource-depth">29</entry><entry key="resource-width">29</entry> -<entry key='tokens-field-of-vision'>true</entry> -<entry key='subjects-field-of-vision'>true</entry> - <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> +<entry key='in-round-chat-enabled'>true</entry><entry key="instructions"><![CDATA[ @@ -54,19 +52,20 @@ <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key. </p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> ]]></entry><entry key='trust-game-instructions'> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round2.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round2.xml Wed Aug 17 13:27:14 2011 -0700 @@ -17,6 +17,7 @@ <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> +<entry key='in-round-chat-enabled'>true</entry><entry key="instructions"><![CDATA[ @@ -34,19 +35,20 @@ <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key. </p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> ]]></entry><entry key='trust-game-instructions'> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round3.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round3.xml Wed Aug 17 13:27:14 2011 -0700 @@ -18,12 +18,15 @@ <!-- resource regrowth parameters --><entry key="initial-distribution">.25</entry> +<entry key='resource-generator'>mobile</entry> +<entry key='in-round-chat-enabled'>true</entry> + <entry key="instructions"><![CDATA[ <h3>Round 3 Instructions</h3><hr><p> -Round 3 is the same as round 2. +Round 3 is the same as round 2. Except now the resources move. </p><p> If you have any questions please raise your hand. <b>Do you have any @@ -34,19 +37,20 @@ <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key. </p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> ]]></entry><entry key='trust-game-instructions'> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round4.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round4.xml Wed Aug 17 13:27:14 2011 -0700 @@ -15,14 +15,15 @@ <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> +<entry key='in-round-chat-enabled'>true</entry><!-- enable sanctioning --><entry key="sanction-type">real-time</entry><entry key="sanction-cost">1</entry><entry key="sanction-multiplier">2</entry> +<entry key='resource-generator'>top-bottom-patchy</entry> + <entry key="initial-distribution">.25</entry> @@ -41,12 +42,8 @@ Round 4 is the same as the previous two rounds with two exceptions. </p><p> -Before the next round starts you can anonymously communicate by text messages -for four minutes with the other participants in your group. You can use this -opportunity to discuss the experiment and coordinate your actions to improve -your earnings. You may not promise side-payments after the experiment is -completed or make any threats. You are also not allowed to reveal your real -identity. We are monitoring the chat traffic while you chat. +The resource dynamics have changed. One section of the resource has a high growth +rate, and another section has a low growth rate. </p><p> During the next round you will have the option to reduce the earnings of another --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round5.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round5.xml Wed Aug 17 13:27:14 2011 -0700 @@ -16,8 +16,12 @@ <entry key="sanction-type">real-time</entry><entry key="sanction-cost">1</entry><entry key="sanction-multiplier">2</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + <entry key="initial-distribution">.25</entry> +<entry key='resource-generator'>top-bottom-patchy</entry><entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round6.xml Wed Aug 17 10:49:00 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round6.xml Wed Aug 17 13:27:14 2011 -0700 @@ -16,6 +16,10 @@ <entry key="sanction-multiplier">2</entry><entry key="initial-distribution">.25</entry> +<entry key='resource-generator'>top-bottom-patchy</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> + <entry key='always-explicit'>true</entry><entry key='max-cell-occupancy'>1</entry> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 17:49:06
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/44a1315e0608/ changeset: 44a1315e0608 user: alllee date: 2011-08-17 19:49:00 summary: updated configurations, working out a bug in ChatPanel affected #: 15 files (15.4 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Wed Aug 17 10:49:00 2011 -0700 @@ -33,8 +33,6 @@ import edu.asu.commons.event.ChatEvent; import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.EventTypeProcessor; -import edu.asu.commons.foraging.conf.RoundConfiguration; -import edu.asu.commons.foraging.event.CensoredChatRequest; import edu.asu.commons.net.Identifier; @@ -182,7 +180,7 @@ } private void initGuiComponents() { - setLayout(new BorderLayout(4, 4)); + setLayout(new BorderLayout(3, 3)); setName("Chat panel"); messageWindow = new JTextPane(); messageWindow.setEditable(false); --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 17 10:49:00 2011 -0700 @@ -360,23 +360,9 @@ // moveClient(request); transmit(request); } - Utils.sleep(30); + Thread.yield(); } } - -// private void moveClient(ClientRequest request) { -// if (request instanceof ClientMovementRequest) { -// ClientMovementRequest cmr = (ClientMovementRequest) request; -// Direction d = cmr.getDirection(); -// Point point = clientGameState.moveClient(id, d); -// cmr.setPosition(point); -// SwingUtilities.invokeLater(new Runnable() { -// public void run() { -// foragerGameWindow.repaint(); -// } -// }); -// } -// } private void tick() { if (secondTick.hasExpired()) { @@ -387,16 +373,11 @@ public Event get() { tick(); - if (shouldSendMessage()) { - messagesSent++; - return actions.removeFirst(); + if (actions.isEmpty()) { + return null; } - return null; - } - - private boolean shouldSendMessage() { - return ! actions.isEmpty(); - // return secondTick.getElapsedTime() > getNextMessageTime(); + messagesSent++; + return actions.removeFirst(); } public int getEnergyLevel() { --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 17 10:49:00 2011 -0700 @@ -405,7 +405,7 @@ private void setInstructions(String s) { instructionsEditorPane.setText(s); instructionsEditorPane.setCaretPosition(0); - instructionsEditorPane.repaint(); + repaint(); instructionsScrollPane.requestFocusInWindow(); } --- a/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Wed Aug 17 10:49:00 2011 -0700 @@ -501,8 +501,7 @@ return; } playerTwoAmountsToKeep[rowIndex - 1] = (Double) value; - } - System.err.println("P1 keeping " + playerOneAmountToKeep + " and P2 data: " + Arrays.asList(playerTwoAmountsToKeep)); + } client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); client.getGameWindow2D().switchInstructionsPane(); --- a/src/main/java/edu/asu/commons/foraging/event/CensoredChatRequest.java Wed Aug 17 01:34:53 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -package edu.asu.commons.foraging.event; - -import edu.asu.commons.event.AbstractPersistableEvent; -import edu.asu.commons.event.ChatRequest; -import edu.asu.commons.event.ClientRequest; -import edu.asu.commons.net.Identifier; - -/** - * $Id: CensoredChatRequest.java 522 2010-06-30 19:17:48Z alllee $ - * - * Client chat request that should be forwarded on to the facilitator for approval. - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev: 522 $ - */ -public class CensoredChatRequest extends AbstractPersistableEvent implements ClientRequest { - - private static final long serialVersionUID = -120847705184240264L; - - private Identifier target; - - public CensoredChatRequest(Identifier source, String message) { - this(source, message, Identifier.ALL); - } - - public CensoredChatRequest(Identifier source, String message, Identifier target) { - super(source, message); - this.target = target; - } - - public Identifier getTarget() { - return target; - } - - public ChatRequest toApprovedChatRequest() { - return new ChatRequest(getId(), getMessage(), getTarget()); - } - - public ChatRequest toDeniedChatRequest() { - return new ChatRequest(getId(), String.format("Your message: [%s] was not approved.", getMessage()), getId()); - } - -} --- a/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Wed Aug 17 10:49:00 2011 -0700 @@ -1,12 +1,14 @@ package edu.asu.commons.foraging.event; +import java.util.ArrayList; +import java.util.List; + import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; -import java.util.Arrays; public class TrustGameSubmissionRequest extends AbstractPersistableEvent { - private static final long serialVersionUID = -4962852585789164775L; + private static final long serialVersionUID = -3516907265559144744L; private double playerOneAmountToKeep; @@ -27,6 +29,10 @@ } public String toString() { - return String.format("%s (P1: %d) (P2: %s)", getId(), playerOneAmountToKeep, Arrays.asList(playerTwoAmountsToKeep)); + List<Double> list = new ArrayList<Double>(); + for (double amount: playerTwoAmountsToKeep) { + list.add(amount); + } + return String.format("%s (P1: %s) (P2: %s)", getId(), playerOneAmountToKeep, list); } } --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorChatPanel.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorChatPanel.java Wed Aug 17 10:49:00 2011 -0700 @@ -17,8 +17,8 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; +import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.EventTypeProcessor; -import edu.asu.commons.foraging.event.CensoredChatRequest; import edu.asu.commons.foraging.event.FacilitatorCensoredChatRequest; import edu.asu.commons.util.ResourceLoader; @@ -124,8 +124,15 @@ return chatMessageTextArea; } + public ChatRequest toApprovedChatRequest(ChatRequest request) { + return new ChatRequest(request.getId(), request.getMessage(), request.getTarget()); + } + + public ChatRequest toDeniedChatRequest(ChatRequest request) { + return new ChatRequest(request.getId(), String.format("Your message: [%s] was not approved.", request.getMessage()), request.getId()); + } - public CensoredChatRequestView(final CensoredChatRequest request) { + public CensoredChatRequestView(final ChatRequest request) { chatMessageTextArea = createTextArea(request); approveButton = new JButton(); @@ -136,14 +143,14 @@ approveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { - facilitator.transmit(request.toApprovedChatRequest()); + facilitator.transmit(toApprovedChatRequest(request)); updateChatStatus(" approved "); } }); denyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { - facilitator.transmit(request.toDeniedChatRequest()); + facilitator.transmit(toDeniedChatRequest(request)); updateChatStatus(" denied "); } }); @@ -167,14 +174,14 @@ statusLabel.setText(message); } - private JTextArea createTextArea(CensoredChatRequest request) { + private JTextArea createTextArea(ChatRequest request) { JTextArea textArea = new JTextArea( toString( request ) ); textArea.setLineWrap(true); textArea.setEditable(false); return textArea; } - private String toString(CensoredChatRequest request) { + private String toString(ChatRequest request) { return String.format("%s: %s", request.getId(), request.getMessage()); } --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Aug 17 10:49:00 2011 -0700 @@ -3,6 +3,7 @@ import java.awt.Color; import java.awt.Point; import java.io.Serializable; +import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.concurrent.TimeUnit; @@ -65,6 +66,8 @@ private double trustGamePlayerOneAmountToKeep; private double[] trustGamePlayerTwoAmountsToKeep; + private ArrayList<String> trustGameLog = new ArrayList<String>(); + private double trustGameEarnings = 0.0d; public void setTrustGamePlayerOneAmountToKeep(double trustGamePlayerOneAmountToKeep) { @@ -583,4 +586,8 @@ public double getTrustGameEarnings() { return trustGameEarnings; } + + public void logTrustGameEarnings(String log) { + trustGameLog.add(log); + } } --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Aug 17 10:49:00 2011 -0700 @@ -416,9 +416,13 @@ p2AmountToKeep = p2AmountsToKeep[index]; double totalAmountSent = 3 * amountSent; double amountReturnedToP1 = totalAmountSent - p2AmountToKeep; - logger.info(String.format("player one %s earned %d + %d = %d", playerOne, p1AmountToKeep, amountReturnedToP1, p1AmountToKeep + amountReturnedToP1)); + String playerOneLog = String.format("Player one (%s) earned %s + %s = %s", playerOne, p1AmountToKeep, amountReturnedToP1, p1AmountToKeep + amountReturnedToP1); + logger.info(playerOneLog); + playerOne.logTrustGameEarnings(playerOneLog); playerOne.addTrustGameEarnings(p1AmountToKeep + amountReturnedToP1); - logger.info(String.format("player two %s earned %d", p2AmountToKeep)); + String playerTwoLog = String.format("Player two (%s) earned %s", playerTwo, p2AmountToKeep); + logger.info(playerTwoLog); + playerTwo.logTrustGameEarnings(playerTwoLog); playerTwo.addTrustGameEarnings(p2AmountToKeep); } } --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round1.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round1.xml Wed Aug 17 10:49:00 2011 -0700 @@ -51,4 +51,62 @@ </p> ]]></entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and pressing the "enter" key. </p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round2.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round2.xml Wed Aug 17 10:49:00 2011 -0700 @@ -31,4 +31,62 @@ </p> ]]></entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and pressing the "enter" key. </p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round3.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round3.xml Wed Aug 17 10:49:00 2011 -0700 @@ -31,4 +31,62 @@ </p> ]]></entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and pressing the "enter" key. </p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round4.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round4.xml Wed Aug 17 10:49:00 2011 -0700 @@ -86,20 +86,19 @@ <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we see that somebody reveals his or her identity, we have to stop the -experiment and remove the whole group from which this person is a member out -of this room. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key on your keyboard. +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. </p> ]]></entry> @@ -149,4 +148,84 @@ </form> ]]></entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round5.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round5.xml Wed Aug 17 10:49:00 2011 -0700 @@ -40,24 +40,22 @@ </p> ]]></entry> - <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we see that somebody reveals his or her identity, we have to stop the -experiment and remove the whole group from which this person is a member out -of this room. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key on your keyboard. +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. </p> ]]></entry> @@ -70,5 +68,45 @@ members of your group. ]]></entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry></properties> --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round6.xml Wed Aug 17 01:34:53 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round6.xml Wed Aug 17 10:49:00 2011 -0700 @@ -57,23 +57,64 @@ </p> ]]></entry> - <entry key="chat-instructions"><![CDATA[ <p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. +You can chat with the other participants in your group during this round. +You may communicate about any aspect of the experiment that you would like to +discuss with other participants with whom you have been matched. You may not promise +them side-payments after the experiment is completed or threaten them with any +consequence after the experiment is finished. We are monitoring the chat traffic +while you chat. If we see that somebody reveals his or her identity, we have to stop +the experiment and remove the whole group from which this person is a member out of +this room. </p><p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and pressing the "enter" key. </p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the chat +box. You can send a chat message by typing into the textfield and pressing the +enter key. +</p> +]]> +</entry> + +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> ]]></entry></properties> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 08:35:12
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/92762f536733/ changeset: 92762f536733 user: <all...@asu.edu> Allen Lee date: 2011-08-17 10:34:53 summary: adding trust game server side logic, needs testing affected #: 10 files (6.1 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Wed Aug 17 01:34:53 2011 -0700 @@ -118,14 +118,7 @@ if (message == null || "".equals(message) || targetIdentifier == null) { return; } - RoundConfiguration roundConfiguration = client.getCurrentRoundConfiguration(); - if (roundConfiguration.isCensoredChat()) { - // FIXME: get rid of duplication, add a censored boolean to ChatRequest instead? - client.transmit(new CensoredChatRequest(clientId, message, targetIdentifier)); - } - else { - client.transmit(new ChatRequest(clientId, message, targetIdentifier)); - } + client.transmit(new ChatRequest(clientId, message, targetIdentifier)); chatField.requestFocusInWindow(); chatField.setText(""); } --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 17 01:34:53 2011 -0700 @@ -444,7 +444,7 @@ SwingUtilities.invokeLater(createGuiRunnable); } - public void sendTrustGameSubmissionRequest(Double playerOneAmountToKeep, Double[] playerTwoAmountsToKeep) { + public void sendTrustGameSubmissionRequest(double playerOneAmountToKeep, double[] playerTwoAmountsToKeep) { transmit(new TrustGameSubmissionRequest(getId(), playerOneAmountToKeep, playerTwoAmountsToKeep)); } } --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 17 01:34:53 2011 -0700 @@ -82,7 +82,7 @@ private JScrollPane instructionsScrollPane; - private HtmlEditorPane instructionsEditorPane; + private HtmlEditorPane instructionsEditorPane; private JPanel messagePanel; private JScrollPane messageScrollPane; @@ -599,7 +599,7 @@ return configuration.isPracticeRound() && configuration.isPrivateProperty(); } - private void addCenterComponent(Component newCenterComponent) { + public void addCenterComponent(Component newCenterComponent) { if (currentCenterComponent != null) { currentCenterComponent.setVisible(false); remove(currentCenterComponent); @@ -759,9 +759,7 @@ panel.add(scrollPane, BorderLayout.NORTH); TrustGamePanel trustGamePanel = new TrustGamePanel(client); - panel.add(trustGamePanel, BorderLayout.CENTER); - - + panel.add(trustGamePanel, BorderLayout.CENTER); addCenterComponent(panel); } } @@ -790,7 +788,7 @@ setInstructions(instructionsBuilder.toString()); } public void switchInstructionsPane() { - instructionsEditorPane.setText("<b>Please wait while we compute your new token totals.</b>"); +// instructionsEditorPane.setText("<b>Please wait while we compute your new token totals.</b>"); addCenterComponent(instructionsScrollPane); } --- a/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Wed Aug 17 01:34:53 2011 -0700 @@ -489,9 +489,8 @@ } String selectedPlayerOneAction = model.getActionCommand(); System.err.println("player one action: " + selectedPlayerOneAction); - Double playerOneAmountToKeep = (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); - Double[] playerTwoAmountsToKeep = new Double[4]; - Arrays.fill(playerTwoAmountsToKeep, 0.0d); + double playerOneAmountToKeep = (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); + double[] playerTwoAmountsToKeep = new double[4]; for (int rowIndex = 1; rowIndex <= 4; rowIndex++) { Object value = playerTwoTable.getValueAt(rowIndex, 2); System.err.println("value is: " + value); @@ -505,6 +504,8 @@ } System.err.println("P1 keeping " + playerOneAmountToKeep + " and P2 data: " + Arrays.asList(playerTwoAmountsToKeep)); client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); + client.getGameWindow2D().switchInstructionsPane(); + --- a/src/main/java/edu/asu/commons/foraging/event/FacilitatorCensoredChatRequest.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/FacilitatorCensoredChatRequest.java Wed Aug 17 01:34:53 2011 -0700 @@ -1,6 +1,7 @@ package edu.asu.commons.foraging.event; import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.ClientRequest; import edu.asu.commons.net.Identifier; @@ -16,14 +17,14 @@ private static final long serialVersionUID = -120847705184240264L; - private CensoredChatRequest censoredChatRequest; + private ChatRequest censoredChatRequest; - public FacilitatorCensoredChatRequest(Identifier facilitatorId, CensoredChatRequest request) { + public FacilitatorCensoredChatRequest(Identifier facilitatorId, ChatRequest request) { super(facilitatorId); this.censoredChatRequest = request; } - public CensoredChatRequest getCensoredChatRequest() { + public ChatRequest getCensoredChatRequest() { return censoredChatRequest; } --- a/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Wed Aug 17 01:34:53 2011 -0700 @@ -2,27 +2,31 @@ import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; +import java.util.Arrays; public class TrustGameSubmissionRequest extends AbstractPersistableEvent { private static final long serialVersionUID = -4962852585789164775L; - private Double playerOneAmountToKeep; + private double playerOneAmountToKeep; - private Double[] playerTwoAmountsToKeep; + private double[] playerTwoAmountsToKeep; - public Double getPlayerOneAmountToKeep() { + public double getPlayerOneAmountToKeep() { return playerOneAmountToKeep; } - public Double[] getPlayerTwoAmountsToKeep() { + public double[] getPlayerTwoAmountsToKeep() { return playerTwoAmountsToKeep; } - public TrustGameSubmissionRequest(Identifier id, Double playerOneAmountToKeep, Double[] playerTwoAmountsToKeep) { + public TrustGameSubmissionRequest(Identifier id, double playerOneAmountToKeep, double[] playerTwoAmountsToKeep) { super(id); this.playerOneAmountToKeep = playerOneAmountToKeep; this.playerTwoAmountsToKeep = playerTwoAmountsToKeep; } + public String toString() { + return String.format("%s (P1: %d) (P2: %s)", getId(), playerOneAmountToKeep, Arrays.asList(playerTwoAmountsToKeep)); + } } --- a/src/main/java/edu/asu/commons/foraging/model/ClientData.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ClientData.java Wed Aug 17 01:34:53 2011 -0700 @@ -62,6 +62,27 @@ // only needed if this client has already received a tax. private boolean taxReceived = false; + private double trustGamePlayerOneAmountToKeep; + private double[] trustGamePlayerTwoAmountsToKeep; + + private double trustGameEarnings = 0.0d; + + public void setTrustGamePlayerOneAmountToKeep(double trustGamePlayerOneAmountToKeep) { + this.trustGamePlayerOneAmountToKeep = trustGamePlayerOneAmountToKeep; + } + + public void setTrustGamePlayerTwoAmountsToKeep(double[] trustGamePlayerTwoAmountsToKeep) { + this.trustGamePlayerTwoAmountsToKeep = trustGamePlayerTwoAmountsToKeep; + } + + public double getTrustGamePlayerOneAmountToKeep() { + return trustGamePlayerOneAmountToKeep; + } + + public double[] getTrustGamePlayerTwoAmountsToKeep() { + return trustGamePlayerTwoAmountsToKeep; + } + // this is only used in the Rotating Monitor enforcement mechanism. private int tokensCollectedDuringInterval = 0; @@ -554,4 +575,12 @@ public String toString() { return String.format("id (%s) number (%d)", id, assignedNumber); } + + public void addTrustGameEarnings(double trustGameEarnings) { + this.trustGameEarnings += trustGameEarnings; + } + + public double getTrustGameEarnings() { + return trustGameEarnings; + } } --- a/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java Wed Aug 17 01:34:53 2011 -0700 @@ -15,6 +15,7 @@ import java.util.logging.Logger; import edu.asu.commons.experiment.DataModel; +import edu.asu.commons.foraging.client.Circle; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.event.ClientPositionUpdateEvent; import edu.asu.commons.foraging.event.EnforcementRankingRequest; @@ -433,6 +434,16 @@ public int getResourceDistributionSize() { return resourceDistribution.size(); } + + public Set<Identifier> getClientIdentifiersWithin(Circle circle) { + HashSet<Identifier> ids = new HashSet<Identifier>(); + for (ClientData data: clients.values()) { + if (circle.contains(data.getPosition())) { + ids.add(data.getId()); + } + } + return ids; + } /** * --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java Wed Aug 17 01:34:53 2011 -0700 @@ -395,4 +395,31 @@ public void unapply(PersistableEvent persistableEvent) { logger.warning("unapply() not implemented yet: " + persistableEvent); } + + public void calculateTrustGame(ClientData playerOne, ClientData playerTwo) { + double p1AmountToKeep = playerOne.getTrustGamePlayerOneAmountToKeep(); + double[] p2AmountsToKeep = playerTwo.getTrustGamePlayerTwoAmountsToKeep(); + + double amountSent = 1.0d - p1AmountToKeep; + if (amountSent > 0) { + double p2AmountToKeep = 0.0d; + int index = 0; + if (amountSent == 0.25d) { + index = 0; + } else if (amountSent == 0.50d) { + index = 1; + } else if (amountSent == 0.75d) { + index = 2; + } else if (amountSent == 1.0d) { + index = 3; + } + p2AmountToKeep = p2AmountsToKeep[index]; + double totalAmountSent = 3 * amountSent; + double amountReturnedToP1 = totalAmountSent - p2AmountToKeep; + logger.info(String.format("player one %s earned %d + %d = %d", playerOne, p1AmountToKeep, amountReturnedToP1, p1AmountToKeep + amountReturnedToP1)); + playerOne.addTrustGameEarnings(p1AmountToKeep + amountReturnedToP1); + logger.info(String.format("player two %s earned %d", p2AmountToKeep)); + playerTwo.addTrustGameEarnings(p2AmountToKeep); + } + } } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Tue Aug 16 23:36:32 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Aug 17 01:34:53 2011 -0700 @@ -25,12 +25,12 @@ import edu.asu.commons.event.SocketIdentifierUpdateRequest; import edu.asu.commons.experiment.AbstractExperiment; import edu.asu.commons.experiment.StateMachine; +import edu.asu.commons.foraging.client.Circle; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.conf.ServerConfiguration; import edu.asu.commons.foraging.data.ForagingSaveFileConverter; import edu.asu.commons.foraging.event.AgentInfoRequest; import edu.asu.commons.foraging.event.BeginChatRoundRequest; -import edu.asu.commons.foraging.event.CensoredChatRequest; import edu.asu.commons.foraging.event.ClientMovementRequest; import edu.asu.commons.foraging.event.ClientPoseUpdate; import edu.asu.commons.foraging.event.ClientPositionUpdateEvent; @@ -56,6 +56,7 @@ import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; +import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; import edu.asu.commons.foraging.event.UnlockResourceRequest; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; @@ -71,6 +72,9 @@ import edu.asu.commons.net.event.DisconnectionRequest; import edu.asu.commons.util.Duration; import edu.asu.commons.util.Utils; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; /** * $Id: ForagingServer.java 529 2010-08-17 00:08:01Z alllee $ @@ -276,15 +280,20 @@ } } }); - addEventProcessor(new EventTypeProcessor<CensoredChatRequest>(CensoredChatRequest.class) { - public void handle(final CensoredChatRequest request) { - // send to facilitator immediately for approval - transmit(new FacilitatorCensoredChatRequest(facilitatorId, request)); - } - }); addEventProcessor(new EventTypeProcessor<ChatRequest>(ChatRequest.class) { public void handle(final ChatRequest request) { - new Thread () { public void run() { relayChatRequest(request); } }.start(); + RoundConfiguration configuration = getCurrentRoundConfiguration(); + if (configuration.isCensoredChat()) { + transmit(new FacilitatorCensoredChatRequest(facilitatorId, request)); + } + else if (configuration.isInRoundChatEnabled()) { + // FIXME: add configuration parameter for chat in field of vision + + + } + else { + relayChatRequest(request); + } } }); @@ -658,13 +667,39 @@ } } }); - // addEventProcessor(new EventTypeProcessor<BeginVotingRequest>(BeginVotingRequest.class) { - // public void handle(BeginVotingRequest request) { - // if (getConfiguration().getCurrentParameters().isVotingEnabled()) { - // - // } - // } - // }); + addEventProcessor(new EventTypeProcessor<TrustGameSubmissionRequest>(TrustGameSubmissionRequest.class) { + int numberOfSubmissions = 0; + public void handle(TrustGameSubmissionRequest request) { + if (getCurrentRoundConfiguration().isTrustGameEnabled()) { + logger.info("trust game submission: " + request); + // basic sanity check + ClientData clientData = clients.get(request.getId()); + clientData.setTrustGamePlayerOneAmountToKeep(request.getPlayerOneAmountToKeep()); + clientData.setTrustGamePlayerTwoAmountsToKeep(request.getPlayerTwoAmountsToKeep()); + persister.store(request); + numberOfSubmissions++; + } + if (numberOfSubmissions >= clients.size()) { + // once all clients have submitted their decisions, execute the trust game. + for (GroupDataModel group: serverDataModel.getGroups()) { + LinkedList<ClientData> clientList = new LinkedList<ClientData>(group.getClientDataMap().values()); + Collections.shuffle(clientList); + // FIXME: arbitrary choice to save the first one to pair up with the last one as well. + ClientData first = clientList.getFirst(); + for (Iterator<ClientData> iter = clientList.iterator(); iter.hasNext(); ) { + ClientData playerOne = iter.next(); + ClientData playerTwo = first; + if (iter.hasNext()) { + playerTwo = iter.next(); + } + serverDataModel.calculateTrustGame(playerOne, playerTwo); + } + } + numberOfSubmissions = 0; + } + } + }); + addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { public void handle(BeginChatRoundRequest request) { if (getCurrentRoundConfiguration().isChatEnabled()) { @@ -708,9 +743,14 @@ // relay to all clients in this client's group. ClientData clientData = clients.get(source); getLogger().info(String.format("chat from %s: [ %s ]", clientData.toString(), request)); - for (Identifier targetId : clientData.getGroupDataModel().getClientIdentifiers()) { - ChatEvent chatEvent = new ChatEvent(targetId, request.toString(), source, true); - transmit(chatEvent); + // check for field of vision + RoundConfiguration currentConfiguration = getCurrentRoundConfiguration(); + if (currentConfiguration.isFieldOfVisionEnabled()) { + Circle circle = new Circle(clientData.getPosition(), currentConfiguration.getViewSubjectsRadius()); + sendChatEvent(request, clientData.getGroupDataModel().getClientIdentifiersWithin(circle)); + } + else { + sendChatEvent(request, clientData.getGroupDataModel().getClientIdentifiers()); } } else { @@ -720,6 +760,13 @@ } persister.store(request); } + + private void sendChatEvent(ChatRequest request, Collection<Identifier> identifiers) { + for (Identifier targetId : identifiers) { + ChatEvent chatEvent = new ChatEvent(targetId, request.toString(), request.getSource(), true); + transmit(chatEvent); + } + } // FIXME: remove Dispatcher reference if it's unused. public void execute(Dispatcher dispatcher) { Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 06:36:55
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/f1e06747ef5c/ changeset: f1e06747ef5c user: <all...@asu.edu> Allen Lee date: 2011-08-17 08:36:32 summary: more refinement to the trust game panel affected #: 4 files (7.9 KB) --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 22:30:07 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 23:36:32 2011 -0700 @@ -55,6 +55,7 @@ import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Duration; import edu.asu.commons.util.HtmlEditorPane; +import javax.swing.JEditorPane; @@ -745,10 +746,23 @@ public void showTrustGame() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); - if (roundConfiguration.isTrustGameEnabled()) { + if (roundConfiguration.isTrustGameEnabled()) { + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + JEditorPane instructionEditorPane = new JEditorPane(); + instructionEditorPane.setContentType("text/html"); + instructionEditorPane.setEditorKit(new HTMLEditorKit()); + instructionEditorPane.setEditable(false); + instructionEditorPane.setBackground(Color.WHITE); + JScrollPane scrollPane = new JScrollPane(instructionEditorPane); + instructionEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); + panel.add(scrollPane, BorderLayout.NORTH); + TrustGamePanel trustGamePanel = new TrustGamePanel(client); + panel.add(trustGamePanel, BorderLayout.CENTER); - addCenterComponent(new TrustGamePanel(client)); + + addCenterComponent(panel); } } --- a/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.form Tue Aug 16 22:30:07 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.form Tue Aug 16 23:36:32 2011 -0700 @@ -21,14 +21,19 @@ <DimensionLayout dim="0"><Group type="103" groupAlignment="0" attributes="0"><Group type="102" alignment="0" attributes="0"> - <EmptySpace max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/><Component id="jPanel1" min="-2" pref="704" max="-2" attributes="1"/> + <EmptySpace pref="22" max="32767" attributes="0"/></Group></Group></DimensionLayout><DimensionLayout dim="1"><Group type="103" groupAlignment="0" attributes="0"> - <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="21" max="32767" attributes="0"/> + </Group></Group></DimensionLayout></Layout> @@ -38,7 +43,7 @@ <Layout><DimensionLayout dim="0"><Group type="103" groupAlignment="0" attributes="0"> - <Group type="102" attributes="0"> + <Group type="102" alignment="0" attributes="0"><EmptySpace max="-2" attributes="0"/><Group type="103" groupAlignment="0" attributes="0"><Group type="102" alignment="0" attributes="0"> @@ -46,52 +51,18 @@ <EmptySpace pref="103" max="32767" attributes="0"/></Group><Group type="102" alignment="0" attributes="0"> - <Group type="103" groupAlignment="1" attributes="0"> - <Component id="playerOneTableLabel" alignment="1" min="-2" pref="483" max="-2" attributes="0"/> - <Group type="102" alignment="1" attributes="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel10" alignment="0" pref="120" max="32767" attributes="1"/> - <Component id="jLabel7" alignment="0" pref="120" max="32767" attributes="1"/> - <Component id="jLabel6" alignment="0" pref="120" max="32767" attributes="1"/> - <Component id="jLabel1" alignment="0" pref="120" max="32767" attributes="1"/> - <Component id="playerOneAmountKeptLabel" alignment="0" max="32767" attributes="1"/> - <Component id="jLabel13" alignment="0" pref="120" max="32767" attributes="1"/> - </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="playerOneTableLabel" min="-2" pref="483" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="playerOneAmountKeptLabel" linkSize="1" max="32767" attributes="1"/><EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel11" alignment="0" pref="160" max="32767" attributes="1"/> - <Component id="jLabel8" alignment="0" pref="160" max="32767" attributes="1"/> - <Component id="jLabel3" alignment="0" pref="160" max="32767" attributes="1"/> - <Component id="jLabel2" alignment="0" pref="160" max="32767" attributes="1"/> - <Component id="playerOneAmountSentLabel" alignment="0" max="32767" attributes="1"/> - <Component id="jLabel14" pref="160" max="32767" attributes="1"/> - </Group> + <Component id="playerOneAmountSentLabel" max="32767" attributes="1"/><EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel5" alignment="0" pref="191" max="32767" attributes="1"/> - <Component id="playerOneAmountReceived" alignment="0" pref="191" max="32767" attributes="1"/> - <Component id="jLabel9" alignment="1" pref="191" max="32767" attributes="1"/> - <Component id="jLabel15" alignment="0" pref="191" max="32767" attributes="1"/> - </Group> - </Group> - <Group type="102" alignment="0" attributes="0"> - <EmptySpace min="292" pref="292" max="292" attributes="0"/> - <Component id="jLabel12" pref="191" max="32767" attributes="1"/> - </Group> - <Group type="102" alignment="0" attributes="0"> - <EmptySpace min="292" pref="292" max="292" attributes="0"/> - <Component id="jLabel4" pref="191" max="32767" attributes="1"/> + <Component id="playerOneAmountReceived" pref="191" max="32767" attributes="1"/></Group></Group><EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="playerOneAction" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton3" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton2" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton1" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton4" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton5" min="-2" max="-2" attributes="0"/> - </Group> + <Component id="playerOneAction" min="-2" max="-2" attributes="0"/><EmptySpace min="-2" pref="302" max="-2" attributes="0"/></Group><Group type="102" alignment="0" attributes="0"> @@ -105,6 +76,69 @@ </Group><EmptySpace pref="22" max="32767" attributes="0"/></Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel7" linkSize="1" pref="120" max="32767" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel8" linkSize="3" pref="160" max="32767" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel9" linkSize="4" pref="191" max="32767" attributes="1"/> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel10" linkSize="1" pref="120" max="32767" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel11" linkSize="3" pref="160" max="32767" attributes="1"/> + <EmptySpace min="197" pref="197" max="197" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="292" pref="292" max="292" attributes="0"/> + <Component id="jLabel12" linkSize="4" pref="191" max="32767" attributes="1"/> + </Group> + </Group> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel13" linkSize="1" pref="120" max="32767" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel14" linkSize="3" pref="160" max="32767" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel15" linkSize="4" pref="191" max="32767" attributes="1"/> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel1" alignment="0" pref="120" max="32767" attributes="1"/> + <Component id="jLabel6" linkSize="1" alignment="0" pref="120" max="32767" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel2" linkSize="3" alignment="0" pref="160" max="32767" attributes="1"/> + <Component id="jLabel3" linkSize="3" alignment="0" pref="160" max="32767" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel5" linkSize="4" pref="191" max="32767" attributes="1"/> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + </Group> + <Component id="jLabel4" linkSize="4" pref="191" max="32767" attributes="1"/> + </Group> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="playerOneRadioButton5" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton4" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton3" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton2" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="331" max="-2" attributes="0"/> + </Group></Group></Group></Group> @@ -117,51 +151,47 @@ <Group type="103" groupAlignment="3" attributes="0"><Component id="playerOneAmountKeptLabel" alignment="3" min="-2" max="-2" attributes="0"/><Component id="playerOneAmountSentLabel" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="playerOneAmountReceived" alignment="3" min="-2" max="-2" attributes="0"/><Component id="playerOneAction" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="playerOneAmountReceived" alignment="3" min="-2" max="-2" attributes="0"/></Group><EmptySpace type="unrelated" max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel2" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel1" linkSize="2" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="1" groupAlignment="3" attributes="0"> + <Component id="jLabel4" linkSize="5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" linkSize="6" alignment="3" min="-2" max="-2" attributes="0"/></Group><Component id="playerOneRadioButton1" min="-2" max="-2" attributes="0"/></Group> - <EmptySpace min="-2" pref="4" max="-2" attributes="0"/> + <EmptySpace min="6" pref="6" max="-2" attributes="0"/><Group type="103" groupAlignment="0" attributes="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/> - </Group> - <Component id="playerOneRadioButton2" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton2" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" linkSize="6" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/></Group> - <EmptySpace min="-2" pref="2" max="-2" attributes="0"/> - <Group type="103" groupAlignment="1" attributes="0"> - <Component id="jLabel9" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel8" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="jLabel7" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="playerOneRadioButton3" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="9" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel9" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8" linkSize="6" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton3" alignment="1" min="-2" max="-2" attributes="0"/></Group><EmptySpace type="unrelated" max="-2" attributes="0"/><Group type="103" groupAlignment="2" attributes="0"> - <Component id="jLabel10" alignment="2" min="-2" max="-2" attributes="0"/> - <Component id="jLabel11" alignment="2" min="-2" max="-2" attributes="0"/> - <Component id="jLabel12" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel10" linkSize="2" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" linkSize="6" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel12" linkSize="5" alignment="2" min="-2" max="-2" attributes="0"/><Component id="playerOneRadioButton4" alignment="2" min="-2" max="-2" attributes="0"/></Group> - <EmptySpace type="unrelated" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/><Group type="103" groupAlignment="0" attributes="0"> - <Group type="103" groupAlignment="3" attributes="0"> - <Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/> - </Group> - <Component id="playerOneRadioButton5" min="-2" max="-2" attributes="0"/> + <Component id="playerOneRadioButton5" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel13" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel14" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel15" linkSize="5" alignment="0" min="-2" max="-2" attributes="0"/></Group> - <EmptySpace min="-2" pref="39" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="29" max="-2" attributes="0"/><Component id="playerTwoLabel" min="-2" max="-2" attributes="0"/><EmptySpace min="-2" pref="12" max="-2" attributes="0"/><Component id="jLabel16" min="-2" max="-2" attributes="0"/> --- a/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Tue Aug 16 22:30:07 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Tue Aug 16 23:36:32 2011 -0700 @@ -12,6 +12,8 @@ import javax.swing.table.TableModel; import edu.asu.commons.foraging.conf.RoundConfiguration; +import javax.sound.midi.SysexMessage; +import javax.swing.ButtonModel; import javax.swing.table.TableColumn; /** @@ -31,7 +33,7 @@ private String[] columnNames = { "Amount sent by P1", "Total amount received", "Amount to keep", "Amount to return to P1" }; private Object[][] columnDataTable = { - { "0 cents", "(3 x 0) = 0 cents", "0", "0" }, + { "0 cents", "(3 x 0) = 0 cents", 0.0d, 0.0d }, { "25 cents", "(3 x 0.25) = 75 cents", "", "" }, { "50 cents", "(3 x 0.5) = 1.5 dollars", "", "" }, { "75 cents", "(3 x 0.75) = 2.25 dollars", "", "" }, @@ -184,7 +186,7 @@ playerOneAmountKeptLabel.setText("Amount to keep"); playerOneAmountKeptLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); - playerOneAmountSentLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); + playerOneAmountSentLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N playerOneAmountSentLabel.setText("Amount to send to P2"); playerOneAmountSentLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); @@ -324,44 +326,16 @@ .addComponent(jLabel16) .addContainerGap(103, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(playerOneTableLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 483, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) - .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) - .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) - .addComponent(playerOneAmountKeptLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) + .addComponent(playerOneAmountKeptLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) - .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) - .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) - .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) - .addComponent(playerOneAmountSentLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)) + .addComponent(playerOneAmountSentLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) - .addComponent(playerOneAmountReceived, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) - .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) - .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() - .addGap(292, 292, 292) - .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() - .addGap(292, 292, 292) - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) + .addComponent(playerOneAmountReceived, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(playerOneAction) - .addComponent(playerOneRadioButton3) - .addComponent(playerOneRadioButton2) - .addComponent(playerOneRadioButton1) - .addComponent(playerOneRadioButton4) - .addComponent(playerOneRadioButton5)) + .addComponent(playerOneAction) .addGap(302, 302, 302)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(playerTwoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 831, Short.MAX_VALUE) @@ -370,8 +344,64 @@ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(submitButton) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 672, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(22, Short.MAX_VALUE)))) + .addContainerGap(22, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addGap(6, 6, 6)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addGap(197, 197, 197)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() + .addGap(292, 292, 292) + .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) + .addGap(6, 6, 6)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addGap(6, 6, 6)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addGap(6, 6, 6)) + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(playerOneRadioButton5) + .addComponent(playerOneRadioButton4) + .addComponent(playerOneRadioButton3) + .addComponent(playerOneRadioButton2) + .addComponent(playerOneRadioButton1)) + .addGap(331, 331, 331)))) ); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel13, jLabel6, jLabel7, playerOneAmountKeptLabel}); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel14, jLabel2, jLabel3, jLabel8}); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel12, jLabel15, jLabel4, jLabel5, jLabel9}); + jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() @@ -380,42 +410,40 @@ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(playerOneAmountKeptLabel) .addComponent(playerOneAmountSentLabel) - .addComponent(playerOneAction) - .addComponent(playerOneAmountReceived)) + .addComponent(playerOneAmountReceived) + .addComponent(playerOneAction)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel1) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jLabel2)) + .addComponent(playerOneRadioButton1)) + .addGap(6, 6, 6) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)) - .addComponent(playerOneRadioButton1)) - .addGap(4, 4, 4) + .addComponent(playerOneRadioButton2, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)) + .addGap(9, 9, 9) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)) - .addComponent(playerOneRadioButton2)) - .addGap(2, 2, 2) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel9) - .addComponent(jLabel8) - .addComponent(jLabel7) - .addComponent(playerOneRadioButton3)) + .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(playerOneRadioButton3, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jLabel10) .addComponent(jLabel11) .addComponent(jLabel12) .addComponent(playerOneRadioButton4)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGap(10, 10, 10) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel13) - .addComponent(jLabel14) - .addComponent(jLabel15)) - .addComponent(playerOneRadioButton5)) - .addGap(39, 39, 39) + .addComponent(playerOneRadioButton5) + .addComponent(jLabel13) + .addComponent(jLabel14) + .addComponent(jLabel15)) + .addGap(29, 29, 29) .addComponent(playerTwoLabel) .addGap(12, 12, 12) .addComponent(jLabel16) @@ -426,32 +454,56 @@ .addContainerGap(23, Short.MAX_VALUE)) ); + jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel13, jLabel6, jLabel7}); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel12, jLabel15, jLabel4, jLabel5, jLabel9}); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel11, jLabel14, jLabel2, jLabel3, jLabel8}); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 704, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 704, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(22, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(21, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_submitButtonActionPerformed // TODO add your handling code here: - String selectedPlayerOneAction = playerOneActionButtonGroup.getSelection().getActionCommand(); - if (selectedPlayerOneAction == null || "".equals(selectedPlayerOneAction.trim())) { - selectedPlayerOneAction = "4"; + ButtonModel model = playerOneActionButtonGroup.getSelection(); + // default player action is to keep everything + + if (model == null) { + JOptionPane.showMessageDialog(this, "Please select the amount you would like to keep as player 1."); + return; } + String selectedPlayerOneAction = model.getActionCommand(); + System.err.println("player one action: " + selectedPlayerOneAction); Double playerOneAmountToKeep = (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); Double[] playerTwoAmountsToKeep = new Double[4]; Arrays.fill(playerTwoAmountsToKeep, 0.0d); - for (int i = 1; i <= 4; i++) { - playerTwoAmountsToKeep[i - 1] = (Double) playerTwoTable.getValueAt(i, 2); + for (int rowIndex = 1; rowIndex <= 4; rowIndex++) { + Object value = playerTwoTable.getValueAt(rowIndex, 2); + System.err.println("value is: " + value); + if (value == null || "".equals(value)) { + JOptionPane.showMessageDialog(this, "Please enter the amount you would like to keep as player 2."); + playerTwoTable.setColumnSelectionAllowed(true); + playerTwoTable.setColumnSelectionInterval(2, 2); + return; + } + playerTwoAmountsToKeep[rowIndex - 1] = (Double) value; } + System.err.println("P1 keeping " + playerOneAmountToKeep + " and P2 data: " + Arrays.asList(playerTwoAmountsToKeep)); client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); --- a/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Tue Aug 16 22:30:07 2011 -0700 +++ b/src/main/resources/configuration/asu-experiments/fall-2011/stationary-limitedvision/round0.xml Tue Aug 16 23:36:32 2011 -0700 @@ -67,4 +67,45 @@ ]]></entry> +<entry key='trust-game-instructions'> +<![CDATA[ +<h3>Task</h3> +<p> +You will be matched with another person in your group, but you will not know who +that person is. And that person will not know who you are. You make decisions for +the case you are drawn to be player 1 and the case you will be player 2. The +results of the decisions are given to you at the end of the whole experiment. +</p> + +<p> +The person drawn to be player 1 has the following decision to make. You will receive +an endowment of one dollar and decide how much to keep and how much to send to +another person in your group. +</p> + +<p> +The amount you send to the other person will be tripled and then given to the person +in your group with whom you have been matched. That person will decide how much to +keep and how much to send back to you. For example, if you send 0 extra credit +points to the other person, 0 extra credit points will be sent to the other person. +However, if you write 3 extra credit points on the form, 9 extra credit points will +be sent to the person. The other person would then decide how much to return to +you. +</p> + +<p> +Player 2 has the following decision to make. You have to chose for each of the 4 +possible cases how much to receive from player 1 how much to keep and how much to +send back to player 1. +We ask you to fill in the tables for player 1 as well as for player 2, and we will +drawn whether you are player 1 or 2 after you have made the decisions. +</p> + +<p> +Are there any questions? If you have a question, raise your hand and I will try to +answer it. +</p> +]]> +</entry> + </properties> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 05:42:16
|
2 new changesets in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/e587898829f3/ changeset: e587898829f3 user: all...@SHESC-ALEE14-01.ph.cox.net date: 2011-08-17 07:28:37 summary: adding NetBeans form file for TrustGamePanel.java and fixing TableColumn combo box editing. affected #: 3 files (26.5 KB) --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 19:56:13 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 22:28:37 2011 -0700 @@ -745,8 +745,10 @@ public void showTrustGame() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); - if (roundConfiguration.isTrustGameEnabled()) { - addCenterComponent(new TrustGameWindow(client)); + if (roundConfiguration.isTrustGameEnabled()) { + TrustGamePanel trustGamePanel = new TrustGamePanel(client); + + addCenterComponent(new TrustGamePanel(client)); } } --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGamePanel.java Tue Aug 16 22:28:37 2011 -0700 @@ -0,0 +1,495 @@ +package edu.asu.commons.foraging.client; + +import java.awt.Component; +import java.util.Arrays; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; + +import edu.asu.commons.foraging.conf.RoundConfiguration; +import javax.swing.table.TableColumn; + +/** + * $Id:$ + * + * @author alllee + */ +public class TrustGamePanel extends JPanel { + + private static final long serialVersionUID = 4780102066737046088L; + private RoundConfiguration roundConfiguration; + private ForagingClient client; + + private class PlayerTwoTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 8044821545875471685L; + private String[] columnNames = { "Amount sent by P1", "Total amount received", "Amount to keep", "Amount to return to P1" }; + private Object[][] columnDataTable = { + + { "0 cents", "(3 x 0) = 0 cents", "0", "0" }, + { "25 cents", "(3 x 0.25) = 75 cents", "", "" }, + { "50 cents", "(3 x 0.5) = 1.5 dollars", "", "" }, + { "75 cents", "(3 x 0.75) = 2.25 dollars", "", "" }, + { "1 dollar", "(3 x 1) = 3 dollars", "", "" } + }; + + @Override + public int getColumnCount() { + return columnNames.length; + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + + @Override + public int getRowCount() { + return columnDataTable.length; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return columnDataTable[rowIndex][columnIndex]; + } + + @Override + public boolean isCellEditable(int row, int col) { + // Note that the data/cell address is constant, + // no matter where the cell appears onscreen. + return (col == 2) && (row != 0); + } + + @Override + public void setValueAt(Object value, int row, int col) { + if (value == null) { + return; + } + try { + Double amount = Double.parseDouble(value.toString()); + columnDataTable[row][col] = amount; + Double totalAmount = row * 3 * roundConfiguration.getTrustGamePayoffIncrement(); + columnDataTable[row][col + 1] = totalAmount - amount; + fireTableCellUpdated(row, col + 1); + } catch (NumberFormatException exception) { + JOptionPane.showMessageDialog(TrustGamePanel.this, "Please enter a valid number."); + return; + } + } + } + + private class PlayerTwoInputColumnCellEditor extends DefaultCellEditor { + private static final long serialVersionUID = -981239232309467766L; + + public PlayerTwoInputColumnCellEditor() { + super(new JComboBox()); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) { + JComboBox combo = (JComboBox) super.getTableCellEditorComponent(table, value, selected, row, column); + combo.removeAllItems(); + int numberOfQuarters = row * 3; + for (int i = 0; i <= numberOfQuarters; i++) { + combo.addItem(Double.valueOf(i * roundConfiguration.getTrustGamePayoffIncrement())); + } + return combo; + } + } + + private TableModel playerTwoTableModel; + + private TableModel getPlayerTwoTableModel() { + if (playerTwoTableModel == null) { + playerTwoTableModel = new PlayerTwoTableModel(); + } + return playerTwoTableModel; + } + + /** Creates new form TrustGamePanel */ + public TrustGamePanel() { + initComponents(); + } + + public TrustGamePanel(ForagingClient client) { + this(); + this.client = client; + setRoundConfiguration(client.getCurrentRoundConfiguration()); + TableColumn column = playerTwoTable.getColumnModel().getColumn(2); + column.setCellEditor(new DefaultCellEditor(new JComboBox()) { + public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) { + JComboBox combo = (JComboBox) super.getTableCellEditorComponent(table, value, selected, row, column); + combo.removeAllItems(); + int numberOfQuarters = row * 3; + for (int i = 0; i <= numberOfQuarters; i++) { + combo.addItem(Double.valueOf(i * roundConfiguration.getTrustGamePayoffIncrement())); + } + return combo; + } + }); + } + + public void setRoundConfiguration(RoundConfiguration configuration) { + this.roundConfiguration = configuration; + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + playerOneActionButtonGroup = new javax.swing.ButtonGroup(); + jPanel1 = new javax.swing.JPanel(); + playerOneAmountKeptLabel = new javax.swing.JLabel(); + playerOneAmountSentLabel = new javax.swing.JLabel(); + playerOneAmountReceived = new javax.swing.JLabel(); + playerOneAction = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + playerOneRadioButton1 = new javax.swing.JRadioButton(); + playerOneRadioButton2 = new javax.swing.JRadioButton(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + playerOneRadioButton3 = new javax.swing.JRadioButton(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + playerOneRadioButton4 = new javax.swing.JRadioButton(); + playerOneRadioButton5 = new javax.swing.JRadioButton(); + jLabel13 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + playerTwoLabel = new javax.swing.JLabel(); + submitButton = new javax.swing.JButton(); + jLabel16 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + playerTwoTable = new javax.swing.JTable(); + playerOneTableLabel = new javax.swing.JLabel(); + + playerOneAmountKeptLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N + playerOneAmountKeptLabel.setText("Amount to keep"); + playerOneAmountKeptLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + + playerOneAmountSentLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); + playerOneAmountSentLabel.setText("Amount to send to P2"); + playerOneAmountSentLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + + playerOneAmountReceived.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N + playerOneAmountReceived.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + playerOneAmountReceived.setText("Amount received by P2 "); + playerOneAmountReceived.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + + playerOneAction.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N + playerOneAction.setText("Select"); + playerOneAction.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("0 cents"); + jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText("1 dollar"); + jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel4.setText("(3 x 1) = 3 dollars"); + jLabel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel4.setFocusable(false); + + jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel5.setText("(3 x 0.75) = 2.25 dollars"); + jLabel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel5.setFocusable(false); + + jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel3.setText("75 cents"); + jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel6.setText("25 cents"); + jLabel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + playerOneActionButtonGroup.add(playerOneRadioButton1); + playerOneRadioButton1.setActionCommand("0"); + + playerOneActionButtonGroup.add(playerOneRadioButton2); + playerOneRadioButton2.setActionCommand("1"); + + jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel7.setText("50 cents"); + jLabel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel8.setText("50 cents"); + jLabel8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel9.setText("(3 x 0.5) = 1.5 dollars"); + jLabel9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel9.setFocusable(false); + + playerOneActionButtonGroup.add(playerOneRadioButton3); + playerOneRadioButton3.setActionCommand("2"); + + jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel10.setText("75 cents"); + jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel11.setText("25 cents"); + jLabel11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel12.setText("(3 x 0.25) = 0.75 cents"); + jLabel12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel12.setFocusable(false); + + playerOneActionButtonGroup.add(playerOneRadioButton4); + playerOneRadioButton4.setActionCommand("3"); + + playerOneActionButtonGroup.add(playerOneRadioButton5); + playerOneRadioButton5.setActionCommand("4"); + + jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel13.setText("1 dollar"); + jLabel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel14.setText("0 cents"); + jLabel14.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel15.setText("(3 x 0) = 0 cents"); + jLabel15.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel15.setFocusable(false); + + playerTwoLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N + playerTwoLabel.setText("Player 2: Please enter data for ALL of the following allocations."); + + submitButton.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + submitButton.setText("Submit"); + submitButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + submitButtonActionPerformed(evt); + } + }); + + jLabel16.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel16.setText("Click in the \"Amount to keep\" column to select how much to keep if you are selected as player 2."); + + playerTwoTable.setFont(new java.awt.Font("Trebuchet MS", 0, 15)); // NOI18N + playerTwoTable.setModel(getPlayerTwoTableModel()); + jScrollPane1.setViewportView(playerTwoTable); + + playerOneTableLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); // NOI18N + playerOneTableLabel.setText("Player 1: Please select one of the following allocations."); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel16) + .addContainerGap(103, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(playerOneTableLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 483, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) + .addComponent(playerOneAmountKeptLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .addComponent(playerOneAmountSentLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(playerOneAmountReceived, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() + .addGap(292, 292, 292) + .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() + .addGap(292, 292, 292) + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(playerOneAction) + .addComponent(playerOneRadioButton3) + .addComponent(playerOneRadioButton2) + .addComponent(playerOneRadioButton1) + .addComponent(playerOneRadioButton4) + .addComponent(playerOneRadioButton5)) + .addGap(302, 302, 302)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(playerTwoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 831, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(submitButton) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 672, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(22, Short.MAX_VALUE)))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(playerOneTableLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(playerOneAmountKeptLabel) + .addComponent(playerOneAmountSentLabel) + .addComponent(playerOneAction) + .addComponent(playerOneAmountReceived)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)) + .addComponent(playerOneRadioButton1)) + .addGap(4, 4, 4) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)) + .addComponent(playerOneRadioButton2)) + .addGap(2, 2, 2) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel9) + .addComponent(jLabel8) + .addComponent(jLabel7) + .addComponent(playerOneRadioButton3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel10) + .addComponent(jLabel11) + .addComponent(jLabel12) + .addComponent(playerOneRadioButton4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13) + .addComponent(jLabel14) + .addComponent(jLabel15)) + .addComponent(playerOneRadioButton5)) + .addGap(39, 39, 39) + .addComponent(playerTwoLabel) + .addGap(12, 12, 12) + .addComponent(jLabel16) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(submitButton) + .addContainerGap(23, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 704, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + }// </editor-fold>//GEN-END:initComponents + + private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_submitButtonActionPerformed + // TODO add your handling code here: + String selectedPlayerOneAction = playerOneActionButtonGroup.getSelection().getActionCommand(); + if (selectedPlayerOneAction == null || "".equals(selectedPlayerOneAction.trim())) { + selectedPlayerOneAction = "4"; + } + Double playerOneAmountToKeep = (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); + Double[] playerTwoAmountsToKeep = new Double[4]; + Arrays.fill(playerTwoAmountsToKeep, 0.0d); + for (int i = 1; i <= 4; i++) { + playerTwoAmountsToKeep[i - 1] = (Double) playerTwoTable.getValueAt(i, 2); + } + client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); + + + + }// GEN-LAST:event_submitButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel playerOneAction; + private javax.swing.ButtonGroup playerOneActionButtonGroup; + private javax.swing.JLabel playerOneAmountKeptLabel; + private javax.swing.JLabel playerOneAmountReceived; + private javax.swing.JLabel playerOneAmountSentLabel; + private javax.swing.JRadioButton playerOneRadioButton1; + private javax.swing.JRadioButton playerOneRadioButton2; + private javax.swing.JRadioButton playerOneRadioButton3; + private javax.swing.JRadioButton playerOneRadioButton4; + private javax.swing.JRadioButton playerOneRadioButton5; + private javax.swing.JLabel playerOneTableLabel; + private javax.swing.JLabel playerTwoLabel; + private javax.swing.JTable playerTwoTable; + private javax.swing.JButton submitButton; + // End of variables declaration//GEN-END:variables +} --- a/src/main/java/edu/asu/commons/foraging/client/TrustGameWindow.java Tue Aug 16 19:56:13 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,577 +0,0 @@ -package edu.asu.commons.foraging.client; - -import java.awt.Component; -import java.util.Arrays; - -import javax.swing.DefaultCellEditor; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableModel; - -import edu.asu.commons.foraging.conf.RoundConfiguration; - -/** - * $Id:$ - * - * @author alllee - */ -public class TrustGameWindow extends JPanel { - - private static final long serialVersionUID = 4780102066737046088L; - private RoundConfiguration roundConfiguration; - private ForagingClient client; - - private class PlayerTwoTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 8044821545875471685L; - private String[] columnNames = { "Amount sent by P1", "Total amount received", "Amount to keep", "Amount to return to P1" }; - private Object[][] columnDataTable = { - - { "0 cents", "(3 x 0) = 0 cents", "0", "0" }, - { "25 cents", "(3 x 0.25) = 75 cents", "", "" }, - { "50 cents", "(3 x 0.5) = 1.5 dollars", "", "" }, - { "75 cents", "(3 x 0.75) = 2.25 dollars", "", "" }, - { "1 dollar", "(3 x 1) = 3 dollars", "", "" } - }; - - @Override - public int getColumnCount() { - return columnNames.length; - } - - @Override - public String getColumnName(int col) { - return columnNames[col]; - } - - @Override - public int getRowCount() { - return columnDataTable.length; - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return columnDataTable[rowIndex][columnIndex]; - } - - @Override - public boolean isCellEditable(int row, int col) { - // Note that the data/cell address is constant, - // no matter where the cell appears onscreen. - return (col == 2) && (row != 0); - } - - @Override - public void setValueAt(Object value, int row, int col) { - if (value == null) { - return; - } - try { - Double amount = Double.parseDouble(value.toString()); - columnDataTable[row][col] = amount; - Double totalAmount = row * 3 * roundConfiguration.getTrustGamePayoffIncrement(); - columnDataTable[row][col + 1] = totalAmount - amount; - fireTableCellUpdated(row, col + 1); - } catch (NumberFormatException exception) { - JOptionPane.showMessageDialog(TrustGameWindow.this, "Please enter a valid number."); - return; - } - } - } - - private class PlayerTwoInputColumnCellEditor extends DefaultCellEditor { - private static final long serialVersionUID = -981239232309467766L; - - public PlayerTwoInputColumnCellEditor() { - super(new JComboBox()); - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) { - JComboBox combo = (JComboBox) super.getTableCellEditorComponent(table, value, selected, row, column); - combo.removeAllItems(); - int numberOfQuarters = row * 3; - for (int i = 0; i <= numberOfQuarters; i++) { - combo.addItem(Double.valueOf(i * roundConfiguration.getTrustGamePayoffIncrement())); - } - return combo; - } - } - - private TableModel playerTwoTableModel; - - private TableModel getPlayerTwoTableModel() { - if (playerTwoTableModel == null) { - playerTwoTableModel = new PlayerTwoTableModel(); - } - return playerTwoTableModel; - } - - /** Creates new form TrustGameWindow */ - public TrustGameWindow() { - initComponents(); - } - - public TrustGameWindow(ForagingClient client) { - this(); - this.client = client; - setRoundConfiguration(client.getCurrentRoundConfiguration()); - } - - public void setRoundConfiguration(RoundConfiguration configuration) { - this.roundConfiguration = configuration; - } - - /** - * This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - playerOneActionButtonGroup = new javax.swing.ButtonGroup(); - jPanel1 = new javax.swing.JPanel(); - playerOneAmountKeptLabel = new javax.swing.JLabel(); - playerOneAmountSentLabel = new javax.swing.JLabel(); - playerOneAmountReceived = new javax.swing.JLabel(); - playerOneAction = new javax.swing.JLabel(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - playerOneRadioButton1 = new javax.swing.JRadioButton(); - playerOneRadioButton2 = new javax.swing.JRadioButton(); - jLabel7 = new javax.swing.JLabel(); - jLabel8 = new javax.swing.JLabel(); - jLabel9 = new javax.swing.JLabel(); - playerOneRadioButton3 = new javax.swing.JRadioButton(); - jLabel10 = new javax.swing.JLabel(); - jLabel11 = new javax.swing.JLabel(); - jLabel12 = new javax.swing.JLabel(); - playerOneRadioButton4 = new javax.swing.JRadioButton(); - playerOneRadioButton5 = new javax.swing.JRadioButton(); - jLabel13 = new javax.swing.JLabel(); - jLabel14 = new javax.swing.JLabel(); - jLabel15 = new javax.swing.JLabel(); - playerTwoLabel = new javax.swing.JLabel(); - submitButton = new javax.swing.JButton(); - jLabel16 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - playerTwoTable = new javax.swing.JTable(); - playerOneTableLabel = new javax.swing.JLabel(); - - playerOneAmountKeptLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerOneAmountKeptLabel.setText("Amount to keep"); - playerOneAmountKeptLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); - - playerOneAmountSentLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerOneAmountSentLabel.setText("Amount to send to P2"); - playerOneAmountSentLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); - - playerOneAmountReceived.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerOneAmountReceived.setText("Amount received by P2 "); - playerOneAmountReceived.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); - - playerOneAction.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerOneAction.setText("Action"); - playerOneAction.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); - - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel1.setText("0 cents"); - jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel2.setText("1 dollar"); - jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel4.setText("(3 x 1) = 3 dollars"); - jLabel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel5.setText("(3 x 0.75) = 2.25 dollars"); - jLabel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel3.setText("75 cents"); - jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel6.setText("25 cents"); - jLabel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - playerOneActionButtonGroup.add(playerOneRadioButton1); - playerOneRadioButton1.setActionCommand("0"); - - playerOneActionButtonGroup.add(playerOneRadioButton2); - playerOneRadioButton2.setActionCommand("1"); - - jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel7.setText("50 cents"); - jLabel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel8.setText("50 cents"); - jLabel8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel9.setText("(3 x 0.5) = 1.5 dollars"); - jLabel9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - playerOneActionButtonGroup.add(playerOneRadioButton3); - playerOneRadioButton3.setActionCommand("2"); - - jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel10.setText("75 cents"); - jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel11.setText("25 cents"); - jLabel11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel12.setText("(3 x 0.25) = 0.75 cents"); - jLabel12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - playerOneActionButtonGroup.add(playerOneRadioButton4); - playerOneRadioButton4.setActionCommand("3"); - - playerOneActionButtonGroup.add(playerOneRadioButton5); - playerOneRadioButton5.setActionCommand("4"); - - jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel13.setText("1 dollar"); - jLabel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel14.setText("0 cents"); - jLabel14.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel15.setText("(3 x 0) = 0 cents"); - jLabel15.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - playerTwoLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerTwoLabel.setText("Player 2: Please enter data for ALL of the following allocations."); - - submitButton.setText("Submit"); - submitButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - submitButtonActionPerformed(evt); - } - }); - - jLabel16.setText("Click in the \"Amount to keep\" column to select how much you would like to keep."); - - playerTwoTable.setFont(new java.awt.Font("Trebuchet MS", 0, 15)); - playerTwoTable.setModel(getPlayerTwoTableModel()); - jScrollPane1.setViewportView(playerTwoTable); - - playerOneTableLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 15)); - playerOneTableLabel.setText("Player 1: Please select one of the following allocations."); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout - .setHorizontalGroup( - jPanel1Layout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel1Layout - .createSequentialGroup() - .addContainerGap() - .addGroup( - jPanel1Layout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel16) - .addContainerGap(156, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(submitButton) - .addGap(62, 62, 62)) - .addGroup( - jPanel1Layout - .createSequentialGroup() - .addGroup( - jPanel1Layout - .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(playerOneTableLabel, - javax.swing.GroupLayout.PREFERRED_SIZE, 483, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup( - jPanel1Layout - .createSequentialGroup() - .addGroup( - jPanel1Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING, - false) - .addComponent( - jLabel13, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel10, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel7, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel6, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel1, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - playerOneAmountKeptLabel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup( - jPanel1Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING, - false) - .addComponent( - jLabel14, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel11, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel8, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel3, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel2, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - playerOneAmountSentLabel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup( - jPanel1Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING, - false) - .addComponent( - jLabel15, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel9, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel12, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel5, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - jLabel4, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - playerOneAmountReceived, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup( - jPanel1Layout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - ... [truncated message content] |
From: Bitbucket <com...@bi...> - 2011-08-17 02:56:18
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/d3f66c32b3f5/ changeset: d3f66c32b3f5 user: alllee date: 2011-08-17 04:56:13 summary: wiring up event transmission affected #: 4 files (18.3 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Tue Aug 16 19:41:02 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Tue Aug 16 19:56:13 2011 -0700 @@ -34,6 +34,7 @@ import edu.asu.commons.foraging.event.ShowInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; +import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; import edu.asu.commons.net.SocketIdentifier; import edu.asu.commons.util.Duration; import edu.asu.commons.util.Utils; @@ -442,4 +443,8 @@ }; SwingUtilities.invokeLater(createGuiRunnable); } + + public void sendTrustGameSubmissionRequest(Double playerOneAmountToKeep, Double[] playerTwoAmountsToKeep) { + transmit(new TrustGameSubmissionRequest(getId(), playerOneAmountToKeep, playerTwoAmountsToKeep)); + } } --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 19:41:02 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 19:56:13 2011 -0700 @@ -100,8 +100,6 @@ private JPanel subjectWindow; - private TrustGamePanel trustGamePanel; - private ForagingClient client; private SubjectView subjectView; @@ -748,18 +746,10 @@ public void showTrustGame() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); if (roundConfiguration.isTrustGameEnabled()) { - addCenterComponent(new TrustGameWindow(roundConfiguration)); + addCenterComponent(new TrustGameWindow(client)); } } - public TrustGamePanel getTrustGamePanel() { - if (trustGamePanel == null) { - // initialize - trustGamePanel = new TrustGamePanel(); - } - return trustGamePanel; - } - public void showInstructions() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); instructionsBuilder.delete(0, instructionsBuilder.length()); --- a/src/main/java/edu/asu/commons/foraging/client/TrustGameWindow.java Tue Aug 16 19:41:02 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/TrustGameWindow.java Tue Aug 16 19:56:13 2011 -0700 @@ -1,43 +1,46 @@ -/* - * TrustGameWindow.java - * - * Created on Aug 16, 2011, 2:28:14 PM - */ package edu.asu.commons.foraging.client; -import edu.asu.commons.foraging.conf.RoundConfiguration; import java.awt.Component; +import java.util.Arrays; + import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumn; import javax.swing.table.TableModel; +import edu.asu.commons.foraging.conf.RoundConfiguration; + /** - * + * $Id:$ + * * @author alllee */ -public class TrustGameWindow extends javax.swing.JPanel { +public class TrustGameWindow extends JPanel { + private static final long serialVersionUID = 4780102066737046088L; private RoundConfiguration roundConfiguration; - - private class PlayerTwoTableModel extends AbstractTableModel { - private String[] columnNames = {"Amount sent by P1", "Total amount received", "Amount to keep", "Amount to return to P1" }; - private Object[][] columnDataTable = { - - {"0 cents", "(3 x 0) = 0 cents", "0", "0"}, - {"25 cents", "(3 x 0.25) = 75 cents", "", ""}, - {"50 cents", "(3 x 0.5) = 1.5 dollars", "", ""}, - {"75 cents", "(3 x 0.75) = 2.25 dollars", "", ""}, - {"1 dollar", "(3 x 1) = 3 dollars", "", ""} + private ForagingClient client; + + private class PlayerTwoTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 8044821545875471685L; + private String[] columnNames = { "Amount sent by P1", "Total amount received", "Amount to keep", "Amount to return to P1" }; + private Object[][] columnDataTable = { + + { "0 cents", "(3 x 0) = 0 cents", "0", "0" }, + { "25 cents", "(3 x 0.25) = 75 cents", "", "" }, + { "50 cents", "(3 x 0.5) = 1.5 dollars", "", "" }, + { "75 cents", "(3 x 0.75) = 2.25 dollars", "", "" }, + { "1 dollar", "(3 x 1) = 3 dollars", "", "" } }; - + @Override public int getColumnCount() { return columnNames.length; - } + } @Override public String getColumnName(int col) { @@ -56,10 +59,11 @@ @Override public boolean isCellEditable(int row, int col) { - //Note that the data/cell address is constant, - //no matter where the cell appears onscreen. + // Note that the data/cell address is constant, + // no matter where the cell appears onscreen. return (col == 2) && (row != 0); } + @Override public void setValueAt(Object value, int row, int col) { if (value == null) { @@ -69,22 +73,22 @@ Double amount = Double.parseDouble(value.toString()); columnDataTable[row][col] = amount; Double totalAmount = row * 3 * roundConfiguration.getTrustGamePayoffIncrement(); - columnDataTable[row][col+1] = totalAmount - amount; - fireTableCellUpdated(row, col+1); - } - catch (NumberFormatException exception) { + columnDataTable[row][col + 1] = totalAmount - amount; + fireTableCellUpdated(row, col + 1); + } catch (NumberFormatException exception) { JOptionPane.showMessageDialog(TrustGameWindow.this, "Please enter a valid number."); return; } } } - + private class PlayerTwoInputColumnCellEditor extends DefaultCellEditor { - + private static final long serialVersionUID = -981239232309467766L; + public PlayerTwoInputColumnCellEditor() { super(new JComboBox()); } - + public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) { JComboBox combo = (JComboBox) super.getTableCellEditorComponent(table, value, selected, row, column); combo.removeAllItems(); @@ -92,34 +96,36 @@ for (int i = 0; i <= numberOfQuarters; i++) { combo.addItem(Double.valueOf(i * roundConfiguration.getTrustGamePayoffIncrement())); } - return combo; + return combo; } } - + private TableModel playerTwoTableModel; - + private TableModel getPlayerTwoTableModel() { if (playerTwoTableModel == null) { playerTwoTableModel = new PlayerTwoTableModel(); } return playerTwoTableModel; } - + /** Creates new form TrustGameWindow */ public TrustGameWindow() { - this(new RoundConfiguration()); + initComponents(); } - - public TrustGameWindow(RoundConfiguration configuration) { - initComponents(); - setRoundConfiguration(configuration); + + public TrustGameWindow(ForagingClient client) { + this(); + this.client = client; + setRoundConfiguration(client.getCurrentRoundConfiguration()); } - + public void setRoundConfiguration(RoundConfiguration configuration) { this.roundConfiguration = configuration; } - /** This method is called from within the constructor to + /** + * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. @@ -273,147 +279,266 @@ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel16) - .addContainerGap(156, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(submitButton) - .addGap(62, 62, 62)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(playerOneTableLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 483, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(playerOneAmountKeptLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + jPanel1Layout + .setHorizontalGroup( + jPanel1Layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup( + jPanel1Layout + .createSequentialGroup() + .addContainerGap() + .addGroup( + jPanel1Layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel16) + .addContainerGap(156, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(submitButton) + .addGap(62, 62, 62)) + .addGroup( + jPanel1Layout + .createSequentialGroup() + .addGroup( + jPanel1Layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(playerOneTableLabel, + javax.swing.GroupLayout.PREFERRED_SIZE, 483, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup( + jPanel1Layout + .createSequentialGroup() + .addGroup( + jPanel1Layout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING, + false) + .addComponent( + jLabel13, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel10, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel7, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel6, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel1, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + playerOneAmountKeptLabel, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addPreferredGap( + javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup( + jPanel1Layout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING, + false) + .addComponent( + jLabel14, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel11, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel8, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel3, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel2, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + playerOneAmountSentLabel, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addPreferredGap( + javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup( + jPanel1Layout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING, + false) + .addComponent( + jLabel15, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel9, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel12, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel5, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + jLabel4, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + playerOneAmountReceived, + javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup( + jPanel1Layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(playerOneAction) + .addGroup( + jPanel1Layout + .createSequentialGroup() + .addGap(12, 12, 12) + .addGroup( + jPanel1Layout + .createParallelGroup( + javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(playerOneRadioButton2) + .addComponent(playerOneRadioButton1) + .addComponent(playerOneRadioButton4) + .addComponent(playerOneRadioButton5) + .addComponent(playerOneRadioButton3)))) + .addGap(208, 208, 208)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(playerTwoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 698, Short.MAX_VALUE) + .addGap(50, 50, 50)) + .addGroup( + jPanel1Layout + .createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 672, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(42, Short.MAX_VALUE)))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(playerOneTableLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(playerOneAmountSentLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(playerOneAmountKeptLabel) + .addComponent(playerOneAmountSentLabel) + .addComponent(playerOneAmountReceived) + .addComponent(playerOneAction)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jLabel2) + .addComponent(jLabel4)) + .addComponent(playerOneRadioButton1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(playerOneAmountReceived, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(playerOneAction) - .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(jLabel3) + .addComponent(jLabel5)) + .addComponent(playerOneRadioButton2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7) + .addComponent(jLabel8) + .addComponent(jLabel9)) + .addComponent(playerOneRadioButton3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10) + .addComponent(jLabel12) + .addComponent(jLabel11)) + .addComponent(playerOneRadioButton4)) .addGap(12, 12, 12) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(playerOneRadioButton2) - .addComponent(playerOneRadioButton1) - .addComponent(playerOneRadioButton4) - .addComponent(playerOneRadioButton5) - .addComponent(playerOneRadioButton3)))) - .addGap(208, 208, 208)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(playerTwoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 698, Short.MAX_VALUE) - .addGap(50, 50, 50)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 672, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(42, Short.MAX_VALUE)))) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(playerOneTableLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(playerOneAmountKeptLabel) - .addComponent(playerOneAmountSentLabel) - .addComponent(playerOneAmountReceived) - .addComponent(playerOneAction)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(jLabel2) - .addComponent(jLabel4)) - .addComponent(playerOneRadioButton1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel6) - .addComponent(jLabel3) - .addComponent(jLabel5)) - .addComponent(playerOneRadioButton2)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel7) - .addComponent(jLabel8) - .addComponent(jLabel9)) - .addComponent(playerOneRadioButton3)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel10) - .addComponent(jLabel12) - .addComponent(jLabel11)) - .addComponent(playerOneRadioButton4)) - .addGap(12, 12, 12) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel13) - .addComponent(jLabel14) - .addComponent(jLabel15)) - .addComponent(playerOneRadioButton5)) - .addGap(18, 18, 18) - .addComponent(playerTwoLabel) - .addGap(12, 12, 12) - .addComponent(jLabel16) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(7, 7, 7) - .addComponent(submitButton) - .addContainerGap(27, Short.MAX_VALUE)) - ); + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13) + .addComponent(jLabel14) + .addComponent(jLabel15)) + .addComponent(playerOneRadioButton5)) + .addGap(18, 18, 18) + .addComponent(playerTwoLabel) + .addGap(12, 12, 12) + .addComponent(jLabel16) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(7, 7, 7) + .addComponent(submitButton) + .addContainerGap(27, Short.MAX_VALUE)) + ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 726, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(1333, Short.MAX_VALUE)) - ); + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 726, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(1333, Short.MAX_VALUE)) + ); layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(335, Short.MAX_VALUE)) - ); + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup( + layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(335, Short.MAX_VALUE)) + ); }// </editor-fold>//GEN-END:initComponents -private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButtonActionPerformed -// TODO add your handling code here: - String selectedPlayerOneAction = playerOneActionButtonGroup.getSelection().getActionCommand(); - if (selectedPlayerOneAction == null || "".equals(selectedPlayerOneAction.trim())) { - selectedPlayerOneAction = "4"; - } - int amountToKeep = (int) (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); - - -}//GEN-LAST:event_submitButtonActionPerformed + private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_submitButtonActionPerformed + // TODO add your handling code here: + String selectedPlayerOneAction = playerOneActionButtonGroup.getSelection().getActionCommand(); + if (selectedPlayerOneAction == null || "".equals(selectedPlayerOneAction.trim())) { + selectedPlayerOneAction = "4"; + } + Double playerOneAmountToKeep = (Integer.parseInt(selectedPlayerOneAction) * roundConfiguration.getTrustGamePayoffIncrement()); + Double[] playerTwoAmountsToKeep = new Double[4]; + Arrays.fill(playerTwoAmountsToKeep, 0.0d); + for (int i = 1; i <= 4; i++) { + playerTwoAmountsToKeep[i - 1] = (Double) playerTwoTable.getValueAt(i, 2); + } + client.sendTrustGameSubmissionRequest(playerOneAmountToKeep, playerTwoAmountsToKeep); + + + + }// GEN-LAST:event_submitButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; --- a/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Tue Aug 16 19:41:02 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/TrustGameSubmissionRequest.java Tue Aug 16 19:56:13 2011 -0700 @@ -5,19 +5,21 @@ public class TrustGameSubmissionRequest extends AbstractPersistableEvent { - private int playerOneAmountToKeep; + private static final long serialVersionUID = -4962852585789164775L; + + private Double playerOneAmountToKeep; - private int[] playerTwoAmountsToKeep; + private Double[] playerTwoAmountsToKeep; - public int getPlayerOneAmountToKeep() { + public Double getPlayerOneAmountToKeep() { return playerOneAmountToKeep; } - public int[] getPlayerTwoAmountsToKeep() { + public Double[] getPlayerTwoAmountsToKeep() { return playerTwoAmountsToKeep; } - public TrustGameSubmissionRequest(Identifier id, int playerOneAmountToKeep, int[] playerTwoAmountsToKeep) { + public TrustGameSubmissionRequest(Identifier id, Double playerOneAmountToKeep, Double[] playerTwoAmountsToKeep) { super(id); this.playerOneAmountToKeep = playerOneAmountToKeep; this.playerTwoAmountsToKeep = playerTwoAmountsToKeep; Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-17 02:41:07
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/27b190134ee8/ changeset: 27b190134ee8 user: alllee date: 2011-08-17 04:41:02 summary: updated trust game window affected #: 13 files (28.3 KB) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Tue Aug 16 19:41:02 2011 -0700 @@ -32,6 +32,7 @@ import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.net.SocketIdentifier; import edu.asu.commons.util.Duration; @@ -73,7 +74,7 @@ private JPanel clientPanel = new JPanel(); public ForagingClient(ServerConfiguration configuration) { - this(configuration, new Dimension(800, 600)); + this(configuration, new Dimension(900, 800)); } public ForagingClient(ServerConfiguration configuration, Dimension screenSize) { @@ -159,7 +160,11 @@ getGameWindow().showInstructions(); } }); - + addEventProcessor(new EventTypeProcessor<ShowTrustGameRequest>(ShowTrustGameRequest.class) { + public void handle(ShowTrustGameRequest request) { + getGameWindow().showTrustGame(); + } + }); addEventProcessor(new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { public void handle(RoundStartedEvent event) { System.err.println("client starting round: " + dataModel.is2dExperiment()); --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow.java Tue Aug 16 19:41:02 2011 -0700 @@ -18,4 +18,6 @@ public void update(long millisecondsLeft); public void showInstructions(); + public void showTrustGame(); + } --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Tue Aug 16 19:41:02 2011 -0700 @@ -100,6 +100,8 @@ private JPanel subjectWindow; + private TrustGamePanel trustGamePanel; + private ForagingClient client; private SubjectView subjectView; @@ -428,12 +430,10 @@ instructionsScrollPane = new JScrollPane(instructionsEditorPane); add(instructionsScrollPane, BorderLayout.CENTER); currentCenterComponent = instructionsScrollPane; - // setup the Subject Window, add the experiment view - subjectWindow = new JPanel(new BorderLayout(4, 4)); + subjectWindow = new JPanel(new BorderLayout()); 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 ..."); @@ -630,13 +630,7 @@ if (configuration.isInRoundChatEnabled()) { ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(); -// Dimension subjectWindowSize = subjectView.getSize(); -// Dimension totalSize = getParent().getSize(); -// System.err.println("subject window size: " + subjectWindowSize); -// System.err.println("total size: " + totalSize); -// Dimension chatPanelSize = new Dimension((totalSize.width - subjectWindowSize.width) / 2, (totalSize.height - subjectWindowSize.height) / 2); -// System.err.println("chat panel size: " + chatPanelSize); - Dimension chatPanelSize = new Dimension(100, getSize().height); + Dimension chatPanelSize = new Dimension(200, getSize().height); chatPanel.setPreferredSize(chatPanelSize); add(chatPanel, BorderLayout.EAST); } @@ -751,6 +745,21 @@ return chatPanel; } + public void showTrustGame() { + RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); + if (roundConfiguration.isTrustGameEnabled()) { + addCenterComponent(new TrustGameWindow(roundConfiguration)); + } + } + + public TrustGamePanel getTrustGamePanel() { + if (trustGamePanel == null) { + // initialize + trustGamePanel = new TrustGamePanel(); + } + return trustGamePanel; + } + public void showInstructions() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); instructionsBuilder.delete(0, instructionsBuilder.length()); --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java Tue Aug 16 19:41:02 2011 -0700 @@ -45,6 +45,11 @@ private JPanel gameInformationPanel; private EmbeddedChatPanel chatPanel; + + @Override + public void showTrustGame() { + throw new UnsupportedOperationException("Not supported yet."); + } public static enum VideoCardSupport{SHADER_SUPPORT, VBO_SUPPORT, VERTEX_ARRAY_SUPPORT}; public static VideoCardSupport featureSupported; --- a/src/main/java/edu/asu/commons/foraging/client/GridView.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GridView.java Tue Aug 16 19:41:02 2011 -0700 @@ -165,9 +165,6 @@ } protected void paintComponent(Graphics graphics) { - // XXX: if this guy didn't fill the entire component we'd have to do - // this super call to let the UI delegate some paintage as well. - // super.paintComponent(graphics); Graphics2D graphics2D = (Graphics2D) graphics; // graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // FIXME: can be made more efficient. --- a/src/main/java/edu/asu/commons/foraging/client/SubjectView.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/SubjectView.java Tue Aug 16 19:41:02 2011 -0700 @@ -39,12 +39,27 @@ private final ClientDataModel dataModel; + private boolean tokenFieldOfVision; + private boolean subjectFieldOfVision; + public final static Color FIELD_OF_VISION_COLOR = new Color(255, 255, 255, 150); // associates a Duration with a piece of token consumed at the given Point - // the duration is used to render the token as shrinking. private Map<Point, Duration> collectedTokens = new HashMap<Point, Duration>(); + private int viewSubjectsRadius; + + private double viewTokensRadius; + + private Circle viewTokensField; + + private Circle viewSubjectsField; + + private double fieldOfVisionYOffset; + + private double fieldOfVisionXOffset; + public SubjectView(Dimension screenSize, ClientDataModel dataModel) { super(screenSize); this.dataModel = dataModel; @@ -57,24 +72,35 @@ public void setup(RoundConfiguration configuration) { synchronized (collectedTokens) { collectedTokens.clear(); + tokenFieldOfVision = configuration.isTokensFieldOfVisionEnabled(); + if (tokenFieldOfVision) { + viewTokensRadius = configuration.getViewTokensRadius(); + Point location = dataModel.getCurrentPosition(); + viewTokensField = new Circle(location, viewTokensRadius); + } + subjectFieldOfVision = configuration.isSubjectsFieldOfVisionEnabled(); + if (subjectFieldOfVision) { + viewSubjectsRadius = configuration.getViewSubjectsRadius(); + viewSubjectsField = new Circle(dataModel.getCurrentPosition(), viewSubjectsRadius); + fieldOfVisionXOffset = (dw / 3.0); + fieldOfVisionYOffset = (dh / 3.0); + } } super.setup(configuration); } public void collectToken(Point p) { synchronized (collectedTokens) { - collectedTokens.put(p, Duration.create(1000L)); + collectedTokens.put(p, Duration.create(3000L)); } } protected void paintTokens(Graphics2D graphics2D) { // three cases - show all food on the game board, show all food within // visible radius of the current player, or don't show any food. - if (dataModel.getRoundConfiguration().isTokensFieldOfVisionEnabled()) { - Point location = dataModel.getCurrentPosition(); - Circle viewTokensField = new Circle(location, dataModel.getRoundConfiguration().getViewTokensRadius()); + if (tokenFieldOfVision) { + viewTokensField.setCenter(dataModel.getCurrentPosition()); paintCollection(dataModel.getResourcePositions(), graphics2D, scaledTokenImage, this, viewTokensField); - } else { paintCollection(dataModel.getResourcePositions(), graphics2D, scaledTokenImage); @@ -122,20 +148,17 @@ FontMetrics fontMetrics = graphics2D.getFontMetrics(font); int characterHeight = fontMetrics.getAscent(); int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); - Circle fieldOfVision = null; Point currentPosition = dataModel.getCurrentPosition(); - RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); - if (roundConfiguration.isSubjectsFieldOfVisionEnabled()) { + if (subjectFieldOfVision) { // paint a transparent circle centered on the current position of the subject. - int radius = roundConfiguration.getViewSubjectsRadius(); - fieldOfVision = new Circle(currentPosition, radius); + int radius = viewSubjectsRadius; + viewSubjectsField.setCenter(currentPosition); Point topLeftCorner = new Point(currentPosition.x - radius, currentPosition.y - radius); - double x = scaleXDouble(topLeftCorner.x) + (dw / 3); - double y = scaleYDouble(topLeftCorner.y) + (dh / 3); + double x = scaleXDouble(topLeftCorner.x) + fieldOfVisionXOffset; + double y = scaleYDouble(topLeftCorner.y) + fieldOfVisionYOffset; double diameter = radius * 2.0d; diameter = Math.min(scaleXDouble(diameter), scaleYDouble(diameter)) + (dw / 2); Ellipse2D.Double circle = new Ellipse2D.Double(x, y, diameter, diameter); - //graphics2D.fillOval(x, y, diameter, diameter); // clip the rendered part of the Field of vision circle that crosses the playing boundary graphics2D.setClip(circle); Paint originalPaint = graphics2D.getPaint(); @@ -147,7 +170,7 @@ Identifier id = entry.getKey(); Point subjectLocation = entry.getValue().getPosition(); // optimized conditional - if (fieldOfVision == null || id.equals(dataModel.getId()) || fieldOfVision.contains(subjectLocation)) { + if (viewSubjectsField == null || id.equals(dataModel.getId()) || viewSubjectsField.contains(subjectLocation)) { // only draw if: // 1. field of vision is not enabled for subjects // 2. subject being drawn is this participant (i.e., id == dataModel.id) --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Tue Aug 16 19:41:02 2011 -0700 @@ -42,6 +42,10 @@ private static final double DEFAULT_TOKEN_MOVEMENT_PROBABILITY = 0.2d; private static final double DEFAULT_TOKEN_BIRTH_PROBABILITY = 0.01d; + + public double getTrustGamePayoffIncrement() { + return getDoubleProperty("trust-game-payoff", 0.25d); + } public enum SanctionType { REAL_TIME, POST_ROUND, NONE; @@ -505,7 +509,7 @@ } public boolean isTrustGameEnabled() { - return getBooleanProperty("trust-game", false); + return getBooleanProperty("trust-game", true); } public boolean isInRoundChatEnabled() { @@ -572,4 +576,8 @@ return instructionsBuilder; } + public String getTrustGameInstructions() { + return getProperty("trust-game-instructions", "Instructions: You will be randomly matched with another person in your group."); + } + } --- a/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/Facilitator.java Tue Aug 16 19:41:02 2011 -0700 @@ -22,27 +22,22 @@ import edu.asu.commons.foraging.event.FacilitatorUpdateEvent; import edu.asu.commons.foraging.event.QuizCompletedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.model.ServerDataModel; - - /** * $Id: Facilitator.java 529 2010-08-17 00:08:01Z alllee $ * * @author <a href='ano...@gm...'>Allen Lee</a>, Deepali Bhagvat * @version $Revision: 529 $ */ - public class Facilitator extends BaseFacilitator<ServerConfiguration> { private final static Facilitator INSTANCE = new Facilitator(); + private ServerDataModel serverDataModel; + private FacilitatorWindow facilitatorWindow; + private boolean experimentRunning = false; - private ServerDataModel serverDataModel; - - private FacilitatorWindow facilitatorWindow; - - private boolean experimentRunning = false; - private Facilitator() { this(new ServerConfiguration()); } @@ -51,35 +46,39 @@ public Facilitator(ServerConfiguration configuration) { super(configuration); addEventProcessor(new EventTypeProcessor<SetConfigurationEvent>(SetConfigurationEvent.class) { + public void handle(SetConfigurationEvent event) { RoundConfiguration configuration = (RoundConfiguration) event.getParameters(); setServerConfiguration(configuration.getParentConfiguration()); } }); addEventProcessor(new EventTypeProcessor<FacilitatorUpdateEvent>(FacilitatorUpdateEvent.class) { + public void handle(FacilitatorUpdateEvent event) { if (serverDataModel == null) { experimentRunning = true; serverDataModel = event.getServerDataModel(); facilitatorWindow.displayGame(); - } - else { + } else { serverDataModel = event.getServerDataModel(); } } }); addEventProcessor(new EventTypeProcessor<FacilitatorEndRoundEvent>(FacilitatorEndRoundEvent.class) { + public void handle(FacilitatorEndRoundEvent event) { serverDataModel = null; facilitatorWindow.endRound(event); } }); addEventProcessor(new EventTypeProcessor<FacilitatorSanctionUpdateEvent>(FacilitatorSanctionUpdateEvent.class) { + public void handle(FacilitatorSanctionUpdateEvent event) { facilitatorWindow.updateDebriefing(event); } }); addEventProcessor(new EventTypeProcessor<QuizCompletedEvent>(QuizCompletedEvent.class) { + public void handle(QuizCompletedEvent event) { facilitatorWindow.quizCompleted(); } @@ -90,12 +89,12 @@ public static Facilitator getInstance() { return INSTANCE; } - + void createFacilitatorWindow(Dimension dimension) { facilitatorWindow = new FacilitatorWindow(dimension, this); if (getId() == null) { // configure for unconnected functionality - facilitatorWindow.configureForReplay(); + facilitatorWindow.configureForReplay(); } } @@ -148,21 +147,25 @@ /** * Sends a request to show round instructions */ - public void sendShowInstructionsRequest() - { - transmit(new ShowInstructionsRequest(getId())); + public void sendShowInstructionsRequest() { + transmit(new ShowInstructionsRequest(getId())); + } + + void sendShowTrustGameRequest() { + transmit(new ShowTrustGameRequest(getId())); } /* * Send a request to start a round */ + public void sendBeginRoundRequest() { transmit(new BeginRoundRequest(getId())); } - - public void sendBeginChatRoundRequest() { - transmit(new BeginChatRoundRequest(getId())); - } - + + public void sendBeginChatRoundRequest() { + transmit(new BeginChatRoundRequest(getId())); + } + public void endExperiment() { // configuration.resetRoundConfiguration(); // serverGameState = null; @@ -189,8 +192,6 @@ return facilitatorWindow; } - - public ServerDataModel getServerGameState() { return serverDataModel; } @@ -203,13 +204,14 @@ public boolean isExperimentRunning() { return experimentRunning; } - + public boolean isReplaying() { return getId() == null; } public static void main(String[] args) { Runnable createGuiRunnable = new Runnable() { + public void run() { Dimension dimension = new Dimension(700, 700); Facilitator facilitator = Facilitator.getInstance(); @@ -231,10 +233,8 @@ public RoundConfiguration getCurrentRoundConfiguration() { return getServerConfiguration().getCurrentParameters(); } - + public void setServerGameState(ServerDataModel serverGameState) { this.serverDataModel = serverGameState; } - - } --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Tue Aug 16 19:41:02 2011 -0700 @@ -76,6 +76,7 @@ private int completedQuizzes; private JMenuItem startChatMenuItem; + private JMenuItem showTrustGameMenuItem; public FacilitatorWindow(Dimension dimension, Facilitator facilitator) { this.facilitator = facilitator; @@ -170,6 +171,14 @@ }); menu.add(showInstructionsMenuItem); + showTrustGameMenuItem = new JMenuItem("Show Trust Game"); + showTrustGameMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.sendShowTrustGameRequest(); + } + }); + menu.add(showTrustGameMenuItem); + startRoundMenuItem = new JMenuItem("Start"); startRoundMenuItem.setMnemonic(KeyEvent.VK_T); startRoundMenuItem.setEnabled(false); --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Wed Aug 03 17:13:58 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Tue Aug 16 19:41:02 2011 -0700 @@ -54,6 +54,7 @@ import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.SanctionAppliedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowTrustGameRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.UnlockResourceRequest; import edu.asu.commons.foraging.model.ClientData; @@ -616,6 +617,19 @@ } } }); + addEventProcessor(new EventTypeProcessor<ShowTrustGameRequest>(ShowTrustGameRequest.class) { + public void handle(ShowTrustGameRequest event) { + if (event.getId().equals(facilitatorId)) { + logger.info("Showing trust game."); + for (Identifier id: clients.keySet()) { + transmit(new ShowTrustGameRequest(id)); + } + } + else { + logger.warning("Ignoring show instructions request from id: " + event.getId()); + } + } + }); addEventProcessor(new EventTypeProcessor<BeginRoundRequest>(BeginRoundRequest.class) { public void handle(BeginRoundRequest event) { if (event.getId().equals(facilitatorId)) { Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-12 08:11:20
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/7f89e499f37e/ changeset: 7f89e499f37e user: alllee date: 2011-08-12 10:11:11 summary: embarassingly wrong import affected #: 1 file (7 bytes) --- a/vcweb/lighterprints/forms.py Fri Aug 12 01:10:11 2011 -0700 +++ b/vcweb/lighterprints/forms.py Fri Aug 12 01:11:11 2011 -0700 @@ -1,6 +1,6 @@ from django import forms -from django.utils.html.escape import escape +from django.utils.html import escape class ChatForm(forms.Form): Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-12 08:10:20
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/8c69762b8eb6/ changeset: 8c69762b8eb6 user: alllee date: 2011-08-12 10:10:11 summary: html escaping incoming chat messages affected #: 1 file (127 bytes) --- a/vcweb/lighterprints/forms.py Fri Aug 12 00:52:12 2011 -0700 +++ b/vcweb/lighterprints/forms.py Fri Aug 12 01:10:11 2011 -0700 @@ -1,9 +1,14 @@ from django import forms +from django.utils.html.escape import escape + class ChatForm(forms.Form): message = forms.CharField(required=True, max_length=512) participant_group_id = forms.IntegerField(required=True, widget=forms.HiddenInput) + def clean_message(self): + return escape(self.cleaned_data['message']) + class ActivityForm(forms.Form): activity_id = forms.IntegerField(required=True, widget=forms.HiddenInput) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-12 07:52:22
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/73646c605252/ changeset: 73646c605252 user: alllee date: 2011-08-12 09:52:12 summary: fixing bug with participant number affected #: 1 file (43 bytes) --- a/vcweb/lighterprints/views.py Thu Aug 11 16:49:33 2011 -0700 +++ b/vcweb/lighterprints/views.py Fri Aug 12 00:52:12 2011 -0700 @@ -136,8 +136,7 @@ chat_messages.append({ 'date_created': timesince(chat_message.date_created), 'message': chat_message.message, - 'participant_number': participant_group_relationship.participant_number, - 'participant': participant_group_relationship.participant + 'participant_number': chat_message.participant_group_relationship.participant_number, }) group_activity = [] performed_activities = ParticipantRoundDataValue.objects.filter(participant_group_relationship__group=group, submitted=True, parameter=get_activity_performed_parameter()).order_by('-date_created') @@ -147,7 +146,7 @@ activity = Activity.objects.get(pk=activity_prdv.value) performed_activity_dict = to_activity_dict(activity, attrs=('pk', 'display_name', 'name', 'icon_url', 'savings')) performed_activity_dict['date_performed'] = activity_prdv.date_created - performed_activity_dict['participant_id'] = participant_group_relationship.participant_number + performed_activity_dict['participant_id'] = activity_prdv.participant_group_relationship.participant_number performed_activity_dict['performed_activity_id'] = activity_prdv.pk group_activity.append(performed_activity_dict) return dumps({ Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 23:49:51
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/fe804c54781d/ changeset: fe804c54781d user: alllee date: 2011-08-12 01:49:33 summary: adding additional fields to activity list for the client-side activity store - time_slot, participant_id, and performed_activity_id affected #: 1 file (550 bytes) --- a/vcweb/lighterprints/views.py Thu Aug 11 15:06:07 2011 -0700 +++ b/vcweb/lighterprints/views.py Thu Aug 11 16:49:33 2011 -0700 @@ -43,7 +43,9 @@ # authenticated request, figure out if this activity is available participant_group_id = self.request.GET.get('participant_group_id') participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) - activity_as_dict['availability'] = is_activity_available(activity, participant_group_relationship) + activity_as_dict['available'] = is_activity_available(activity, participant_group_relationship) + activity_as_dict['time_slots'] = ','.join(["%s - %s" % (av.available_start_time, av.available_end_time) for av in activity.availability_set.all()]) + except Exception as e: logger.debug("failed to get authenticated activity list: %s", e) flattened_activities.append(activity_as_dict) @@ -143,8 +145,10 @@ # FIXME: change this to activity name if we decide to use names instead of # pks activity = Activity.objects.get(pk=activity_prdv.value) - performed_activity_dict = to_activity_dict(activity, attrs=('pk', 'name', 'icon_url', 'summary', 'savings')) + performed_activity_dict = to_activity_dict(activity, attrs=('pk', 'display_name', 'name', 'icon_url', 'savings')) performed_activity_dict['date_performed'] = activity_prdv.date_created + performed_activity_dict['participant_id'] = participant_group_relationship.participant_number + performed_activity_dict['performed_activity_id'] = activity_prdv.pk group_activity.append(performed_activity_dict) return dumps({ 'chat_messages': chat_messages, @@ -162,7 +166,10 @@ activity = get_object_or_404(Activity, pk=activity_id) performed_activity = do_activity(activity=activity, participant_group_relationship=participant_group_relationship) if performed_activity is not None: - return HttpResponse(dumps(performed_activity), content_type='text/javascript') + activity_dict = to_activity_dict(activity) + activity_dict['date_created'] = performed_activity.date_created + activity_dict['performed_activity_id'] = performed_activity.pk + return HttpResponse(dumps(activity_dict), content_type='text/javascript') return HttpResponseBadRequest(dumps({'response': "Could not perform activity"}), content_type='text/javascript') @csrf_exempt Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 22:06:20
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/1bd576f15ec5/ changeset: 1bd576f15ec5 user: all...@sod19.asu.edu date: 2011-08-12 00:06:07 summary: fixes to group activity json api, needed to reroll JSONResponseMixin since getting parameters didn't seem to be working affected #: 2 files (789 bytes) --- a/vcweb/lighterprints/urls.py Thu Aug 11 14:41:26 2011 -0700 +++ b/vcweb/lighterprints/urls.py Thu Aug 11 15:06:07 2011 -0700 @@ -1,7 +1,8 @@ from django.conf.urls.defaults import url, patterns from vcweb.lighterprints.views import (ActivityDetailView, ActivityListView, MobileView, - post_chat_message, perform_activity, DiscussionBoardView, login) + post_chat_message, perform_activity, DiscussionBoardView, login, + group_activity) urlpatterns = patterns('vcweb.lighterprints.views', url(r'^mobile$', MobileView.as_view(), name='mobile'), @@ -9,7 +10,7 @@ url(r'^activity/list/?$', ActivityListView.as_view()), url(r'^activity/(?P<activity_id>\d+)$', ActivityDetailView.as_view()), url(r'^discussion/(?P<experiment_id>\d+)/(?P<participant_id>\d+)', DiscussionBoardView.as_view()), - url(r'^api/group-activity', DiscussionBoardView.as_view()), + url(r'^api/group-activity/(?P<participant_group_id>\d+)', group_activity), url(r'^api/do-activity$', perform_activity), url(r'^api/post-chat', post_chat_message), url(r'^api/login', login), --- a/vcweb/lighterprints/views.py Thu Aug 11 14:41:26 2011 -0700 +++ b/vcweb/lighterprints/views.py Thu Aug 11 15:06:07 2011 -0700 @@ -1,6 +1,7 @@ from django.contrib import auth from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import get_object_or_404 +from django.utils.timesince import timesince from django.views.decorators.csrf import csrf_exempt from django.views.generic.detail import BaseDetailView from django.views.generic.edit import FormView @@ -9,6 +10,7 @@ from vcweb.core.forms import LoginForm from vcweb.core.models import (ChatMessage, Experiment, ParticipantGroupRelationship, ParticipantRoundDataValue) from vcweb.core.views import JSONResponseMixin, dumps, set_authentication_token +from vcweb.core.validate_jsonp import is_valid_jsonp_callback_value # FIXME: move ChatForm to core? from vcweb.lighterprints.forms import ActivityForm, ChatForm from vcweb.lighterprints.models import (Activity, is_activity_available, do_activity, get_lighterprints_experiment_metadata, get_activity_performed_parameter) @@ -113,12 +115,24 @@ class DoActivityView(FormView): pass +def group_activity(request, participant_group_id): + participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) + content = get_group_activity_json(participant_group_relationship) + callback = request.GET.get('callback', '') + content_type = 'application/x-json' + if is_valid_jsonp_callback_value(callback): + content = '%s(%s)' % (callback, content) + content_type = 'text/javascript' + return HttpResponse(content, content_type) + return HttpResponseBadRequest(dumps({'response': "Could not perform activity"}), content_type='text/javascript') + + def get_group_activity_json(participant_group_relationship, number_of_activities=5): group = participant_group_relationship.group chat_messages = [] for chat_message in ChatMessage.objects.filter(participant_group_relationship__group=group).order_by('-date_created'): chat_messages.append({ - 'date_created': chat_message.date_created, + 'date_created': timesince(chat_message.date_created), 'message': chat_message.message, 'participant_number': participant_group_relationship.participant_number, 'participant': participant_group_relationship.participant Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 21:41:35
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/28689a98c73a/ changeset: 28689a98c73a user: alllee date: 2011-08-11 23:41:26 summary: setting up api endpoint for group activity affected #: 2 files (113 bytes) --- a/vcweb/lighterprints/urls.py Thu Aug 11 13:28:57 2011 -0700 +++ b/vcweb/lighterprints/urls.py Thu Aug 11 14:41:26 2011 -0700 @@ -9,7 +9,7 @@ url(r'^activity/list/?$', ActivityListView.as_view()), url(r'^activity/(?P<activity_id>\d+)$', ActivityDetailView.as_view()), url(r'^discussion/(?P<experiment_id>\d+)/(?P<participant_id>\d+)', DiscussionBoardView.as_view()), - url(r'^discussion/(?P<experiment_id>\d+)/', DiscussionBoardView.as_view()), + url(r'^api/group-activity', DiscussionBoardView.as_view()), url(r'^api/do-activity$', perform_activity), url(r'^api/post-chat', post_chat_message), url(r'^api/login', login), --- a/vcweb/lighterprints/views.py Thu Aug 11 13:28:57 2011 -0700 +++ b/vcweb/lighterprints/views.py Thu Aug 11 14:41:26 2011 -0700 @@ -79,6 +79,7 @@ context = super(DiscussionBoardView, self).get_context_data(**kwargs) context['group'] = self.group context['participant_group_relationship'] = self.participant_group_relationship + context['group_activity'] = get_group_activity_json(self.participant_group_relationship) return context Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <iss...@bi...> - 2011-08-11 21:21:54
|
--- you can reply above this line --- New issue 29: untaint chat input https://bitbucket.org/virtualcommons/vcweb/issue/29/untaint-chat-input A Lee / alllee on Thu, 11 Aug 2011 23:21:49 +0200: Description: lighter footprint post_chat_message needs to untaint its input Responsible: alllee -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. |
From: Bitbucket <com...@bi...> - 2011-08-11 20:29:06
|
2 new changesets in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/65b97a99bebe/ changeset: 65b97a99bebe user: alllee date: 2011-08-11 22:27:31 summary: fixing post_chat_message implementation and adding test. affected #: 3 files (752 bytes) --- a/vcweb/lighterprints/models.py Thu Aug 11 12:06:56 2011 -0700 +++ b/vcweb/lighterprints/models.py Thu Aug 11 13:27:31 2011 -0700 @@ -173,11 +173,9 @@ logger.debug("total carbon savings: %s", total_savings) return total_savings -def should_advance_level(group, level): - if level < 3: +def should_advance_level(group, level, max_level=3, level_multiplier=10): + if level < max_level: daily_carbon_savings = get_daily_carbon_savings(group) - logger.debug("daily carbon savings were %s, but were they greater than level * 10? %s", daily_carbon_savings, - level * 10) - return daily_carbon_savings > level * 10 + return daily_carbon_savings > (level * level_multiplier) return False --- a/vcweb/lighterprints/tests.py Thu Aug 11 12:06:56 2011 -0700 +++ b/vcweb/lighterprints/tests.py Thu Aug 11 13:27:31 2011 -0700 @@ -45,6 +45,7 @@ class GroupActivityTest(BaseTest): def test_group_activity_json(self): + import simplejson as json e = self.experiment e.activate() e.start_round() @@ -57,10 +58,23 @@ activity_performed.value = activity.id activity_performed.save() group_activity_json = get_group_activity_json(participant_group_relationship) - logger.debug("group activity json: %s", group_activity_json) - import simplejson as json group_activity_dict = json.loads(group_activity_json) - logger.debug("group activity dict: %s", group_activity_dict) + chat_messages = group_activity_dict['chat_messages'] + recent_activity = group_activity_dict['recent_activity'] + self.assertEqual(0, len(chat_messages)) + self.assertEqual(5, len(recent_activity)) + response = self.client.post('/lighterprints/api/post-chat', { + 'participant_group_id': participant_group_relationship.id, + 'message': "Midnight mushrumps", + }) + self.assertEqual(response.status_code, 200) + group_activity_json = get_group_activity_json(participant_group_relationship) + group_activity_dict = json.loads(group_activity_json) + chat_messages = group_activity_dict['chat_messages'] + recent_activity = group_activity_dict['recent_activity'] + self.assertEqual(1, len(chat_messages)) + self.assertEqual(5, len(recent_activity)) + class DoActivityTest(BaseTest): @@ -79,10 +93,8 @@ 'participant_group_id': participant_group_relationship.id, 'activity_id': activity.id }) - logger.debug("response %s", response) self.assertEqual(response.status_code, 200) # try to do the same activity again - logger.debug("XXX: all activity performed parameters: %s", ParticipantRoundDataValue.objects.filter(parameter=get_activity_performed_parameter())) response = self.client.post('/lighterprints/api/do-activity', { 'participant_group_id': participant_group_relationship.id, 'activity_id': activity.pk --- a/vcweb/lighterprints/views.py Thu Aug 11 12:06:56 2011 -0700 +++ b/vcweb/lighterprints/views.py Thu Aug 11 13:27:31 2011 -0700 @@ -142,8 +142,8 @@ form = ActivityForm(request.POST or None) if form.is_valid(): activity_id = form.cleaned_data['activity_id'] - participant_group_pk = form.cleaned_data['participant_group_id'] - participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_pk) + participant_group_id = form.cleaned_data['participant_group_id'] + participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) activity = get_object_or_404(Activity, pk=activity_id) performed_activity = do_activity(activity=activity, participant_group_relationship=participant_group_relationship) if performed_activity is not None: @@ -154,16 +154,13 @@ def post_chat_message(request): form = ChatForm(request.POST or None) if form.is_valid(): - participant_group_pk = form.cleaned_data['participant_group_id'] + participant_group_id = form.cleaned_data['participant_group_id'] message = form.cleaned_data['message'] - participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_pk) - group = participant_group_relationship.group - chat_message = ChatMessage.objects.create(participant_group_relationship=participant_group_relationship, - message=message, round_data=group.current_round_data) - logger.debug("Participant %s created chat message %s", request.user.participant, chat_message) - # FIXME: add recent Activity performed data as well as all ChatMessages - # sent, ordered by date. - content = dumps(ChatMessage.objects.filter(participant_group_relationship__group=group)) + participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) + chat_message = participant_group_relationship.participant_chat_message_set.create(message=message, + round_data=participant_group_relationship.current_round_data) + logger.debug("Participant %s created chat message %s", participant_group_relationship.participant, chat_message) + content = get_group_activity_json(participant_group_relationship) return HttpResponse(content, content_type='text/javascript') return HttpResponseBadRequest(dumps({'response': "Invalid chat message post"})) http://bitbucket.org/virtualcommons/vcweb/changeset/db58034b0ed2/ changeset: db58034b0ed2 user: alllee date: 2011-08-11 22:28:57 summary: updated test affected #: 1 file (104 bytes) --- a/vcweb/lighterprints/tests.py Thu Aug 11 13:27:31 2011 -0700 +++ b/vcweb/lighterprints/tests.py Thu Aug 11 13:28:57 2011 -0700 @@ -63,9 +63,10 @@ recent_activity = group_activity_dict['recent_activity'] self.assertEqual(0, len(chat_messages)) self.assertEqual(5, len(recent_activity)) + test_message = "Midnight mushrumps" response = self.client.post('/lighterprints/api/post-chat', { 'participant_group_id': participant_group_relationship.id, - 'message': "Midnight mushrumps", + 'message': test_message, }) self.assertEqual(response.status_code, 200) group_activity_json = get_group_activity_json(participant_group_relationship) @@ -73,6 +74,7 @@ chat_messages = group_activity_dict['chat_messages'] recent_activity = group_activity_dict['recent_activity'] self.assertEqual(1, len(chat_messages)) + self.assertEqual(chat_messages[0]['message'], test_message) self.assertEqual(5, len(recent_activity)) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 19:07:05
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/96e3a0cdb9af/ changeset: 96e3a0cdb9af user: alllee date: 2011-08-11 21:06:56 summary: implementing group discussion board and added test, still need to add coverage for chat messages affected #: 3 files (3.2 KB) --- a/vcweb/core/models.py Wed Aug 10 17:33:08 2011 -0700 +++ b/vcweb/core/models.py Thu Aug 11 12:06:56 2011 -0700 @@ -1184,6 +1184,7 @@ Many-to-many relationship entity storing a participant, group, their participant number in that group, the round in which they joined the group, and the datetime that they joined the group. """ +# FIXME: should also add a participant_identifier field here in case we want to use something other than numbers..? participant_number = models.PositiveIntegerField() participant = models.ForeignKey(Participant, related_name='participant_group_relationship_set') group = models.ForeignKey(Group, related_name = 'participant_group_relationship_set') --- a/vcweb/lighterprints/tests.py Wed Aug 10 17:33:08 2011 -0700 +++ b/vcweb/lighterprints/tests.py Thu Aug 11 12:06:56 2011 -0700 @@ -37,17 +37,36 @@ activity_performed = participant_group_relationship.participant_data_value_set.create(round_data=current_round_data, parameter=activity_performed_parameter, experiment=e) activity_performed.value = activity.id activity_performed.save() + # FIXME: sender parameter doesn't really matter here, just pass self in as the sender update_active_experiments(self) for group in e.group_set.all(): self.assertEqual(get_carbon_footprint_level(group).value, 2) - self.assertEqual(get_daily_carbon_savings(group), Decimal('58.20')) + self.assertEqual(get_daily_carbon_savings(group), Decimal('55.70')) + +class GroupActivityTest(BaseTest): + def test_group_activity_json(self): + e = self.experiment + e.activate() + e.start_round() + participant_group_relationship = ParticipantGroupRelationship.objects.filter(group__experiment=e)[0] + # do every activity in level 1 for this particular participant + activity_performed_parameter = get_activity_performed_parameter() + current_round_data = e.current_round_data + for activity in Activity.objects.filter(level=1): + activity_performed = participant_group_relationship.participant_data_value_set.create(submitted=True, round_data=current_round_data, parameter=activity_performed_parameter, experiment=e) + activity_performed.value = activity.id + activity_performed.save() + group_activity_json = get_group_activity_json(participant_group_relationship) + logger.debug("group activity json: %s", group_activity_json) + import simplejson as json + group_activity_dict = json.loads(group_activity_json) + logger.debug("group activity dict: %s", group_activity_dict) class DoActivityTest(BaseTest): def test_view(self): logger.debug("testing do activity view") e = self.experiment - create_activity_performed_parameter() e.activate() e.start_round() for participant_group_relationship in ParticipantGroupRelationship.objects.filter(group__experiment=e): @@ -57,7 +76,7 @@ activity = activity_availability.activity logger.debug("participant %s performing activity %s", participant_group_relationship.participant, activity) response = self.client.post('/lighterprints/api/do-activity', { - 'participant_group_relationship_id': participant_group_relationship.id, + 'participant_group_id': participant_group_relationship.id, 'activity_id': activity.id }) logger.debug("response %s", response) @@ -65,7 +84,7 @@ # try to do the same activity again logger.debug("XXX: all activity performed parameters: %s", ParticipantRoundDataValue.objects.filter(parameter=get_activity_performed_parameter())) response = self.client.post('/lighterprints/api/do-activity', { - 'participant_group_relationship_id': participant_group_relationship.id, + 'participant_group_id': participant_group_relationship.id, 'activity_id': activity.pk }) self.assertEqual(response.status_code, 400) --- a/vcweb/lighterprints/views.py Wed Aug 10 17:33:08 2011 -0700 +++ b/vcweb/lighterprints/views.py Thu Aug 11 12:06:56 2011 -0700 @@ -7,16 +7,22 @@ from django.views.generic.list import BaseListView, MultipleObjectTemplateResponseMixin from vcweb.core.forms import LoginForm -from vcweb.core.models import (ChatMessage, Experiment, ParticipantGroupRelationship) +from vcweb.core.models import (ChatMessage, Experiment, ParticipantGroupRelationship, ParticipantRoundDataValue) from vcweb.core.views import JSONResponseMixin, dumps, set_authentication_token # FIXME: move ChatForm to core? from vcweb.lighterprints.forms import ActivityForm, ChatForm -from vcweb.lighterprints.models import (Activity, is_activity_available, do_activity, get_lighterprints_experiment_metadata) +from vcweb.lighterprints.models import (Activity, is_activity_available, do_activity, get_lighterprints_experiment_metadata, get_activity_performed_parameter) import collections import logging logger = logging.getLogger(__name__) +def to_activity_dict(activity, attrs=('pk', 'name', 'summary', 'display_name', 'description', 'savings', 'url', 'available_all_day', 'level', 'group_activity', 'icon_url', 'time_remaining')): + activity_as_dict = {} + for attr_name in attrs: + activity_as_dict[attr_name] = getattr(activity, attr_name, None) + return activity_as_dict + class ActivityListView(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): model = Activity @@ -29,9 +35,7 @@ for activity in all_activities: activity_by_level[activity.level].append(activity) #activity_as_dict = collections.OrderedDict() - activity_as_dict = {} - for attr_name in ('pk', 'name', 'summary', 'display_name', 'description', 'savings', 'url', 'available_all_day', 'level', 'group_activity', 'icon_url', 'time_remaining'): - activity_as_dict[attr_name] = getattr(activity, attr_name, None) + activity_as_dict = to_activity_dict(activity) try: if self.request.user.is_authenticated(): # authenticated request, figure out if this activity is available @@ -52,6 +56,32 @@ else: return MultipleObjectTemplateResponseMixin.render_to_response(self, context) +class DiscussionBoardView(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): + model = ChatMessage + template_name = 'discussion_board.html' + def get_queryset(self): + # FIXME: stubbed out for now, passing in the participant id for the time + # being + # participant = self.request.user.participant + participant_group_id = self.kwargs['participant_group_id'] +# FIXME: will change once we have proper auth set up + self.participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) + self.group = self.participant_group_relationship.group + return ChatMessage.objects.filter(participant_group_relationship__group = self.group) + + def render_to_response(self, context, **response_kwargs): + if self.request.GET.get('format', 'html') == 'json': + return JSONResponseMixin.render_to_response(self, context, context_key='group_activity') + else: + return MultipleObjectTemplateResponseMixin.render_to_response(self, context) + + def get_context_data(self, **kwargs): + context = super(DiscussionBoardView, self).get_context_data(**kwargs) + context['group'] = self.group + context['participant_group_relationship'] = self.participant_group_relationship + return context + + class ActivityDetailView(JSONResponseMixin, BaseDetailView): template_name = 'lighterprints/activity_detail.html' @@ -82,6 +112,30 @@ class DoActivityView(FormView): pass +def get_group_activity_json(participant_group_relationship, number_of_activities=5): + group = participant_group_relationship.group + chat_messages = [] + for chat_message in ChatMessage.objects.filter(participant_group_relationship__group=group).order_by('-date_created'): + chat_messages.append({ + 'date_created': chat_message.date_created, + 'message': chat_message.message, + 'participant_number': participant_group_relationship.participant_number, + 'participant': participant_group_relationship.participant + }) + group_activity = [] + performed_activities = ParticipantRoundDataValue.objects.filter(participant_group_relationship__group=group, submitted=True, parameter=get_activity_performed_parameter()).order_by('-date_created') + for activity_prdv in performed_activities[:number_of_activities]: + # FIXME: change this to activity name if we decide to use names instead of + # pks + activity = Activity.objects.get(pk=activity_prdv.value) + performed_activity_dict = to_activity_dict(activity, attrs=('pk', 'name', 'icon_url', 'summary', 'savings')) + performed_activity_dict['date_performed'] = activity_prdv.date_created + group_activity.append(performed_activity_dict) + return dumps({ + 'chat_messages': chat_messages, + 'recent_activity': group_activity + }) + @csrf_exempt def perform_activity(request): logger.debug("performing activity") @@ -107,29 +161,12 @@ chat_message = ChatMessage.objects.create(participant_group_relationship=participant_group_relationship, message=message, round_data=group.current_round_data) logger.debug("Participant %s created chat message %s", request.user.participant, chat_message) + # FIXME: add recent Activity performed data as well as all ChatMessages + # sent, ordered by date. content = dumps(ChatMessage.objects.filter(participant_group_relationship__group=group)) return HttpResponse(content, content_type='text/javascript') return HttpResponseBadRequest(dumps({'response': "Invalid chat message post"})) -class DiscussionBoardView(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): - model = ChatMessage - template_name = 'discussion_board.html' - def get_queryset(self): - # FIXME: stubbed out for now, passing in the participant id for the time - # being - # participant = self.request.user.participant - participant_group_id = self.kwargs['participant_group_id'] -# FIXME: will change once we have proper auth set up - self.participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) - self.group = self.participant_group_relationship.group - return ChatMessage.objects.filter(participant_group_relationship__group = self.group) - - def get_context_data(self, **kwargs): - context = super(DiscussionBoardView, self).get_context_data(**kwargs) - context['group'] = self.group - context['participant_group_relationship'] = self.participant_group_relationship - return context - @csrf_exempt def login(request): form = LoginForm(request.POST or None) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 00:33:16
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/9879f38695ac/ changeset: 9879f38695ac user: alllee date: 2011-08-11 02:33:08 summary: updated admin models affected #: 1 file (307 bytes) --- a/vcweb/core/admin.py Wed Aug 10 17:24:11 2011 -0700 +++ b/vcweb/core/admin.py Wed Aug 10 17:33:08 2011 -0700 @@ -1,25 +1,21 @@ ''' -registering django models with django admin +Registers django models with the django admin app. ''' from django.contrib import admin from django.contrib.auth.models import Permission -from vcweb.core.models import Parameter, RoundParameterValue, \ - ExperimentConfiguration, RoundConfiguration, \ - Experimenter, Participant, Group, Experiment, ParticipantExperimentRelationship, \ - ParticipantGroupRelationship, GroupRoundDataValue, GroupActivityLog +from vcweb.core.models import * -admin.site.register(Parameter) -admin.site.register(RoundParameterValue) -admin.site.register(ExperimentConfiguration) -admin.site.register(RoundConfiguration) -admin.site.register(Experimenter) -admin.site.register(Participant) -admin.site.register(Group) -admin.site.register(Experiment) -admin.site.register(ParticipantExperimentRelationship) -admin.site.register(ParticipantGroupRelationship) +models = ( + Parameter, RoundParameterValue, ExperimentConfiguration, RoundConfiguration, + Experimenter, Participant, Group, Experiment, + ParticipantExperimentRelationship, ParticipantGroupRelationship, + GroupRoundDataValue, ParticipantRoundDataValue, GroupActivityLog, + ChatMessage, QuizQuestion + ) + +for model in models: + admin.site.register(model) + admin.site.register(Permission) -admin.site.register(GroupRoundDataValue) -admin.site.register(GroupActivityLog) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 00:24:20
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/538ab23220c0/ changeset: 538ab23220c0 user: alllee date: 2011-08-11 02:24:11 summary: updating forms to use shorter participant_group_id affected #: 1 file (26 bytes) --- a/vcweb/lighterprints/forms.py Wed Aug 10 17:00:58 2011 -0700 +++ b/vcweb/lighterprints/forms.py Wed Aug 10 17:24:11 2011 -0700 @@ -3,9 +3,9 @@ class ChatForm(forms.Form): message = forms.CharField(required=True, max_length=512) - participant_group_relationship_id = forms.IntegerField(required=True, widget=forms.HiddenInput) + participant_group_id = forms.IntegerField(required=True, widget=forms.HiddenInput) class ActivityForm(forms.Form): activity_id = forms.IntegerField(required=True, widget=forms.HiddenInput) - participant_group_relationship_id = forms.IntegerField(required=True, widget=forms.HiddenInput) + participant_group_id = forms.IntegerField(required=True, widget=forms.HiddenInput) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-11 00:01:11
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/618a1de6c3f5/ changeset: 618a1de6c3f5 user: alllee date: 2011-08-11 02:00:58 summary: fixing issues with post_chat_message view affected #: 1 file (66 bytes) --- a/vcweb/lighterprints/views.py Wed Aug 10 14:31:03 2011 -0700 +++ b/vcweb/lighterprints/views.py Wed Aug 10 17:00:58 2011 -0700 @@ -94,21 +94,20 @@ performed_activity = do_activity(activity=activity, participant_group_relationship=participant_group_relationship) if performed_activity is not None: return HttpResponse(dumps(performed_activity), content_type='text/javascript') - return HttpResponseBadRequest("Could not perform activity") - + return HttpResponseBadRequest(dumps({'response': "Could not perform activity"}), content_type='text/javascript') @csrf_exempt -def post_chat_message(request, experiment_id): - experiment = get_object_or_404(Experiment, pk=experiment_id) +def post_chat_message(request): form = ChatForm(request.POST or None) if form.is_valid(): participant_group_pk = form.cleaned_data['participant_group_id'] message = form.cleaned_data['message'] participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_pk) + group = participant_group_relationship.group chat_message = ChatMessage.objects.create(participant_group_relationship=participant_group_relationship, - message=message, round_data=experiment.current_round_data) + message=message, round_data=group.current_round_data) logger.debug("Participant %s created chat message %s", request.user.participant, chat_message) - content = dumps(ChatMessage.objects.filter(participant_group_relationship__group=participant_group_relationship.group)) + content = dumps(ChatMessage.objects.filter(participant_group_relationship__group=group)) return HttpResponse(content, content_type='text/javascript') return HttpResponseBadRequest(dumps({'response': "Invalid chat message post"})) @@ -131,6 +130,7 @@ context['participant_group_relationship'] = self.participant_group_relationship return context +@csrf_exempt def login(request): form = LoginForm(request.POST or None) try: @@ -146,6 +146,8 @@ active_experiment = active_experiments[0] participant_group_relationship = participant.get_participant_group_relationship(active_experiment) return HttpResponse(dumps({'participant_group_id': participant_group_relationship.id}), content_type='text/javascript') + else: + logger.debug("invalid form %s", form) except Exception as e: logger.debug("Invalid login: %s", e) return HttpResponseBadRequest(dumps({"response": "Invalid login"}), content_type='text/javascript') Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-10 21:31:14
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/41d7c8fba3cf/ changeset: 41d7c8fba3cf user: alllee date: 2011-08-10 23:31:03 summary: returning HttpResponseBadRequest for invalid login affected #: 1 file (115 bytes) --- a/vcweb/lighterprints/views.py Wed Aug 10 14:25:03 2011 -0700 +++ b/vcweb/lighterprints/views.py Wed Aug 10 14:31:03 2011 -0700 @@ -110,7 +110,7 @@ logger.debug("Participant %s created chat message %s", request.user.participant, chat_message) content = dumps(ChatMessage.objects.filter(participant_group_relationship__group=participant_group_relationship.group)) return HttpResponse(content, content_type='text/javascript') - return HttpResponseBadRequest("Invalid chat message post") + return HttpResponseBadRequest(dumps({'response': "Invalid chat message post"})) class DiscussionBoardView(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): model = ChatMessage @@ -136,6 +136,7 @@ try: if form.is_valid(): user = form.user_cache + logger.debug("user was authenticated as %s, attempting to login", user) auth.login(request, user) set_authentication_token(user, request.session.session_key) participant = user.participant @@ -147,4 +148,4 @@ return HttpResponse(dumps({'participant_group_id': participant_group_relationship.id}), content_type='text/javascript') except Exception as e: logger.debug("Invalid login: %s", e) - return HttpResponse(dumps({"response": "Invalid login"}), content_type='text/javascript') + return HttpResponseBadRequest(dumps({"response": "Invalid login"}), content_type='text/javascript') Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-10 21:25:16
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/f33dce7927e8/ changeset: f33dce7927e8 user: alllee date: 2011-08-10 23:25:03 summary: adding lighterprints api login that returns json with participant group id on successful auth. affected #: 2 files (1.0 KB) --- a/vcweb/lighterprints/urls.py Tue Aug 09 17:15:04 2011 -0700 +++ b/vcweb/lighterprints/urls.py Wed Aug 10 14:25:03 2011 -0700 @@ -1,7 +1,7 @@ from django.conf.urls.defaults import url, patterns from vcweb.lighterprints.views import (ActivityDetailView, ActivityListView, MobileView, - post_chat_message, perform_activity, DiscussionBoardView) + post_chat_message, perform_activity, DiscussionBoardView, login) urlpatterns = patterns('vcweb.lighterprints.views', url(r'^mobile$', MobileView.as_view(), name='mobile'), @@ -12,4 +12,5 @@ url(r'^discussion/(?P<experiment_id>\d+)/', DiscussionBoardView.as_view()), url(r'^api/do-activity$', perform_activity), url(r'^api/post-chat', post_chat_message), + url(r'^api/login', login), ) --- a/vcweb/lighterprints/views.py Tue Aug 09 17:15:04 2011 -0700 +++ b/vcweb/lighterprints/views.py Wed Aug 10 14:25:03 2011 -0700 @@ -1,3 +1,4 @@ +from django.contrib import auth from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import get_object_or_404 from django.views.decorators.csrf import csrf_exempt @@ -5,11 +6,12 @@ from django.views.generic.edit import FormView from django.views.generic.list import BaseListView, MultipleObjectTemplateResponseMixin +from vcweb.core.forms import LoginForm from vcweb.core.models import (ChatMessage, Experiment, ParticipantGroupRelationship) -from vcweb.core.views import JSONResponseMixin, dumps -# FIXME: move to core? +from vcweb.core.views import JSONResponseMixin, dumps, set_authentication_token +# FIXME: move ChatForm to core? from vcweb.lighterprints.forms import ActivityForm, ChatForm -from vcweb.lighterprints.models import Activity, is_activity_available, do_activity +from vcweb.lighterprints.models import (Activity, is_activity_available, do_activity, get_lighterprints_experiment_metadata) import collections import logging @@ -33,8 +35,8 @@ try: if self.request.user.is_authenticated(): # authenticated request, figure out if this activity is available - participant_group_relationship_id = self.request.GET.get('participant_group_relationship_id') - participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_relationship_id) + participant_group_id = self.request.GET.get('participant_group_id') + participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) activity_as_dict['availability'] = is_activity_available(activity, participant_group_relationship) except Exception as e: logger.debug("failed to get authenticated activity list: %s", e) @@ -53,6 +55,11 @@ class ActivityDetailView(JSONResponseMixin, BaseDetailView): template_name = 'lighterprints/activity_detail.html' +def get_available_activities(request): + # FIXME: currently stubbed out to return all activities. should move this to + # models.py and have it take a Participant? + return zip(Activity.objects.all(), MobileView.jqm_grid_columns) + class MobileView(ActivityListView): jqm_grid_columns = tuple("abcde") @@ -81,7 +88,7 @@ form = ActivityForm(request.POST or None) if form.is_valid(): activity_id = form.cleaned_data['activity_id'] - participant_group_pk = form.cleaned_data['participant_group_relationship_id'] + participant_group_pk = form.cleaned_data['participant_group_id'] participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_pk) activity = get_object_or_404(Activity, pk=activity_id) performed_activity = do_activity(activity=activity, participant_group_relationship=participant_group_relationship) @@ -95,7 +102,7 @@ experiment = get_object_or_404(Experiment, pk=experiment_id) form = ChatForm(request.POST or None) if form.is_valid(): - participant_group_pk = form.cleaned_data['participant_group_relationship_id'] + participant_group_pk = form.cleaned_data['participant_group_id'] message = form.cleaned_data['message'] participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_pk) chat_message = ChatMessage.objects.create(participant_group_relationship=participant_group_relationship, @@ -112,10 +119,9 @@ # FIXME: stubbed out for now, passing in the participant id for the time # being # participant = self.request.user.participant - participant_id = self.kwargs['participant_id'] - experiment_id = self.kwargs['experiment_id'] + participant_group_id = self.kwargs['participant_group_id'] # FIXME: will change once we have proper auth set up - self.participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, participant__pk=participant_id, group__experiment__pk=experiment_id) + self.participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_id) self.group = self.participant_group_relationship.group return ChatMessage.objects.filter(participant_group_relationship__group = self.group) @@ -125,9 +131,20 @@ context['participant_group_relationship'] = self.participant_group_relationship return context -def get_available_activities(request): - # FIXME: currently stubbed out to return all activities. should move this to - # models.py and have it take a Participant? - return zip(Activity.objects.all(), MobileView.jqm_grid_columns) - - +def login(request): + form = LoginForm(request.POST or None) + try: + if form.is_valid(): + user = form.user_cache + auth.login(request, user) + set_authentication_token(user, request.session.session_key) + participant = user.participant + active_experiments = participant.experiments.filter(status__in=('ACTIVE', 'ROUND_IN_PROGRESS'), experiment_metadata=get_lighterprints_experiment_metadata()) + # FIXME: assuming participant is only participating in one active experiment + # at a time.. + active_experiment = active_experiments[0] + participant_group_relationship = participant.get_participant_group_relationship(active_experiment) + return HttpResponse(dumps({'participant_group_id': participant_group_relationship.id}), content_type='text/javascript') + except Exception as e: + logger.debug("Invalid login: %s", e) + return HttpResponse(dumps({"response": "Invalid login"}), content_type='text/javascript') Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-10 00:55:15
|
2 new changesets in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/8843127f07ea/ changeset: 8843127f07ea user: alllee date: 2011-08-10 00:42:29 summary: fixing activity list w/ authentication (hopefully) affected #: 1 file (166 bytes) --- a/vcweb/lighterprints/views.py Tue Aug 09 14:50:02 2011 -0700 +++ b/vcweb/lighterprints/views.py Tue Aug 09 15:42:29 2011 -0700 @@ -30,12 +30,14 @@ activity_as_dict = {} for attr_name in ('pk', 'name', 'summary', 'display_name', 'description', 'savings', 'url', 'available_all_day', 'level', 'group_activity', 'icon_url', 'time_remaining'): activity_as_dict[attr_name] = getattr(activity, attr_name, None) - if self.request.user.is_authenticated(): - # authenticated request, figure out if this activity is available - experiment_id = self.request.GET.get('experiment_id') - participant = self.request.user.participant - experiment = get_object_or_404(Experiment, pk=experiment_id) - activity_as_dict['availability'] = is_activity_available(participant=participant, experiment=experiment, activity=activity) + try: + if self.request.user.is_authenticated(): + # authenticated request, figure out if this activity is available + participant_group_relationship_id = self.request.GET.get('participant_group_relationship_id') + participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, pk=participant_group_relationship_id) + activity_as_dict['availability'] = is_activity_available(activity, participant_group_relationship) + except Exception as e: + logger.debug("failed to get authenticated activity list: %s", e) flattened_activities.append(activity_as_dict) context['activity_by_level'] = dict(activity_by_level) http://bitbucket.org/virtualcommons/vcweb/changeset/d9486415c937/ changeset: d9486415c937 user: alllee date: 2011-08-10 02:15:04 summary: re-enabling start round on experimenter monitor page affected #: 1 file (296 bytes) --- a/vcweb/core/templates/experimenter/monitor.html Tue Aug 09 15:42:29 2011 -0700 +++ b/vcweb/core/templates/experimenter/monitor.html Tue Aug 09 17:15:04 2011 -0700 @@ -158,13 +158,8 @@ <li><a class='confirm-experiment-action' name='end_round' href='end-round' title='Stops the current round.'><span class='vcweb-icon icon-left ui-icon' style='background: url({{STATIC_URL}}images/famfamfam/control_stop_blue.png);' ></span>end round</a></li> {% else %} - {% comment %} - FIXME: disabling for the time being, I have a suspicion Veronika - might be clicking it accidentally and redoing rounds (thus - applying group harvest + regrowth twice) <li><a class='confirm-experiment-action' name='start_round' href='start-round' title='Starts the round.'><span class='ui-icon vcweb-icon icon-left' style='background:url({{STATIC_URL}}images/famfamfam/control_play_blue.png);' ></span>start round</a></li> - {% endcomment %} {% endif %} <li><a class='confirm-experiment-action' name='advance_to_next_round' href='advance-to-next-round' title='Stops the current round if necessary and advances to the next round.'><span class='vcweb-icon ui-icon icon-left' style='background:url({{STATIC_URL}}images/famfamfam/control_fastforward_blue.png);' ></span>advance to next round</a></li> Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |
From: Bitbucket <com...@bi...> - 2011-08-09 23:39:12
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/a90b943948a3/ changeset: a90b943948a3 user: alllee date: 2011-08-09 23:50:02 summary: updated activity descriptions and icons from Steven affected #: 1 file (437 bytes) --- a/vcweb/lighterprints/fixtures/initial_data.json Tue Aug 09 11:03:28 2011 -0700 +++ b/vcweb/lighterprints/fixtures/initial_data.json Tue Aug 09 14:50:02 2011 -0700 @@ -74,7 +74,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Adjust your thermostat by 2 degrees", - "description": "Climate-controlled buildings costs a lot of energy. Adjusting the temperature with two degrees saved 2000 pound of CO2 a year.", + "description": "Climate-controlled buildings cost a lot of energy. Adjusting the temperature by two degrees saves 2,000 pounds of CO2 a year.", "available_all_day": false, "url": "http://www.savecarbon.org/activity_form/twodegrees", "level": 1, @@ -82,7 +82,7 @@ "summary": "Heating or cooling buildings less saves energy", "savings": "5.50", "cooldown": 1, - "icon": "", + "icon": "lighterprints/activity-icons/93-thermometer.png", "name": "adjust-thermostat" } }, @@ -91,15 +91,15 @@ "model": "lighterprints.activity", "fields": { "display_name": "Eat locally grown food for lunch", - "description": "The food we eat comes from all over the world. How much CO2 emissions this generates depends on your specific location and menu. On average a person in the USA can save 1400 pounds of CO2 per year by switching to locally grown food. We assume that one lunch is equivalent of 1.5 pounds of CO2 saved.", + "description": "The food we eat comes from all over the world. How much CO2 this emits depends on your specific location and menu. On average, a person in the USA can save 1,400 pounds of CO2 per year by switching to locally grown food. We assume that one lunch is equivalent of 1.5 pounds of CO2 saved.", "available_all_day": true, "url": "http://www.huffingtonpost.com/bill-chameides/carbon-savings-at-home_b_113551.html", "level": 1, "group_activity": false, - "summary": "Less energy for transport when only locally grown food is consumed", - "savings": "2.00", + "summary": "Less energy is used for transportation when only locally grown food is consumed", + "savings": "1.50", "cooldown": 1, - "icon": "", + "icon": "lighterprints/activity-icons/80-shopping-cart.png", "name": "eat-local-lunch" } }, @@ -108,7 +108,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Enable sleep function on your computer", - "description": "Annual energy savings from enabling sleep feature on computer and monitor = 235 kWh\r\nSavings assumes you have an ENERGY STAR computer. It assumes a weighted average of consumer behavior rather than assuming computers are turned off all night. ", + "description": "Annual energy savings from enabling the sleep feature on a computer and monitor = 235 kWh.\r\nSavings assumes a weighted average of consumer behavior rather than assuming computers are turned off all night, as well as that the computer and monitor are ENERGY STAR rated. ", "available_all_day": true, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 1, @@ -116,7 +116,7 @@ "summary": "Your computer consumes less energy when it's asleep or turned off", "savings": "0.98", "cooldown": 1, - "icon": "lighterprints/activity-icons/compsleep.bmp", + "icon": "lighterprints/activity-icons/69-display.png", "name": "enable-computer-sleep" } }, @@ -125,7 +125,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Recycle materials", - "description": "Average number of pounds of CO2 equivalent per person per year that could be saved by recycling glass (6.83), plastic (18.96) and aluminum and steel cans (86.05). This is 2.15 a week.", + "description": "The average number of pounds of CO2 equivalent per person per year that could be saved by recycling is 6.83 pounds for glass, 18.96 pounds for plastic, and 86.05 pounds for aluminum and steel cans. This is an average of 2.15 pounds a week, or .31 pounds a day.", "available_all_day": true, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 1, @@ -133,7 +133,7 @@ "summary": "Recycling processes used materials into new products to prevent waste of potentially useful materials.", "savings": "0.31", "cooldown": 1, - "icon": "lighterprints/activity-icons/recycle-2-icon.png", + "icon": "lighterprints/activity-icons/142-wine-bottle.png", "name": "recycle" } }, @@ -142,15 +142,15 @@ "model": "lighterprints.activity", "fields": { "display_name": "Share your ride", - "description": "We assume a 22.4 miles per gallon car. CO2 emissions are 19.53 pounds per gallon and 1.5 pound per gallon of non-CO2 CO2 equivalent emissions. This means 0.94 pounds per mile. We assume a trip length of 5 miles.\r\n\r\nIf there are N carpoolers, the savings are (N-1) / N* 4.7. Hence for N=2 persons, the savings is 2.85. More carpoolers lead to more reductions.", + "description": "We assume a car averaging 22.4 miles per gallon. CO2 emissions are 19.53 pounds per gallon and 1.5 pounds per gallon of non-CO2 CO2 equivalent emissions. This means 0.94 pounds per mile. We assume a trip length of 5 miles.\r\n\r\nIf there are N carpoolers, the savings are (N-1) / N* 4.7. Hence for N=2 persons, the savings are 2.85 pounds. More carpoolers lead to more reductions.", "available_all_day": false, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 1, "group_activity": false, - "summary": "Using mass transit, bicycle commuting, or carpooling is more efficient than traveling alone in your car.", + "summary": "Carpooling is more energy efficient than travelling alone in your car.", "savings": "2.85", "cooldown": 1, - "icon": "", + "icon": "lighterprints/activity-icons/car.png", "name": "share-your-ride" } }, @@ -159,15 +159,15 @@ "model": "lighterprints.activity", "fields": { "display_name": "Bike or take public transportation when you go out", - "description": "We assume a 22.4 miles per gallon car and a 4 mile trip length. CO2 emissions are 19.53 pounds per gallon and 1.5 pound per gallon of non-CO2 CO2 equivalent emissions. This means 0.94 pounds per mile. ", + "description": "We assume a car averaging 22.4 miles per gallon and a trip length of 4 miles. CO2 emissions are 19.53 pounds per gallon and 1.5 pounds per gallon of non-CO2 CO2 equivalent emissions. This means 0.94 pounds per mile. ", "available_all_day": false, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 2, "group_activity": false, "summary": "Reduce fossil fuel consumption and emissions by not driving a car", - "savings": "7.52", + "savings": "9.40", "cooldown": 1, - "icon": "lighterprints/activity-icons/biketo.bmp", + "icon": "lighterprints/activity-icons/102-walk.png", "name": "bike-public-transport" } }, @@ -176,7 +176,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Turn water off while brushing your teeth", - "description": "0.5 kWh per person per day, assuming four minutes a day (enough to account for brushing teeth twice daily) and typical energy use for water supply, treatment, and heating. With 1.52 CO2 per kWh this leads to a savings of 0.76 pound of CO2 a day.", + "description": "Turning off the water while brushing saves 0.5 kWh per person per day. This assumes four minutes a day spent brushing (enough to account for brushing teeth twice daily) and typical energy use for water supply, treatment, and heating. With 1.52 CO2 per kWh this leads to a savings of 0.76 pounds of CO2 a day.", "available_all_day": false, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 2, @@ -184,7 +184,7 @@ "summary": "Don't leave the water running while you're brushing your teeth", "savings": "0.76", "cooldown": 1, - "icon": "lighterprints/activity-icons/toothbrush.bmp", + "icon": "lighterprints/activity-icons/186-toothbrush.png", "name": "brushing-your-teeth" } }, @@ -193,7 +193,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Turn off your computer at night", - "description": "The average computer uses about 120 Watts (75 Watts for the screen and 45 Watts for the CPU) whether you're using it or not.\r\nOne computer left on 24 hours a day will lead to cost 1,500 pounds of CO2 into the atmosphere.", + "description": "The average computer uses about 120 Watts (75 Watts for the screen and 45 Watts for the CPU) whether you're using it or not.\r\nOne computer left on 24 hours a day will cause 1,500 pounds of CO2 to be emitted into the atmosphere.", "available_all_day": false, "url": "http://sustainability.tufts.edu/", "level": 2, @@ -201,7 +201,7 @@ "summary": "Save energy and turn off your computer when it's not needed.", "savings": "1.37", "cooldown": 1, - "icon": "lighterprints/activity-icons/compsleep_1.bmp", + "icon": "lighterprints/activity-icons/screen_sleep_glossy.png", "name": "computer-off" } }, @@ -210,7 +210,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Replace beef with poultry", - "description": "Replacing the protein you get from beef with poultry can save you 1,555 pounds of CO2 emissions annually. Per day this switch leads to a 4.26 pounds of CO2 savings.", + "description": "Replacing the protein you get from beef with poultry can save you 1,555 pounds of CO2 emissions annually. Per day, this switch leads to 4.26 pounds of CO2 savings.", "available_all_day": false, "url": "http://www.simplesteps.org/food/shopping-wise/co2-smackdown-step-6-trimming-out-beef-and-pork", "level": 2, @@ -218,7 +218,7 @@ "summary": "Beef production is very energy intensive", "savings": "4.26", "cooldown": 1, - "icon": "lighterprints/activity-icons/nobeef.bmp", + "icon": "lighterprints/activity-icons/109-chicken.png", "name": "no-beef" } }, @@ -227,7 +227,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Recycle paper", - "description": "Average number of pounds of CO2 equivalent per person per year that could be saved by recycling magazines (14.86), newspaper (89.76) and junk mail (100). This is 0.56 pound per day.", + "description": "The average number of pounds of CO2 equivalent per person per year that could be saved by recycling paper is 14.86 pounds for magazines, 89.76 pounds for newspapers, and 100 pounds for junk mail. These add up to 0.56 pounds per day.", "available_all_day": false, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 2, @@ -235,7 +235,7 @@ "summary": "Saving paper resources and production by recycling", "savings": "0.56", "cooldown": 1, - "icon": "lighterprints/activity-icons/recycle.bmp", + "icon": "lighterprints/activity-icons/166-newspaper.png", "name": "recycle-paper" } }, @@ -244,7 +244,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Air dry your clothes", - "description": "Drying your clothes saves 723 pounds of CO2 every year. This is 1.98 pounds per day.", + "description": "Air drying your clothes saves 723 pounds of CO2 every year, or 1.98 pounds per day.", "available_all_day": false, "url": "http://www.simplesteps.org/tools/house-savings-calculator#laundry", "level": 3, @@ -252,7 +252,7 @@ "summary": "Air drying your clothes saves gas or electricity", "savings": "1.98", "cooldown": 1, - "icon": "lighterprints/activity-icons/airdry.bmp", + "icon": "lighterprints/activity-icons/67-tshirt.png", "name": "air-dry-clothes" } }, @@ -278,15 +278,15 @@ "model": "lighterprints.activity", "fields": { "display_name": "Turn off unnecessary lights", - "description": "Per bulb per hour: [60 watts / 1000 watts/kWh] *1.52 pounds of CO2 per kWh = 0.09 pound of CO2 per bulb per hour. Assume turning off 5 bulbs for 5 hours. This leads to 2.28 pounds of CO2 per day.", + "description": "The amount of CO2 saved by turning lights off is [60 watts / 1000 watts/kWh] * 1.52 pounds of CO2 per kWh, which equals 0.09 pounds of CO2 per bulb per hour. Assuming 5 bulbs are turned off for 5 hours, this saves 2.28 pounds of CO2 per day.", "available_all_day": false, "url": "http://www.epa.gov/climatechange/kids/calc/index.html", "level": 3, "group_activity": false, - "summary": "Turning lights off in areas that don't need it saves energy.", + "summary": "Turning lights off in areas that don't need them saves energy.", "savings": "2.28", "cooldown": 1, - "icon": "lighterprints/activity-icons/lightsoff.bmp", + "icon": "lighterprints/activity-icons/84-lightbulb.png", "name": "lights-off" } }, @@ -295,7 +295,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Become a vegan for a day", - "description": "A plant-based diet saves 1608 pound of CO2 per year compared to an average diet.", + "description": "A plant-based diet saves 1,608 pounds of CO2 per year compared to the average diet.", "available_all_day": false, "url": "http://www.simplesteps.org/tools/house-savings-calculator#diet", "level": 3, @@ -303,7 +303,7 @@ "summary": "Raising animals for meat is resource intensive", "savings": "4.41", "cooldown": 1, - "icon": "lighterprints/activity-icons/organic.bmp", + "icon": "lighterprints/activity-icons/lettuce.png", "name": "vegan-for-a-day" } }, @@ -312,7 +312,7 @@ "model": "lighterprints.activity", "fields": { "display_name": "Wash your clothes with cold water", - "description": "You can save 400 pound of CO2 a year by washing all your clothes with cold water.", + "description": "You can save 400 pounds of CO2 a year by washing all your clothes with cold water.", "available_all_day": false, "url": "http://www.savecarbon.org/activity_form/washcold", "level": 3, @@ -320,10 +320,11 @@ "summary": "Save energy by not heating water", "savings": "1.10", "cooldown": 1, - "icon": "lighterprints/activity-icons/airdry_1.bmp", + "icon": "lighterprints/activity-icons/mwcold.png", "name": "wash-cold-water" } }, + { "pk": 4, "model": "lighterprints.activityavailability", Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |