source: src/main/java/onetomany/bargainingchipsgame/players/Agent.java@ 265

Last change on this file since 265 was 257, checked in by Faria Nassiri Mofakham, 5 years ago

1) BilateralNegotiation which extends Thread added to onetomany. According to BCG protocol this creates two threads, one for a buyer and one for a seller (it now generates null agents). 2) An ActionListener added to close button in onetomany.etc.GUI.

File size: 2.6 KB
Line 
1/**
2 * Negotiator class
3 */
4package onetomany.bargainingchipsgame.players;
5
6import onetomany.bargainingchipsgame.Bundle;
7import onetomany.bargainingchipsgame.players.utilityfunction.Utility_Function;
8
9/**
10 * A negotiator agent has typically a buyer or seller role.
11 * An agent has a wish list (to buy or sell), which is a bundle, and a utility function for evaluating any proposal.
12 *
13 * Negotiator class has a wishlist, deadline, picture, and (implements) a utility function.
14 *
15 *
16 * @author Faria Nassiri-Mofakham
17 *
18 */
19public class Agent implements Runnable
20{
21 private String name;
22 private Bundle wishlist;
23 private Utility_Function utility;
24 private String picture;
25 private long deadline;
26
27
28 public Agent()
29 {
30 setName(null);
31 setWishlist(null);
32 setUtility(null);
33 setDeadline(0);
34 setPicture(null);
35 }
36
37 public Agent(String n, Bundle w, Utility_Function u, long d, String p)
38 {
39 setName(n);
40 setWishlist(w);
41 setUtility(u);
42 setDeadline(d);
43 setPicture(p);
44 }
45
46
47 @Override
48 public void run() {
49 // TODO Auto-generated method stub
50
51 // ? what to do here?
52
53 }
54
55
56 /**
57 * @return the wishlist
58 */
59 public Bundle getWishlist() {
60 return wishlist;
61 }
62 /**
63 * @param wishlist the wishlist to set
64 */
65 public void setWishlist(Bundle wishlist) {
66 this.wishlist = wishlist;
67 }
68 /**
69 * @return the name
70 */
71 public String getName() {
72 return name;
73 }
74
75 /**
76 * @param name the name to set
77 */
78 public void setName(String name) {
79 this.name = name;
80 }
81
82 /**
83 * @return the utility
84 */
85 public Double getUtility(Bundle b)
86 {
87 return utility.getUtility(b);
88 }
89 /**
90 * @param u the utility to set
91 */
92 public void setUtility(Utility_Function u) {
93 this.utility = u;
94 }
95 /**
96 * @return the picture
97 */
98 public String getPicture() {
99 return picture;
100 }
101 /**
102 * @param picture the picture to set
103 */
104 public void setPicture(String picture) {
105 this.picture = picture;
106 }
107 /**
108 * @return the deadline
109 */
110 public long getDeadline() {
111 return deadline;
112 }
113 /**
114 * @param deadline the deadline to set
115 */
116 public void setDeadline(long deadline) {
117 this.deadline = deadline;
118 }
119
120 @Override
121 public String toString()
122 {
123 return this.getClass().getSimpleName()+" (name:"+name+", wishlist:"+this.wishlist+", "+this.utility+", deadline:"+deadline+", picture:"+picture+")";
124 }
125
126 public void printUtility(Bundle b)
127 {
128 System.out.println("\n"+this+"\nBundle "+b+"\n"+this.getName()+" evaluates utility of this bundle as "+this.getUtility(b));
129 }
130
131}
Note: See TracBrowser for help on using the repository browser.