Changes between Version 10 and Version 11 of WikiStart


Ignore:
Timestamp:
02/25/19 16:59:52 (6 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v10 v11  
    1313* (Re)start tomcat
    1414
    15 Now your local profilesserver should be up and running.
     15Now your local partiesserver should be up and running.
    1616
    1717== Using ==
    1818After installing and starting, go to [http://localhost:8080/partiesserver] to see if it works.
    1919
    20 Examples
     20Example parties can be found in the general genius repository, for example the [https://tracinsy.ewi.tudelft.nl/trac/Genius2/browser/exampleparties/randomparty randomparty]. The randomparty roughly looks like this
    2121{{{
    2222
    23 ...code...
     23public class RandomParty extends DefaultParty {
     24        @Override
     25        public void notifyChange(Inform info) {
     26                // System.out.println("Received info:" + info);
     27                if (info instanceof Settings) {
     28                        fetchProfile(((Settings) info).getProfile());
     29                        this.me = ((Settings) info).getID();
     30                } else if (info instanceof ActionDone) {
     31                        lastActor = ((ActionDone) info).getAction().getActor();
     32                        Action otheract = ((ActionDone) info).getAction();
     33                        if (otheract instanceof Offer) {
     34                                lastReceivedBid = ((Offer) otheract).getBid();
     35                        }
     36                } else if (info instanceof YourTurn) {
     37                        myTurn();
     38                }
     39        }
     40
     41        private void myTurn() {
     42                Action action;
     43                if (lastReceivedBid != null && profileint.getProfile()
     44                                .getUtility(lastReceivedBid).doubleValue() > 0.6) {
     45                        action = new Accept(lastActor, lastReceivedBid);
     46                } else {
     47                        AllBidsList bidspace = new AllBidsList(getProfile().getDomain());
     48                        long i = random.nextInt(bidspace.size().intValue());
     49                        action = new Offer(me, bidspace.get(BigInteger.valueOf(i)));
     50                }
     51                try {
     52                        getConnection().send(action);
     53                } catch (IOException e) {
     54                        e.printStackTrace();
     55                }
     56
     57        }
     58
     59}
    2460}}}
    2561