Changes between Version 124 and Version 125 of WikiStart


Ignore:
Timestamp:
02/25/19 17:06:59 (5 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v124 v125  
    2222
    2323Example parties can be found [https://tracinsy.ewi.tudelft.nl/trac/Genius2/browser/exampleparties here]. An agent is compiled with maven. After compilation ({{{mvn package}}}) you get a {{{target/yourparty-X.Y.Z-jar-with-dependencies.jar}}} that can be copied into the parties server for deployment.
     24
     25The basic structure of an agent looks like this
     26{{{
     27public class RandomParty extends DefaultParty {
     28        @Override
     29        public void notifyChange(Inform info) {
     30                // System.out.println("Received info:" + info);
     31                if (info instanceof Settings) {
     32                        fetchProfile(((Settings) info).getProfile());
     33                        this.me = ((Settings) info).getID();
     34                } else if (info instanceof ActionDone) {
     35                        lastActor = ((ActionDone) info).getAction().getActor();
     36                        Action otheract = ((ActionDone) info).getAction();
     37                        if (otheract instanceof Offer) {
     38                                lastReceivedBid = ((Offer) otheract).getBid();
     39                        }
     40                } else if (info instanceof YourTurn) {
     41                        myTurn();
     42                }
     43        }
     44
     45        private void myTurn() {
     46                Action action;
     47                if (lastReceivedBid != null && profileint.getProfile()
     48                                .getUtility(lastReceivedBid).doubleValue() > 0.6) {
     49                        action = new Accept(lastActor, lastReceivedBid);
     50                } else {
     51                        AllBidsList bidspace = new AllBidsList(getProfile().getDomain());
     52                        long i = random.nextInt(bidspace.size().intValue());
     53                        action = new Offer(me, bidspace.get(BigInteger.valueOf(i)));
     54                }
     55                try {
     56                        getConnection().send(action);
     57                } catch (IOException e) {
     58                        e.printStackTrace();
     59                }
     60
     61        }
     62
     63        @Override
     64        public Capabilities getCapabilities() {
     65                        return new Capabilities(new HashSet<>(
     66                                        Arrays.asList(new ProtocolRef(new URI("SAOP")))));
     67        }
     68
     69        @Override
     70        public String getDescription() {
     71                return "places random bids until it can accept an offer with utility >0.6";
     72        }
     73
     74}
     75}}}
    2476
    2577=== Some technical info