source: src/main/java/onetomany/bargainingchipsgame/BargainingChips.java@ 312

Last change on this file since 312 was 312, checked in by Tim Baarslag, 5 years ago

CoordinationMessage

File size: 3.3 KB
RevLine 
[268]1package onetomany.bargainingchipsgame;
2
[269]3import java.util.concurrent.BlockingQueue;
4import java.util.concurrent.LinkedBlockingQueue;
5
6import onetomany.bargainingchipsgame.interactions.Offer;
[287]7import onetomany.bargainingchipsgame.players.Agent;
[309]8import onetomany.bargainingchipsgame.players.BoulwareAgent;
[278]9import onetomany.bargainingchipsgame.players.CoordinationMessage;
[279]10import onetomany.bargainingchipsgame.players.Coordinator;
[312]11import onetomany.bargainingchipsgame.players.StatusMessage;
[302]12import onetomany.bargainingchipsgame.players.utilityfunction.UF_CloseToQuantity;
[301]13import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction;
[269]14
[268]15/**
[311]16 * This main class showcases the fundamental concepts in the Bargaining Chips game.
[268]17 *
[311]18 * Bargaining Chips is played by a buyer who seeks to acquire a number of chips for a good price.
19 * For example, the wish list of the buyer may consist of 2 red chips and 1 blue chip.
20 * Chips represents arbitrary indivisible items, such as products or tasks and are differentiated
21 * from others by a unique color.
22 *
23 * Bargaining Chips is played using an asynchronous offer protocol for each bilateral negotiation thread.
[310]24 * Multiple deals in simultaneous threads of one-to-many negotiation need to be coordinated; therefore,
25 * the buyer is equipped with two modules, one coordinator and multiple negotiators one per each thread.
[272]26 *
[310]27 * Each of the individual negotiations is itself a bilateral negotiation over multiple items and multiple
28 * issues, i.e. a multi-issue multi-item thread. As each thread could reach a deal, the whole negotiation
29 * could reach multiple deals.
[272]30 *
[310]31 * Negotiating in this setting needs some coordination efforts to synchronize threads according to the
32 * progress of each individual negotiation as well as the multiple deals compared with the party's preference.
[272]33 *
[310]34 * Bargaining Chips is a testbed for evaluating agents in such settings.
[268]35 *
36 */
37public class BargainingChips
38{
[269]39 public static void main(String[] args) throws InterruptedException
[268]40 {
[269]41 BlockingQueue<Offer> in = new LinkedBlockingQueue<Offer>();
42 BlockingQueue<Offer> out = new LinkedBlockingQueue<Offer>();
[268]43
[279]44 BlockingQueue<CoordinationMessage> cin = new LinkedBlockingQueue<CoordinationMessage>();
[312]45 BlockingQueue<StatusMessage> cout = new LinkedBlockingQueue<StatusMessage>();
[278]46
[309]47 NegotiationContext context = new NegotiationContext();
[302]48
[288]49 // Bob
[311]50 WishList wishlist = new WishListBuilder().addWish("Green", 2).build();
51 UtilityFunction u = new UF_CloseToQuantity(wishlist);
52 Agent bob1 = new BoulwareAgent("Bob 1", u, context, in, out, cin, cout);
[281]53
[310]54 // Coordinator
[311]55 Coordinator c = new Coordinator(wishlist, cout, cin);
[268]56
[288]57 // Sam
[302]58 WishList wishlistSam = new WishListBuilder().addWish("Green", 10).build();
59 UtilityFunction uSam = new UF_CloseToQuantity(wishlistSam);
[310]60 Agent sam = new BoulwareAgent("Sam 1", uSam, context, out, in);
[288]61
[310]62 // Start threads
63 System.out.println(bob1.toDescription());
[311]64 System.out.println("playing vs");
[302]65 System.out.println(sam.toDescription());
66
[273]67 Thread threadBuyer = new Thread(bob1);
68 threadBuyer.start();
[269]69
[273]70 Thread threadSeller = new Thread(sam);
71 threadSeller.start();
[279]72
73 Thread threadCoordinator = new Thread(c);
74 threadCoordinator.start();
[268]75 }
76
77}
Note: See TracBrowser for help on using the repository browser.