Ignore:
Timestamp:
09/22/20 16:26:36 (4 years ago)
Author:
bart
Message:

Minor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java

    r21 r22  
    3939 * A simple party that places random bids and accepts when it receives an offer
    4040 * 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>
    4454 */
    4555public class RandomParty extends DefaultParty {
     
    109119        @Override
    110120        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.";
    112123        }
    113124
     
    164175         */
    165176        private Votes vote(Voting voting) throws IOException {
    166                 Object val = settings.getParameters().get("minPowwer");
    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
    172183                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))
    174186                                .collect(Collectors.toList());
    175187                return new Votes(me, votes);
Note: See TracChangeset for help on using the changeset viewer.