[243] | 1 | /**
|
---|
| 2 | * Negotiator class
|
---|
| 3 | */
|
---|
[253] | 4 | package onetomany.bargainingchipsgame.players;
|
---|
[243] | 5 |
|
---|
[253] | 6 | import onetomany.bargainingchipsgame.Bundle;
|
---|
| 7 | import onetomany.bargainingchipsgame.players.utilityfunction.Utility_Function;
|
---|
[243] | 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 | */
|
---|
[257] | 19 | public class Agent implements Runnable
|
---|
[243] | 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 |
|
---|
[257] | 46 |
|
---|
| 47 | @Override
|
---|
| 48 | public void run() {
|
---|
| 49 | // TODO Auto-generated method stub
|
---|
| 50 |
|
---|
| 51 | // ? what to do here?
|
---|
| 52 |
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 |
|
---|
[243] | 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 | */
|
---|
[257] | 85 | public Double getUtility(Bundle b)
|
---|
| 86 | {
|
---|
| 87 | return utility.getUtility(b);
|
---|
[243] | 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 |
|
---|
[253] | 120 | @Override
|
---|
[243] | 121 | public String toString()
|
---|
| 122 | {
|
---|
[253] | 123 | return this.getClass().getSimpleName()+" (name:"+name+", wishlist:"+this.wishlist+", "+this.utility+", deadline:"+deadline+", picture:"+picture+")";
|
---|
[243] | 124 | }
|
---|
[257] | 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 |
|
---|
[243] | 131 | }
|
---|