Changeset 22 for exampleparties/randomparty/src
- Timestamp:
- 09/22/20 16:26:36 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java
r21 r22 39 39 * A simple party that places random bids and accepts when it receives an offer 40 40 * with sufficient utility. 41 * <h2>voting</h2> If the party receives a parameter "minPower", it will 42 * {@link Vote} using that minPower instead of the default value 2 if it 43 * receives a {@link Voting} request. 41 * <h2>parameters</h2> 42 * <table> 43 * <tr> 44 * <td>minPower</td> 45 * <td>This value is used as minPower for placed {@link Vote}s. Default value is 46 * 2.</td> 47 * </tr> 48 * <tr> 49 * <td>maxPower</td> 50 * <td>This value is used as maxPower for placed {@link Vote}s. Default value is 51 * infinity.</td> 52 * </tr> 53 * </table> 44 54 */ 45 55 public class RandomParty extends DefaultParty { … … 109 119 @Override 110 120 public String getDescription() { 111 return "places random bids until it can accept an offer with utility >0.6"; 121 return "places random bids until it can accept an offer with utility >0.6. " 122 + "Parameters minPower and maxPower can be used to control voting behaviour."; 112 123 } 113 124 … … 164 175 */ 165 176 private Votes vote(Voting voting) throws IOException { 166 Object val = settings.getParameters().get("minPow wer");167 Integer n= (val instanceof Integer) ? (Integer) val : 2;168 for (Bid bid : voting.getBids()) {169 System.out.println("Bid " + bid + "="170 + ((UtilitySpace) profileint.getProfile()).getUtility(bid));171 } 177 Object val = settings.getParameters().get("minPower"); 178 Integer minpower = (val instanceof Integer) ? (Integer) val : 2; 179 val = settings.getParameters().get("maxPower"); 180 Integer maxpower = (val instanceof Integer) ? (Integer) val 181 : Integer.MAX_VALUE; 182 172 183 List<Vote> votes = voting.getBids().stream().distinct() 173 .filter(bid -> isGood(bid)).map(bid -> new Vote(me, bid, n)) 184 .filter(bid -> isGood(bid)) 185 .map(bid -> new Vote(me, bid, minpower, maxpower)) 174 186 .collect(Collectors.toList()); 175 187 return new Votes(me, votes);
Note:
See TracChangeset
for help on using the changeset viewer.