Ignore:
File:
1 edited

Legend:

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

    r1 r2  
    2323import geniusweb.party.inform.Settings;
    2424import geniusweb.party.inform.YourTurn;
     25import geniusweb.profile.PartialOrdering;
     26import geniusweb.profile.Profile;
    2527import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
    2628import geniusweb.profileconnection.ProfileConnectionFactory;
     
    5557                        if (info instanceof Settings) {
    5658                                Settings settings = (Settings) info;
    57                                 this.profileint = ProfileConnectionFactory
    58                                                 .create(settings.getProfile().getURI(), getReporter());
     59                                this.profileint = ProfileConnectionFactory.create(settings.getProfile().getURI(), getReporter());
    5960                                this.me = settings.getID();
    6061                                this.progress = settings.getProgress();
     
    8081        public Capabilities getCapabilities() {
    8182                try {
    82                         return new Capabilities(new HashSet<>(
    83                                         Arrays.asList(new ProtocolRef(new URI("SAOP")))));
     83                        return new Capabilities(new HashSet<>(Arrays.asList(new ProtocolRef(new URI("SAOP")))));
    8484                } catch (URISyntaxException e) {
    85                         getReporter().log(Level.SEVERE, "Failed to create capabilities URI",
    86                                         e);
     85                        getReporter().log(Level.SEVERE, "Failed to create capabilities URI", e);
    8786                        return null;
    8887                }
     
    10099                } else {
    101100                        // for demo. Obviously full bids have higher util in general
    102                         AllPartialBidsList bidspace = new AllPartialBidsList(
    103                                         profileint.getProfile().getDomain());
     101                        AllPartialBidsList bidspace = new AllPartialBidsList(profileint.getProfile().getDomain());
    104102                        Bid bid = null;
    105103                        for (int attempt = 0; attempt < 20 && !isGood(bid); attempt++) {
     
    114112
    115113        private boolean isGood(Bid bid) {
    116                 return bid != null
    117                                 && ((LinearAdditiveUtilitySpace) profileint.getProfile())
    118                                                 .getUtility(bid).doubleValue() > 0.6;
     114                if (bid == null)
     115                        return false;
     116                Profile profile = profileint.getProfile();
     117                if (profile instanceof LinearAdditiveUtilitySpace) {
     118                        return ((LinearAdditiveUtilitySpace) profile).getUtility(bid).doubleValue() > 0.6;
     119                }
     120                if (profile instanceof PartialOrdering) {
     121                        return ((PartialOrdering) profile).isPreferredOrEqual(bid, profile.getReservationBid());
     122                }
     123                throw new IllegalArgumentException("Can not handle profile type " + profile.getClass());
    119124        }
    120125
Note: See TracChangeset for help on using the changeset viewer.