[127] | 1 | package agents.qoagent;
|
---|
| 2 |
|
---|
| 3 | //file name: Agent.java
|
---|
| 4 | import java.util.*;
|
---|
| 5 | import java.io.*;
|
---|
| 6 | import java.net.*;
|
---|
| 7 |
|
---|
| 8 | /*****************************************************************
|
---|
| 9 | * Class name: Agent
|
---|
| 10 | * Goal: Each object of the class represents an agent (Side B = Zimbabwe/Job Can,
|
---|
| 11 | * Side A = England/Employer or a mediator). The class holds all the information
|
---|
| 12 | * of the agent along with his opponent's ID and name (and mediator's
|
---|
| 13 | * ID and name - if exists). This class allows the server to set/get
|
---|
| 14 | * all necessary data of an agent in an efficient way.
|
---|
| 15 | ****************************************************************/
|
---|
| 16 | class Agent
|
---|
| 17 | {
|
---|
| 18 | //general variables
|
---|
| 19 | /* DT: private ServerThread m_st; //Allows access to the agent's thread at the server
|
---|
| 20 | private MultiServer m_server; //Allows access to the server*/
|
---|
| 21 | private Vector<Issue> m_vecIssues; //The negotiation issues of the agent and their status
|
---|
| 22 | private boolean m_bHasOpponent; //Whether the agent has an opponent or not
|
---|
| 23 | private boolean m_bHasMediator; //Whether the agent has a mediator or not
|
---|
| 24 | private boolean m_bSupportMediator; //Whether the agent supports a mediator or not
|
---|
| 25 | private int m_nCurrentTurn; //Current turn of the negotiation
|
---|
| 26 | private Socket m_socket = null; //The socket which allows the agent's thread in the
|
---|
| 27 | //server to connect to the client program
|
---|
| 28 | private String m_sSide; //Holds the side of the agent (B = Zimbabwe/Job Can,A = England/Employer,Mediator)
|
---|
| 29 | private PrintWriter m_out = null; //Allows writing to the socket
|
---|
| 30 | GameTimeServer m_gtEndTurn = null; //A stop watch for each turn
|
---|
| 31 | GameTimeServer m_gtEndNeg = null; //A stop watch for the entire negotiation
|
---|
| 32 | private int m_nPort;
|
---|
| 33 | private double m_dScore; //the agent's score of the negotiation
|
---|
| 34 | private double m_dTimeEffect; // time effect for the entire agreement
|
---|
| 35 | private double m_dOptOutValue; // opting out value
|
---|
| 36 | private double m_dStatusQuoValue; // status quo value
|
---|
| 37 |
|
---|
| 38 | //Agent's Details
|
---|
| 39 | private String m_sId; //Agent's Id
|
---|
| 40 | private String m_sName; //Agent's Name
|
---|
| 41 |
|
---|
| 42 | //Opponent's Details, in case that we are not a mediator
|
---|
| 43 | private String m_sOppId; //Opponent's Id
|
---|
| 44 | private String m_sOppName; //Opponent's Name
|
---|
| 45 |
|
---|
| 46 | //mediator Details, in case that we are not a mediator
|
---|
| 47 | private String m_sMedId; //mediator's Id
|
---|
| 48 | private String m_sMedName; //mediator's Name
|
---|
| 49 |
|
---|
| 50 | //The two sides in case that we are a mediator
|
---|
| 51 | private String m_sIdSideA,m_sIdSideB; //Ids
|
---|
| 52 |
|
---|
| 53 | public final static String TIME_EFFECT_STR = "Time-Effect";
|
---|
| 54 | public final static String OPT_OUT_STR = "Opt-Out";
|
---|
| 55 | public final static String STATUS_QUO_STR = "Status-Quo";
|
---|
| 56 |
|
---|
| 57 | private String m_sPrefDetails;
|
---|
| 58 |
|
---|
| 59 | private String m_sEndNegReason;
|
---|
| 60 | private int m_nOptOutNum;
|
---|
| 61 | private int m_nResponsesNum;
|
---|
| 62 | private int m_nAcceptsNum;
|
---|
| 63 | private int m_nRejectionsNum;
|
---|
| 64 | private int m_nCommentsNum;
|
---|
| 65 | private int m_nThreatsNum;
|
---|
| 66 | private int m_nOffersNum;
|
---|
| 67 | private int m_nPromisesNum;
|
---|
| 68 | private int m_nQueriesNum;
|
---|
| 69 |
|
---|
| 70 | /*****************************************************************
|
---|
| 71 | * Method name: Agent()
|
---|
| 72 | * Goal: Constructor.
|
---|
| 73 | * Description: Initialize the class variables and reading the issues
|
---|
| 74 | * from the utility file.
|
---|
| 75 | * Input: A MultiServer object (to allow access to the server),
|
---|
| 76 | * a ServerThread object (to allow access to the agent's
|
---|
| 77 | * thread at the server)
|
---|
| 78 | * boolean which specifies whether the agent supports a mediator or not.
|
---|
| 79 | * string - the side of the agent
|
---|
| 80 | * Output: None.
|
---|
| 81 | ******************************************************************/
|
---|
| 82 | public Agent(/* DT: MultiServer server,ServerThread st,*/ boolean SupportMed,String sSide)
|
---|
| 83 | {
|
---|
| 84 | m_nOptOutNum = 0;
|
---|
| 85 | m_nResponsesNum = 0;
|
---|
| 86 | m_nAcceptsNum = 0;
|
---|
| 87 | m_nRejectionsNum = 0;
|
---|
| 88 | m_nThreatsNum = 0;
|
---|
| 89 | m_nCommentsNum = 0;
|
---|
| 90 | m_nOffersNum = 0;
|
---|
| 91 | m_nPromisesNum = 0;
|
---|
| 92 | m_nQueriesNum = 0;
|
---|
| 93 |
|
---|
| 94 | m_sEndNegReason = "";
|
---|
| 95 |
|
---|
| 96 | m_dTimeEffect = 0;
|
---|
| 97 | m_dStatusQuoValue = 0;
|
---|
| 98 | m_dOptOutValue = 0;
|
---|
| 99 |
|
---|
| 100 | m_sIdSideA=null;
|
---|
| 101 | m_sIdSideB=null;
|
---|
| 102 | m_sMedId=null;
|
---|
| 103 |
|
---|
| 104 | m_sSide=sSide;
|
---|
| 105 | m_bHasMediator=false;
|
---|
| 106 | m_bSupportMediator=SupportMed;
|
---|
| 107 | //DT: m_st=st;
|
---|
| 108 | //DT: m_server=server;
|
---|
| 109 | m_bHasOpponent=false;
|
---|
| 110 | m_nCurrentTurn=1;
|
---|
| 111 | m_nPort = 0;
|
---|
| 112 | m_dScore=0;
|
---|
| 113 |
|
---|
| 114 | m_vecIssues=new Vector<Issue>();
|
---|
| 115 |
|
---|
| 116 | //reading issues from the appropriate utility file
|
---|
| 117 | try
|
---|
| 118 | {
|
---|
| 119 | BufferedReader br=new BufferedReader(new FileReader("utility"+m_sSide+".txt"));
|
---|
| 120 | String line;
|
---|
| 121 | int nOrder=1;
|
---|
| 122 | Issue issue=new Issue();
|
---|
| 123 |
|
---|
| 124 | while((line=br.readLine())!=null)
|
---|
| 125 | {
|
---|
| 126 | if(!line.startsWith("#"))
|
---|
| 127 | {
|
---|
| 128 | if (line.startsWith("@")) // general values data
|
---|
| 129 | {
|
---|
| 130 | StringTokenizer stGeneral = new StringTokenizer(line);
|
---|
| 131 |
|
---|
| 132 | stGeneral.nextToken(); // '@'
|
---|
| 133 |
|
---|
| 134 | String sType = stGeneral.nextToken();
|
---|
| 135 |
|
---|
| 136 | String sValue = stGeneral.nextToken();
|
---|
| 137 | Double dTemp = new Double(sValue);
|
---|
| 138 |
|
---|
| 139 | if (sType.equals(TIME_EFFECT_STR))
|
---|
| 140 | m_dTimeEffect = dTemp.doubleValue();
|
---|
| 141 | else if (sType.equals(STATUS_QUO_STR))
|
---|
| 142 | m_dStatusQuoValue = dTemp.doubleValue();
|
---|
| 143 | else if (sType.equals(OPT_OUT_STR))
|
---|
| 144 | m_dOptOutValue = dTemp.doubleValue();
|
---|
| 145 | }
|
---|
| 146 | else if (!line.startsWith("!")) //a new title
|
---|
| 147 | {
|
---|
| 148 | switch(nOrder)
|
---|
| 149 | {
|
---|
| 150 | case 1: //the first line is: attribute_name*side*weight
|
---|
| 151 | //the attribute's name and weight is saved in issue
|
---|
| 152 | issue.setAttribute(line.substring(0,line.indexOf("*")));
|
---|
| 153 | String sTemp=line.substring(line.indexOf("*")+1);
|
---|
| 154 | sTemp=sTemp.substring(sTemp.indexOf("*")+1);
|
---|
| 155 | issue.setWeight(sTemp);
|
---|
| 156 | break;
|
---|
| 157 | case 2: issue.setValues(line);
|
---|
| 158 | break;
|
---|
| 159 | case 3: issue.setUtilities(line);
|
---|
| 160 | break;
|
---|
| 161 | case 4: issue.setTimeEffect(line);
|
---|
| 162 | break;
|
---|
| 163 | case 5: m_vecIssues.addElement(issue);
|
---|
| 164 | nOrder=0;
|
---|
| 165 | issue=new Issue();
|
---|
| 166 | }
|
---|
| 167 | nOrder++;
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 | } //while
|
---|
| 171 |
|
---|
| 172 | br.close();
|
---|
| 173 | }//try
|
---|
| 174 |
|
---|
| 175 | catch(IOException e)
|
---|
| 176 | {
|
---|
| 177 | System.out.println("ERROR----" + "[Agent " + m_sId + "] " + "I/O Error while reading from file: " + e.getMessage() + "[Agent::Agent(153)]");
|
---|
| 178 | System.err.println("ERROR----" + "[Agent " + m_sId + "] " + "I/O Error while reading from file: " + e.getMessage() + "[Agent::Agent(153)]");
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /*****************************************************************
|
---|
| 183 | * Method name: setScore()
|
---|
| 184 | * Goal: Setting the agent's score.
|
---|
| 185 | * Input: double(the score).
|
---|
| 186 | * Output: None.
|
---|
| 187 | ****************************************************************/
|
---|
| 188 | public void setScore(double score)
|
---|
| 189 | {
|
---|
| 190 | m_dScore=score;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | /*****************************************************************
|
---|
| 194 | * Method name: getScore()
|
---|
| 195 | * Goal: Return the agent's score.
|
---|
| 196 | * Input: None.
|
---|
| 197 | * Output: double(the score).
|
---|
| 198 | ***************************************************************/
|
---|
| 199 | public double getScore()
|
---|
| 200 | {
|
---|
| 201 | return m_dScore;
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | /*****************************************************************
|
---|
| 205 | * Method name: setIssuesVector()
|
---|
| 206 | * Goal: Setting the Issues vector.
|
---|
| 207 | * Input: A vector of issues.
|
---|
| 208 | * Output: None.
|
---|
| 209 | ****************************************************************/
|
---|
| 210 | public void setIssuesVector(Vector<Issue> vec)
|
---|
| 211 | {
|
---|
| 212 | m_vecIssues=vec;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | /*****************************************************************
|
---|
| 216 | * Method name: getIssuesVector()
|
---|
| 217 | * Goal: Return the Issues vector.
|
---|
| 218 | * Input: None.
|
---|
| 219 | * Output: A vector of issues.
|
---|
| 220 | ***************************************************************/
|
---|
| 221 | public Vector<Issue> getIssuesVector()
|
---|
| 222 | {
|
---|
| 223 | return m_vecIssues;
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | /*****************************************************************
|
---|
| 227 | * Method name: initIssuesVector()
|
---|
| 228 | * Goal: Set all the issues as not agreed yet.
|
---|
| 229 | * Input: None.
|
---|
| 230 | * Output: None.
|
---|
| 231 | ***************************************************************/
|
---|
| 232 | public void initIssuesVector()
|
---|
| 233 | {
|
---|
| 234 | if(m_vecIssues!=null)
|
---|
| 235 | for(int i=0; i < getIssuesNum(); i++)
|
---|
| 236 | {
|
---|
| 237 | getIssueAt(i).setAgreed(false);
|
---|
| 238 | }
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | /*****************************************************************
|
---|
| 242 | * Method name: setName()
|
---|
| 243 | * Goal: Setting the agent's name.
|
---|
| 244 | * Input: A string.
|
---|
| 245 | * Output: None.
|
---|
| 246 | ****************************************************************/
|
---|
| 247 | public void setName(String sName)
|
---|
| 248 | {
|
---|
| 249 | m_sName = sName;
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | /*****************************************************************
|
---|
| 253 | * Method name: getName()
|
---|
| 254 | * Goal: Return the agent's name.
|
---|
| 255 | * Input: None.
|
---|
| 256 | * Output: A string.
|
---|
| 257 | ***************************************************************/
|
---|
| 258 | public String getName()
|
---|
| 259 | {
|
---|
| 260 | return m_sName;
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 | /*****************************************************************
|
---|
| 264 | * Method name: setOpponentName()
|
---|
| 265 | * Goal: Setting the opponent's name.
|
---|
| 266 | * Input: A string.
|
---|
| 267 | * Output: None.
|
---|
| 268 | ****************************************************************/
|
---|
| 269 | public void setOpponentName(String sOppName)
|
---|
| 270 | {
|
---|
| 271 | m_sOppName = sOppName;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | /*****************************************************************
|
---|
| 275 | * Method name: getOpponentName()
|
---|
| 276 | * Goal: Return the opponent's name.
|
---|
| 277 | * Input: None.
|
---|
| 278 | * Output: A string.
|
---|
| 279 | ***************************************************************/
|
---|
| 280 | public String getOpponentName()
|
---|
| 281 | {
|
---|
| 282 | return m_sOppName;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | /*****************************************************************
|
---|
| 286 | * Method name: setMedName()
|
---|
| 287 | * Goal: Setting the mediator's name.
|
---|
| 288 | * Input: A string.
|
---|
| 289 | * Output: None.
|
---|
| 290 | ****************************************************************/
|
---|
| 291 | public void setMedName(String sMedName)
|
---|
| 292 | {
|
---|
| 293 | m_sMedName = sMedName;
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | /*****************************************************************
|
---|
| 297 | * Method name: getMedName()
|
---|
| 298 | * Goal: Return the mediator's name.
|
---|
| 299 | * Input: None.
|
---|
| 300 | * Output: A string.
|
---|
| 301 | ***************************************************************/
|
---|
| 302 | public String getMedName()
|
---|
| 303 | {
|
---|
| 304 | return m_sMedName;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | /*****************************************************************
|
---|
| 308 | * Method name: setEndTurnNewGame()
|
---|
| 309 | * Goal: Restarting the end-turn stop watch.
|
---|
| 310 | * Input: None.
|
---|
| 311 | * Output: None.
|
---|
| 312 | ****************************************************************/
|
---|
| 313 | public void setEndTurnNewGame()
|
---|
| 314 | {
|
---|
| 315 | m_gtEndTurn.newGame();
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | /*****************************************************************
|
---|
| 319 | * Method name: setEndNegNewGame()
|
---|
| 320 | * Goal: Restarting the end-negotiation stop watch.
|
---|
| 321 | * Input: None.
|
---|
| 322 | * Output: None.
|
---|
| 323 | ****************************************************************/
|
---|
| 324 | public void setEndNegNewGame()
|
---|
| 325 | {
|
---|
| 326 | m_gtEndNeg.newGame();
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | /*****************************************************************
|
---|
| 330 | * Method name: setSide()
|
---|
| 331 | * Goal: Setting the agent's side.
|
---|
| 332 | * Input: A string.
|
---|
| 333 | * Output: None.
|
---|
| 334 | ****************************************************************/
|
---|
| 335 | public void setSide(String sSide)
|
---|
| 336 | {
|
---|
| 337 | m_sSide = sSide;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | /*****************************************************************
|
---|
| 341 | * Method name: getSide()
|
---|
| 342 | * Goal: Return the agent's side.
|
---|
| 343 | * Input: None.
|
---|
| 344 | * Output: None.
|
---|
| 345 | ***************************************************************/
|
---|
| 346 | public String getSide()
|
---|
| 347 | {
|
---|
| 348 | return m_sSide;
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | /*****************************************************************
|
---|
| 352 | * Method name: setEndNeg()
|
---|
| 353 | * Goal: Initializing the end-negotiation stop watch.
|
---|
| 354 | * Input: A boolean which specifies whether the stop watch counts up or not,
|
---|
| 355 | * three integers (hours, minutes and seconds), another boolean which
|
---|
| 356 | * specifies whether the stop watch is of type end-turn or end-negotiation,
|
---|
| 357 | * and another integer (number of turns in the negotiation).
|
---|
| 358 | * Output: None.
|
---|
| 359 | ****************************************************************/
|
---|
| 360 | public void setEndNeg(boolean bCountUp, int nHours, int nMinutes, int nSeconds, boolean bTurnOrNeg, int nMaxTurn)
|
---|
| 361 | {
|
---|
| 362 | m_gtEndNeg = new GameTimeServer(bCountUp,nHours,nMinutes,nSeconds,this,bTurnOrNeg,nMaxTurn /* DT: ,m_server,m_st */);
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | /*****************************************************************
|
---|
| 366 | * Method name: setEndNegRun()
|
---|
| 367 | * Goal: Stopping or continuing the end-negotiation stop watch.
|
---|
| 368 | * Input: A boolean which specifies whether the stop watch should
|
---|
| 369 | * stop (false) or continue (true).
|
---|
| 370 | * Output: None.
|
---|
| 371 | ****************************************************************/
|
---|
| 372 | public void setEndNegRun(boolean bRun)
|
---|
| 373 | {
|
---|
| 374 | m_gtEndNeg.setRun(bRun);
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | /*****************************************************************
|
---|
| 378 | * Method name: setEndTurn()
|
---|
| 379 | * Goal: Initializing the end-turn stop watch.
|
---|
| 380 | * Input: A boolean which specifies whether the stop watch counts up or not,
|
---|
| 381 | * three integers (hours, minutes and seconds), another boolean which
|
---|
| 382 | * specifies whether the stop watch is of type end-turn or end-negotiation,
|
---|
| 383 | * and another integer (number of turns in the negotiation).
|
---|
| 384 | * Output: None.
|
---|
| 385 | ****************************************************************/
|
---|
| 386 | public void setEndTurn(boolean bCountUp, int nHours, int nMinutes, int nSeconds, boolean bTurnOrNeg, int nMaxTurn)
|
---|
| 387 | {
|
---|
| 388 | m_gtEndTurn = new GameTimeServer(bCountUp,nHours,nMinutes,nSeconds,this,bTurnOrNeg,nMaxTurn/* DT: ,m_server,m_st */);
|
---|
| 389 | }
|
---|
| 390 |
|
---|
| 391 | /*****************************************************************
|
---|
| 392 | * Method name: setEndTurnRun()
|
---|
| 393 | * Goal: Stopping or continuing the end-turn stop watch.
|
---|
| 394 | * Input: A boolean which specifies whether the stop watch should
|
---|
| 395 | * stop (false) or continue (true).
|
---|
| 396 | * Output: None.
|
---|
| 397 | ****************************************************************/
|
---|
| 398 | public void setEndTurnRun(boolean bRun)
|
---|
| 399 | {
|
---|
| 400 | m_gtEndTurn.setRun(bRun);
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | /*****************************************************************
|
---|
| 404 | * Method name: setIssueAt()
|
---|
| 405 | * Goal: Inserting an Issue to the issues vectors at a specified index.
|
---|
| 406 | * Input: An integer (the index) and an Issue.
|
---|
| 407 | * Output: None.
|
---|
| 408 | ****************************************************************/
|
---|
| 409 | public void setIssueAt(int index, Issue issue)
|
---|
| 410 | {
|
---|
| 411 | m_vecIssues.set(index, issue);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | /*****************************************************************
|
---|
| 415 | * Method name: getIssuesNum()
|
---|
| 416 | * Goal: Return the number of issues of the negotiation.
|
---|
| 417 | * Input: None.
|
---|
| 418 | * Output: An integer.
|
---|
| 419 | ***************************************************************/
|
---|
| 420 | public int getIssuesNum()
|
---|
| 421 | {
|
---|
| 422 | return m_vecIssues.size();
|
---|
| 423 | }
|
---|
| 424 |
|
---|
| 425 | /*****************************************************************
|
---|
| 426 | * Method name: getIssueAt()
|
---|
| 427 | * Goal: Return the issue at the specified index.
|
---|
| 428 | * Input: An integer (the index).
|
---|
| 429 | * Output: An Issue.
|
---|
| 430 | ***************************************************************/
|
---|
| 431 | public Issue getIssueAt(int index)
|
---|
| 432 | {
|
---|
| 433 | return (Issue)m_vecIssues.elementAt(index);
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | /*****************************************************************
|
---|
| 437 | * Method name: setPort()
|
---|
| 438 | * Goal: Setting the agent's port.
|
---|
| 439 | * Input: An integer (the port).
|
---|
| 440 | * Output: None.
|
---|
| 441 | ****************************************************************/
|
---|
| 442 | public void setPort(int nPort)
|
---|
| 443 | {
|
---|
| 444 | m_nPort = nPort;
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | /*****************************************************************
|
---|
| 448 | * Method name: getPort()
|
---|
| 449 | * Goal: Return the agent's port.
|
---|
| 450 | * Input: None.
|
---|
| 451 | * Output: An integer.
|
---|
| 452 | ***************************************************************/
|
---|
| 453 | public int getPort()
|
---|
| 454 | {
|
---|
| 455 | return m_nPort;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | /*****************************************************************
|
---|
| 459 | * Method name: setId()
|
---|
| 460 | * Goal: Setting the agent's ID.
|
---|
| 461 | * Input: A String.
|
---|
| 462 | * Output: None.
|
---|
| 463 | ****************************************************************/
|
---|
| 464 | public void setId(String sId)
|
---|
| 465 | {
|
---|
| 466 | m_sId = sId;
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | /*****************************************************************
|
---|
| 470 | * Method name: getId()
|
---|
| 471 | * Goal: Return the agent's ID.
|
---|
| 472 | * Input: None.
|
---|
| 473 | * Output: A String.
|
---|
| 474 | ***************************************************************/
|
---|
| 475 | public String getId()
|
---|
| 476 | {
|
---|
| 477 | return m_sId;
|
---|
| 478 | }
|
---|
| 479 |
|
---|
| 480 | /*****************************************************************
|
---|
| 481 | * Method name: getOpponentId()
|
---|
| 482 | * Goal: Return the opponent's ID.
|
---|
| 483 | * Input: None.
|
---|
| 484 | * Output: A String.
|
---|
| 485 | ***************************************************************/
|
---|
| 486 | public String getOpponentId()
|
---|
| 487 | {
|
---|
| 488 | return m_sOppId;
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | /*****************************************************************
|
---|
| 492 | * Method name: getMedId()
|
---|
| 493 | * Goal: Return the mediator's ID.
|
---|
| 494 | * Input: None.
|
---|
| 495 | * Output: A String.
|
---|
| 496 | ***************************************************************/
|
---|
| 497 | public String getMedId()
|
---|
| 498 | {
|
---|
| 499 | return m_sMedId;
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | /*****************************************************************
|
---|
| 503 | * Method name: getIdSideA()
|
---|
| 504 | * Goal: Return the England/Employer side ID (Side A) (in case the agent is a mediator).
|
---|
| 505 | * Input: None.
|
---|
| 506 | * Output: A String.
|
---|
| 507 | ***************************************************************/
|
---|
| 508 | public String getIdSideA()
|
---|
| 509 | {
|
---|
| 510 | return m_sIdSideA;
|
---|
| 511 | }
|
---|
| 512 |
|
---|
| 513 | /*****************************************************************
|
---|
| 514 | * Method name: getIdSideB()
|
---|
| 515 | * Goal: Return the Zimbabwe/Job Can side ID (Side B) (in case the agent is a mediator).
|
---|
| 516 | * Input: None.
|
---|
| 517 | * Output: A String.
|
---|
| 518 | ***************************************************************/
|
---|
| 519 | public String getIdSideB()
|
---|
| 520 | {
|
---|
| 521 | return m_sIdSideB;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | /*****************************************************************
|
---|
| 525 | * Method name: setOpponentId()
|
---|
| 526 | * Goal: Setting the opponent's ID.
|
---|
| 527 | * Input: A String.
|
---|
| 528 | * Output: None.
|
---|
| 529 | ****************************************************************/
|
---|
| 530 | public void setOpponentId(String sOppId)
|
---|
| 531 | {
|
---|
| 532 | m_sOppId = sOppId;
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | /*****************************************************************
|
---|
| 536 | * Method name: setMedId()
|
---|
| 537 | * Goal: Setting the mediator's ID.
|
---|
| 538 | * Input: A String.
|
---|
| 539 | * Output: None.
|
---|
| 540 | ****************************************************************/
|
---|
| 541 | public void setMedId(String sMedId)
|
---|
| 542 | {
|
---|
| 543 | m_sMedId = sMedId;
|
---|
| 544 | }
|
---|
| 545 |
|
---|
| 546 | /*****************************************************************
|
---|
| 547 | * Method name: setIdSideA()
|
---|
| 548 | * Goal: Setting the England/Employer side ID (Side A) (in case the agent is a mediator).
|
---|
| 549 | * Input: A String.
|
---|
| 550 | * Output: None.
|
---|
| 551 | ****************************************************************/
|
---|
| 552 | public void setIdSideA(String sId)
|
---|
| 553 | {
|
---|
| 554 | m_sIdSideA = sId;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | /*****************************************************************
|
---|
| 558 | * Method name: setIdSideB()
|
---|
| 559 | * Goal: Setting the Zimbabwe/Job Can side ID (Side B) (in case the agent is a mediator).
|
---|
| 560 | * Input: A String.
|
---|
| 561 | * Output: None.
|
---|
| 562 | ****************************************************************/
|
---|
| 563 | public void setIdSideB(String sId)
|
---|
| 564 | {
|
---|
| 565 | m_sIdSideB = sId;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | /*****************************************************************
|
---|
| 569 | * Method name: setSocket()
|
---|
| 570 | * Goal: Setting the agent's socket and setting the PrintWriter to
|
---|
| 571 | * write to the socket.
|
---|
| 572 | * Input: A Socket object.
|
---|
| 573 | * Output: None.
|
---|
| 574 | ****************************************************************/
|
---|
| 575 | public void setSocket(Socket socket)
|
---|
| 576 | {
|
---|
| 577 | m_socket = socket;
|
---|
| 578 | try {
|
---|
| 579 | m_out = new PrintWriter(m_socket.getOutputStream(),true);
|
---|
| 580 | }
|
---|
| 581 | catch (IOException e)
|
---|
| 582 | {
|
---|
| 583 | System.out.println("ERROR----" + "[Agent " + m_sId + "] " + "Error opening socket: " + e.getMessage() + " [Agent::setSocket(614)]");
|
---|
| 584 | System.err.println("ERROR----" + "[Agent " + m_sId + "] " + "Error opening socket: " + e.getMessage() + " [Agent::setSocket(614)]");
|
---|
| 585 | }
|
---|
| 586 | }
|
---|
| 587 |
|
---|
| 588 | /*****************************************************************
|
---|
| 589 | * Method name: closeSocketStream()
|
---|
| 590 | * Goal: Closing the PrintWriter which writes to the agent's socket.
|
---|
| 591 | * Input: None.
|
---|
| 592 | * Output: None.
|
---|
| 593 | ****************************************************************/
|
---|
| 594 | public void closeSocketStream()
|
---|
| 595 | {
|
---|
| 596 | m_out.close();
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | /*****************************************************************
|
---|
| 600 | * Method name: getSocket()
|
---|
| 601 | * Goal: Return the agent's socket.
|
---|
| 602 | * Input: None.
|
---|
| 603 | * Output: A Socket object.
|
---|
| 604 | ***************************************************************/
|
---|
| 605 | public Socket getSocket()
|
---|
| 606 | {
|
---|
| 607 | return m_socket;
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | /*****************************************************************
|
---|
| 611 | * Method name: writeToSocket()
|
---|
| 612 | * Goal: Writing a message to the agent's socket.
|
---|
| 613 | * Input: A string (the message).
|
---|
| 614 | * Output: None.
|
---|
| 615 | ***************************************************************/
|
---|
| 616 | public void writeToSocket(String sMsg)
|
---|
| 617 | {
|
---|
| 618 | m_out.println(sMsg);
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | /*****************************************************************
|
---|
| 622 | * Method name: incrementCurrentTurn()
|
---|
| 623 | * Goal: Incrementing the current turn of the negotiation.
|
---|
| 624 | * Input: None.
|
---|
| 625 | * Output: None.
|
---|
| 626 | ***************************************************************/
|
---|
| 627 | public void incrementCurrentTurn()
|
---|
| 628 | {
|
---|
| 629 | m_nCurrentTurn++;
|
---|
| 630 | }
|
---|
| 631 |
|
---|
| 632 | /*****************************************************************
|
---|
| 633 | * Method name: setCurrentTurn()
|
---|
| 634 | * Goal: Setting the current turn.
|
---|
| 635 | * Input: An integer.
|
---|
| 636 | * Output: None.
|
---|
| 637 | ****************************************************************/
|
---|
| 638 | public void setCurrentTurn(int nCurrentTurn)
|
---|
| 639 | {
|
---|
| 640 | m_nCurrentTurn = nCurrentTurn;
|
---|
| 641 | }
|
---|
| 642 |
|
---|
| 643 | /*****************************************************************
|
---|
| 644 | * Method name: getCurrentTurn()
|
---|
| 645 | * Goal: Return the current turn.
|
---|
| 646 | * Input: None.
|
---|
| 647 | * Output: An integer.
|
---|
| 648 | ***************************************************************/
|
---|
| 649 | public int getCurrentTurn()
|
---|
| 650 | {
|
---|
| 651 | return m_nCurrentTurn;
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | /*****************************************************************
|
---|
| 655 | * Method name: hasOpponent()
|
---|
| 656 | * Goal: Return a boolean which specifies whether the agent has an opponent.
|
---|
| 657 | * Input: None.
|
---|
| 658 | * Output: A boolean.
|
---|
| 659 | ***************************************************************/
|
---|
| 660 | public boolean hasOpponent()
|
---|
| 661 | {
|
---|
| 662 | return m_bHasOpponent;
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | /*****************************************************************
|
---|
| 666 | * Method name: setHasOpponent()
|
---|
| 667 | * Goal: Setting whether the agent has an opponent.
|
---|
| 668 | * Input: A boolean.
|
---|
| 669 | * Output: None.
|
---|
| 670 | ****************************************************************/
|
---|
| 671 | public void setHasOpponent(boolean bHasOpponent)
|
---|
| 672 | {
|
---|
| 673 | m_bHasOpponent = bHasOpponent;
|
---|
| 674 | }
|
---|
| 675 |
|
---|
| 676 | /*****************************************************************
|
---|
| 677 | * Method name: hasMediator()
|
---|
| 678 | * Goal: Return a boolean which specifies whether the agent has a mediator.
|
---|
| 679 | * Input: None.
|
---|
| 680 | * Output: A boolean.
|
---|
| 681 | ***************************************************************/
|
---|
| 682 | public boolean hasMediator()
|
---|
| 683 | {
|
---|
| 684 | return m_bHasMediator;
|
---|
| 685 | }
|
---|
| 686 |
|
---|
| 687 | /*****************************************************************
|
---|
| 688 | * Method name: setHasMediator()
|
---|
| 689 | * Goal: Setting whether the agent has a mediator.
|
---|
| 690 | * Input: A boolean.
|
---|
| 691 | * Output: None.
|
---|
| 692 | ****************************************************************/
|
---|
| 693 | public void setHasMediator(boolean bHasMediator)
|
---|
| 694 | {
|
---|
| 695 | m_bHasMediator = bHasMediator;
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | /*****************************************************************
|
---|
| 699 | * Method name: supportMediator()
|
---|
| 700 | * Goal: Return a boolean which specifies whether the agent supports
|
---|
| 701 | * a mediator.
|
---|
| 702 | * Input: None.
|
---|
| 703 | * Output: A boolean.
|
---|
| 704 | ***************************************************************/
|
---|
| 705 | public boolean supportMediator()
|
---|
| 706 | {
|
---|
| 707 | return m_bSupportMediator;
|
---|
| 708 | }
|
---|
| 709 |
|
---|
| 710 | /*****************************************************************
|
---|
| 711 | * Method name: startEndNegThread()
|
---|
| 712 | * Goal: Starting the end-negotiation stop watch's thread.
|
---|
| 713 | * Input: None.
|
---|
| 714 | * Output: None.
|
---|
| 715 | ****************************************************************/
|
---|
| 716 | public void startEndNegThread()
|
---|
| 717 | {
|
---|
| 718 | new Thread(m_gtEndNeg).start();
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | /*****************************************************************
|
---|
| 722 | * Method name: startEndNegThread()
|
---|
| 723 | * Goal: Starting the end-turn stop watch's thread.
|
---|
| 724 | * Input: None.
|
---|
| 725 | * Output: None.
|
---|
| 726 | ****************************************************************/
|
---|
| 727 | public void startEndTurnThread()
|
---|
| 728 | {
|
---|
| 729 | new Thread(m_gtEndTurn).start();
|
---|
| 730 | }
|
---|
| 731 |
|
---|
| 732 | /*****************************************************************
|
---|
| 733 | * Method name: setPrefDetails()
|
---|
| 734 | * Goal: Setting the preference details of the player
|
---|
| 735 | * Input: String - list of preference details.
|
---|
| 736 | * Output: None.
|
---|
| 737 | ****************************************************************/
|
---|
| 738 | public void setPrefDetails(String sPrefDetails)
|
---|
| 739 | {
|
---|
| 740 | m_sPrefDetails = sPrefDetails;
|
---|
| 741 | }
|
---|
| 742 |
|
---|
| 743 | /*****************************************************************
|
---|
| 744 | * Method name: getPrefDetails()
|
---|
| 745 | * Goal: Get the preference details of the player
|
---|
| 746 | * Input: None.
|
---|
| 747 | * Output: String - list of preference details.
|
---|
| 748 | ****************************************************************/
|
---|
| 749 | public String getPrefDetails()
|
---|
| 750 | {
|
---|
| 751 | return m_sPrefDetails;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
| 754 | /*****************************************************************
|
---|
| 755 | * Method name: getAgreementTimeEffect()
|
---|
| 756 | * Goal: Get the time effect for the agent
|
---|
| 757 | * Input: None.
|
---|
| 758 | * Output: double - time effect
|
---|
| 759 | ****************************************************************/
|
---|
| 760 | public double getAgreementTimeEffect()
|
---|
| 761 | {
|
---|
| 762 | return m_dTimeEffect;
|
---|
| 763 | }
|
---|
| 764 |
|
---|
| 765 | /*****************************************************************
|
---|
| 766 | * Method name: getAgreementOptOutValue()
|
---|
| 767 | * Goal: Get opt out value for the agent
|
---|
| 768 | * Input: None.
|
---|
| 769 | * Output: double - opt out value
|
---|
| 770 | ****************************************************************/
|
---|
| 771 | public double getAgreementOptOutValue()
|
---|
| 772 | {
|
---|
| 773 | return m_dOptOutValue;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | /*****************************************************************
|
---|
| 777 | * Method name: getAgreementStatusQuoValue()
|
---|
| 778 | * Goal: Get status quo value for the agent
|
---|
| 779 | * Input: None.
|
---|
| 780 | * Output: double - SQ value
|
---|
| 781 | ****************************************************************/
|
---|
| 782 | public double getAgreementStatusQuoValue()
|
---|
| 783 | {
|
---|
| 784 | return m_dStatusQuoValue;
|
---|
| 785 | }
|
---|
| 786 |
|
---|
| 787 | /*****************************************************************
|
---|
| 788 | * Method name: setEndNegReason()
|
---|
| 789 | * Goal: Set the end reason for the negotiatoin
|
---|
| 790 | * Input: String - end reason
|
---|
| 791 | * Output: None
|
---|
| 792 | ****************************************************************/
|
---|
| 793 | public void setEndNegReason(String sEndNegReason)
|
---|
| 794 | {
|
---|
| 795 | m_sEndNegReason = sEndNegReason;
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | /*****************************************************************
|
---|
| 799 | * Method name: getEndNegReason()
|
---|
| 800 | * Goal: Get the end reason for the negotiation
|
---|
| 801 | * Input: None.
|
---|
| 802 | * Output: String - end reason
|
---|
| 803 | ****************************************************************/
|
---|
| 804 | public String getEndNegReason()
|
---|
| 805 | {
|
---|
| 806 | return m_sEndNegReason;
|
---|
| 807 | }
|
---|
| 808 |
|
---|
| 809 | /*****************************************************************
|
---|
| 810 | * Method name: setOptOutNum()
|
---|
| 811 | * Goal: Set the number of opt outs during the negotiation
|
---|
| 812 | * Input: int - opt out number.
|
---|
| 813 | * Output: None
|
---|
| 814 | ****************************************************************/
|
---|
| 815 | public void setOptOutNum(int nOptOutNum)
|
---|
| 816 | {
|
---|
| 817 | m_nOptOutNum = nOptOutNum;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 | /*****************************************************************
|
---|
| 821 | * Method name: getOptOutNum()
|
---|
| 822 | * Goal: Get the number of opt out
|
---|
| 823 | * Input: None.
|
---|
| 824 | * Output: int - opt out number
|
---|
| 825 | ****************************************************************/
|
---|
| 826 | public int getOptOutNum()
|
---|
| 827 | {
|
---|
| 828 | return m_nOptOutNum;
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | /*****************************************************************
|
---|
| 832 | * Method name: incrementResponsesNum()
|
---|
| 833 | * Goal: Incremenet the number of responses made
|
---|
| 834 | * Input: None.
|
---|
| 835 | * Output: None.
|
---|
| 836 | ****************************************************************/
|
---|
| 837 | public void incrementResponsesNum()
|
---|
| 838 | {
|
---|
| 839 | m_nResponsesNum++;
|
---|
| 840 | }
|
---|
| 841 |
|
---|
| 842 | /*****************************************************************
|
---|
| 843 | * Method name: getResponsesNum()
|
---|
| 844 | * Goal: Get the number of responses made
|
---|
| 845 | * Input: None.
|
---|
| 846 | * Output: int - number of responses
|
---|
| 847 | ****************************************************************/
|
---|
| 848 | public int getResponsesNum()
|
---|
| 849 | {
|
---|
| 850 | return m_nResponsesNum++;
|
---|
| 851 | }
|
---|
| 852 |
|
---|
| 853 | /*****************************************************************
|
---|
| 854 | * Method name: incrementAcceptsNum()
|
---|
| 855 | * Goal: Increment the number of accpets made
|
---|
| 856 | * Input: None.
|
---|
| 857 | * Output: None.
|
---|
| 858 | ****************************************************************/
|
---|
| 859 | public void incrementAcceptsNum()
|
---|
| 860 | {
|
---|
| 861 | m_nAcceptsNum++;
|
---|
| 862 | }
|
---|
| 863 |
|
---|
| 864 | /*****************************************************************
|
---|
| 865 | * Method name: getAcceptsNum()
|
---|
| 866 | * Goal: Get the number of accpets made
|
---|
| 867 | * Input: None.
|
---|
| 868 | * Output: int - number of accepts
|
---|
| 869 | ****************************************************************/
|
---|
| 870 | public int getAcceptsNum()
|
---|
| 871 | {
|
---|
| 872 | return m_nAcceptsNum;
|
---|
| 873 | }
|
---|
| 874 |
|
---|
| 875 | /*****************************************************************
|
---|
| 876 | * Method name: incrementRejectionsNum()
|
---|
| 877 | * Goal: Increment the number of rejections made
|
---|
| 878 | * Input: None.
|
---|
| 879 | * Output: None.
|
---|
| 880 | ****************************************************************/
|
---|
| 881 | public void incrementRejectionsNum()
|
---|
| 882 | {
|
---|
| 883 | m_nRejectionsNum++;
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 | /*****************************************************************
|
---|
| 887 | * Method name: getRejectionsNum()
|
---|
| 888 | * Goal: Get the number of rejections made
|
---|
| 889 | * Input: None.
|
---|
| 890 | * Output: int - rejections num
|
---|
| 891 | ****************************************************************/
|
---|
| 892 | public int getRejectionsNum()
|
---|
| 893 | {
|
---|
| 894 | return m_nRejectionsNum;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
| 897 | /*****************************************************************
|
---|
| 898 | * Method name: incrementThreatsNum()
|
---|
| 899 | * Goal: Increment the number of threats made
|
---|
| 900 | * Input: None.
|
---|
| 901 | * Output: None.
|
---|
| 902 | ****************************************************************/
|
---|
| 903 | public void incrementThreatsNum()
|
---|
| 904 | {
|
---|
| 905 | m_nThreatsNum++;
|
---|
| 906 | }
|
---|
| 907 |
|
---|
| 908 | /*****************************************************************
|
---|
| 909 | * Method name: getThreatsNum()
|
---|
| 910 | * Goal: Get the number of threats made
|
---|
| 911 | * Input: None.
|
---|
| 912 | * Output: int - rejections num
|
---|
| 913 | ****************************************************************/
|
---|
| 914 | public int getThreatsNum()
|
---|
| 915 | {
|
---|
| 916 | return m_nThreatsNum;
|
---|
| 917 | }
|
---|
| 918 |
|
---|
| 919 | /*****************************************************************
|
---|
| 920 | * Method name: incrementCommentsNum()
|
---|
| 921 | * Goal: Increment the number of comments made
|
---|
| 922 | * Input: None.
|
---|
| 923 | * Output: None.
|
---|
| 924 | ****************************************************************/
|
---|
| 925 | public void incrementCommentsNum()
|
---|
| 926 | {
|
---|
| 927 | m_nCommentsNum++;
|
---|
| 928 | }
|
---|
| 929 |
|
---|
| 930 | /*****************************************************************
|
---|
| 931 | * Method name: getCommentsNum()
|
---|
| 932 | * Goal: Get the number of comments made
|
---|
| 933 | * Input: None.
|
---|
| 934 | * Output: int - comments number.
|
---|
| 935 | ****************************************************************/
|
---|
| 936 | public int getCommentsNum()
|
---|
| 937 | {
|
---|
| 938 | return m_nCommentsNum;
|
---|
| 939 | }
|
---|
| 940 |
|
---|
| 941 | /*****************************************************************
|
---|
| 942 | * Method name: incrementQueriesNum()
|
---|
| 943 | * Goal: Increment the number of queries made
|
---|
| 944 | * Input: None.
|
---|
| 945 | * Output: None.
|
---|
| 946 | ****************************************************************/
|
---|
| 947 | public void incrementQueriesNum()
|
---|
| 948 | {
|
---|
| 949 | m_nQueriesNum++;
|
---|
| 950 | }
|
---|
| 951 |
|
---|
| 952 | /*****************************************************************
|
---|
| 953 | * Method name: getQueriesNum()
|
---|
| 954 | * Goal: Get the number of queries made
|
---|
| 955 | * Input: None.
|
---|
| 956 | * Output: int - queries number.
|
---|
| 957 | ****************************************************************/
|
---|
| 958 | public int getQueriesNum()
|
---|
| 959 | {
|
---|
| 960 | return m_nQueriesNum;
|
---|
| 961 | }
|
---|
| 962 |
|
---|
| 963 | /*****************************************************************
|
---|
| 964 | * Method name: incrementOffersNum()
|
---|
| 965 | * Goal: Increment the number of offers made
|
---|
| 966 | * Input: None.
|
---|
| 967 | * Output: None.
|
---|
| 968 | ****************************************************************/
|
---|
| 969 | public void incrementOffersNum()
|
---|
| 970 | {
|
---|
| 971 | m_nOffersNum++;
|
---|
| 972 | }
|
---|
| 973 |
|
---|
| 974 | /*****************************************************************
|
---|
| 975 | * Method name: getOffersNum()
|
---|
| 976 | * Goal: Get the number of offers made
|
---|
| 977 | * Input: None.
|
---|
| 978 | * Output: int - offers number.
|
---|
| 979 | ****************************************************************/
|
---|
| 980 | public int getOffersNum()
|
---|
| 981 | {
|
---|
| 982 | return m_nOffersNum;
|
---|
| 983 | }
|
---|
| 984 |
|
---|
| 985 | /*****************************************************************
|
---|
| 986 | * Method name: incrementPromisesNum()
|
---|
| 987 | * Goal: Increment the number of promises made
|
---|
| 988 | * Input: None.
|
---|
| 989 | * Output: None.
|
---|
| 990 | ****************************************************************/
|
---|
| 991 | public void incrementPromisesNum()
|
---|
| 992 | {
|
---|
| 993 | m_nPromisesNum++;
|
---|
| 994 | }
|
---|
| 995 |
|
---|
| 996 | /*****************************************************************
|
---|
| 997 | * Method name: getPromisesNum()
|
---|
| 998 | * Goal: Get the number of promises made
|
---|
| 999 | * Input: None.
|
---|
| 1000 | * Output: int - offers promises.
|
---|
| 1001 | ****************************************************************/
|
---|
| 1002 | public int getPromisesNum()
|
---|
| 1003 | {
|
---|
| 1004 | return m_nPromisesNum;
|
---|
| 1005 | }
|
---|
| 1006 | }
|
---|