source: src/main/java/onetomany/bargainingchipsgame/players/BilateralAgent.java@ 270

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

Offers between agents

File size: 900 bytes
Line 
1package onetomany.bargainingchipsgame.players;
2
3import java.util.concurrent.BlockingQueue;
4
5import onetomany.bargainingchipsgame.Bundle;
6import onetomany.bargainingchipsgame.interactions.Offer;
7import onetomany.bargainingchipsgame.interactions.SampleOffer;
8
9public class BilateralAgent implements Runnable
10{
11 BlockingQueue<Offer> in;
12 BlockingQueue<Offer> out;
13
14 public BilateralAgent(BlockingQueue<Offer> in, BlockingQueue<Offer> out)
15 {
16 super();
17 this.in = in;
18 this.out = out;
19 }
20
21
22
23 @Override
24 public void run()
25 {
26 while (true)
27 {
28 Offer o;
29 try {
30 o = in.take();
31 Bundle bundle = o.getBundle();
32 System.out.println("Received " + bundle);
33 out.put(new SampleOffer(10));
34 System.out.println("Sent " + out);
35 } catch (InterruptedException e) {
36 // TODO Auto-generated catch block
37 e.printStackTrace();
38 }
39 }
40
41 }
42
43}
Note: See TracBrowser for help on using the repository browser.