package onetomany.bargainingchipsgame; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import onetomany.bargainingchipsgame.interactions.Offer; import onetomany.bargainingchipsgame.players.Agent; import onetomany.bargainingchipsgame.players.BoulwareAgent; import onetomany.bargainingchipsgame.players.CoordinationMessage; import onetomany.bargainingchipsgame.players.Coordinator; import onetomany.bargainingchipsgame.players.NegotiationStatusMessage; import onetomany.bargainingchipsgame.players.utilityfunction.UF_CloseToQuantity; import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction; /** * This main class describes the fundamental concepts in the Bargaining Chips game. * * Bargaining Chips is based on an asynchronous offer protocol in each bilateral negotiation thread. * Multiple deals in simultaneous threads of one-to-many negotiation need to be coordinated; therefore, * the buyer is equipped with two modules, one coordinator and multiple negotiators one per each thread. * * Each of the individual negotiations is itself a bilateral negotiation over multiple items and multiple * issues, i.e. a multi-issue multi-item thread. As each thread could reach a deal, the whole negotiation * could reach multiple deals. * * Negotiating in this setting needs some coordination efforts to synchronize threads according to the * progress of each individual negotiation as well as the multiple deals compared with the party's preference. * * Bargaining Chips is a testbed for evaluating agents in such settings. * */ public class BargainingChips { public static void main(String[] args) throws InterruptedException { BlockingQueue in = new LinkedBlockingQueue(); BlockingQueue out = new LinkedBlockingQueue(); BlockingQueue cin = new LinkedBlockingQueue(); BlockingQueue cout = new LinkedBlockingQueue(); NegotiationContext context = new NegotiationContext(); // Bob WishList wishlist = new WishListBuilder().addWish("Green", 2).build(); UtilityFunction u = new UF_CloseToQuantity(wishlist); Agent bob1 = new BoulwareAgent("Bob 1", u, context, in, out, cin, cout); // Coordinator Coordinator c = new Coordinator(wishlist, cout, cin); // Sam WishList wishlistSam = new WishListBuilder().addWish("Green", 10).build(); UtilityFunction uSam = new UF_CloseToQuantity(wishlistSam); Agent sam = new BoulwareAgent("Sam 1", uSam, context, out, in); // Start threads System.out.println(bob1.toDescription()); System.out.println("vs"); System.out.println(sam.toDescription()); Thread threadBuyer = new Thread(bob1); threadBuyer.start(); Thread threadSeller = new Thread(sam); threadSeller.start(); Thread threadCoordinator = new Thread(c); threadCoordinator.start(); } }