[1] | 1 | package agents.qoagent2;
|
---|
| 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 (Zimbabwe,
|
---|
| 11 | * England 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 | //DT: 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 (Zimbabwe,England,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 InetAddress m_ip = null; //Holds the ip address of the client
|
---|
| 33 | private int m_nPort;
|
---|
| 34 | private double m_dScore; //the agent's score of the negotiation
|
---|
| 35 | private double m_dTimeEffect; // time effect for the entire agreement
|
---|
| 36 | private double m_dOptOutValue; // opting out value
|
---|
| 37 | private double m_dStatusQuoValue; // status quo value
|
---|
| 38 |
|
---|
| 39 | //Agent's Details
|
---|
| 40 | private String m_sId; //Agent's Id
|
---|
| 41 | private String m_sName; //Agent's Name
|
---|
| 42 |
|
---|
| 43 | //Opponent's Details, in case that we are not a mediator
|
---|
| 44 | private String m_sOppId; //Opponent's Id
|
---|
| 45 | private String m_sOppName; //Opponent's Name
|
---|
| 46 |
|
---|
| 47 | //mediator Details, in case that we are not a mediator
|
---|
| 48 | private String m_sMedId; //mediator's Id
|
---|
| 49 | private String m_sMedName; //mediator's Name
|
---|
| 50 |
|
---|
| 51 | //The two sides in case that we are a mediator
|
---|
| 52 | private String m_sIdReligious,m_sIdSecular; //Ids
|
---|
| 53 | private String m_sNameReligious,m_sNameSecular; //Names
|
---|
| 54 |
|
---|
| 55 | public final static String TIME_EFFECT_STR = "Time-Effect";
|
---|
| 56 | public final static String OPT_OUT_STR = "Opt-Out";
|
---|
| 57 | public final static String STATUS_QUO_STR = "Status-Quo";
|
---|
| 58 |
|
---|
| 59 | private String m_sPrefDetails;
|
---|
| 60 |
|
---|
| 61 | private String m_sEndNegReason;
|
---|
| 62 | private int m_nOptOutNum;
|
---|
| 63 | private int m_nResponsesNum;
|
---|
| 64 | private int m_nAcceptsNum;
|
---|
| 65 | private int m_nRejectionsNum;
|
---|
| 66 | private int m_nCommentsNum;
|
---|
| 67 | private int m_nThreatsNum;
|
---|
| 68 | private int m_nOffersNum;
|
---|
| 69 | private int m_nPromisesNum;
|
---|
| 70 | private int m_nQueriesNum;
|
---|
| 71 | /*****************************************************************
|
---|
| 72 | * Method name: Agent()
|
---|
| 73 | * Goal: Constructor.
|
---|
| 74 | * Description: Initialize the class variables and reading the issues
|
---|
| 75 | * from the utility file.
|
---|
| 76 | * Input: A MultiServer object (to allow access to the server),
|
---|
| 77 | * a ServerThread object (to allow access to the agent's
|
---|
| 78 | * thread at the server), and a boolean which specifies whether
|
---|
| 79 | * the agent supports a mediator or not.
|
---|
| 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_sIdReligious=null;
|
---|
| 101 | m_sIdSecular=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: An integer(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: An integer(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: getOpponentName()
|
---|
| 265 | * Goal: Return the opponent's name.
|
---|
| 266 | * Input: None.
|
---|
| 267 | * Output: A string.
|
---|
| 268 | ***************************************************************/
|
---|
| 269 | public String getOpponentName()
|
---|
| 270 | {
|
---|
| 271 | return m_sOppName;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | /*****************************************************************
|
---|
| 275 | * Method name: getMedName()
|
---|
| 276 | * Goal: Return the mediator's name.
|
---|
| 277 | * Input: None.
|
---|
| 278 | * Output: A string.
|
---|
| 279 | ***************************************************************/
|
---|
| 280 | public String getMedName()
|
---|
| 281 | {
|
---|
| 282 | return m_sMedName;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | /*****************************************************************
|
---|
| 286 | * Method name: getNameReligious()
|
---|
| 287 | * Goal: Return the England side name (in case the agent is a mediator).
|
---|
| 288 | * Input: None.
|
---|
| 289 | * Output: A string.
|
---|
| 290 | ***************************************************************/
|
---|
| 291 | public String getNameReligious()
|
---|
| 292 | {
|
---|
| 293 | return m_sNameReligious;
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | /*****************************************************************
|
---|
| 297 | * Method name: getNameSecular()
|
---|
| 298 | * Goal: Return the Zimbabwe side name (in case the agent is a mediator).
|
---|
| 299 | * Input: None.
|
---|
| 300 | * Output: A string.
|
---|
| 301 | ***************************************************************/
|
---|
| 302 | public String getNameSecular()
|
---|
| 303 | {
|
---|
| 304 | return m_sNameSecular;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | /*****************************************************************
|
---|
| 308 | * Method name: setOpponentName()
|
---|
| 309 | * Goal: Setting the opponent's name.
|
---|
| 310 | * Input: A string.
|
---|
| 311 | * Output: None.
|
---|
| 312 | ****************************************************************/
|
---|
| 313 | public void setOpponentName(String sOppName)
|
---|
| 314 | {
|
---|
| 315 | m_sOppName = sOppName;
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | /*****************************************************************
|
---|
| 319 | * Method name: setMedName()
|
---|
| 320 | * Goal: Setting the mediator's name.
|
---|
| 321 | * Input: A string.
|
---|
| 322 | * Output: None.
|
---|
| 323 | ****************************************************************/
|
---|
| 324 | public void setMedName(String sMedName)
|
---|
| 325 | {
|
---|
| 326 | m_sMedName = sMedName;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | /*****************************************************************
|
---|
| 330 | * Method name: setNameReligious()
|
---|
| 331 | * Goal: Setting the England side name (in case the agent is a mediator).
|
---|
| 332 | * Input: A string.
|
---|
| 333 | * Output: None.
|
---|
| 334 | ****************************************************************/
|
---|
| 335 | public void setNameReligious(String sName)
|
---|
| 336 | {
|
---|
| 337 | m_sNameReligious = sName;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | /*****************************************************************
|
---|
| 341 | * Method name: setNameSecular()
|
---|
| 342 | * Goal: Setting the Zimbabwe side name (in case the agent is a mediator).
|
---|
| 343 | * Input: A string.
|
---|
| 344 | * Output: None.
|
---|
| 345 | ****************************************************************/
|
---|
| 346 | public void setNameSecular(String sName)
|
---|
| 347 | {
|
---|
| 348 | m_sNameSecular = sName;
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | /*****************************************************************
|
---|
| 352 | * Method name: setEndTurnNewGame()
|
---|
| 353 | * Goal: Restarting the end-turn stop watch.
|
---|
| 354 | * Input: None.
|
---|
| 355 | * Output: None.
|
---|
| 356 | ****************************************************************/
|
---|
| 357 | public void setEndTurnNewGame()
|
---|
| 358 | {
|
---|
| 359 | m_gtEndTurn.newGame();
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | /*****************************************************************
|
---|
| 363 | * Method name: setEndNegNewGame()
|
---|
| 364 | * Goal: Restarting the end-negotiation stop watch.
|
---|
| 365 | * Input: None.
|
---|
| 366 | * Output: None.
|
---|
| 367 | ****************************************************************/
|
---|
| 368 | public void setEndNegNewGame()
|
---|
| 369 | {
|
---|
| 370 | m_gtEndNeg.newGame();
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | /*****************************************************************
|
---|
| 374 | * Method name: getSide()
|
---|
| 375 | * Goal: Return the agent's side.
|
---|
| 376 | * Input: None.
|
---|
| 377 | * Output: None.
|
---|
| 378 | ***************************************************************/
|
---|
| 379 | public String getSide()
|
---|
| 380 | {
|
---|
| 381 | return m_sSide;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | /*****************************************************************
|
---|
| 385 | * Method name: setSide()
|
---|
| 386 | * Goal: Setting the agent's side.
|
---|
| 387 | * Input: A string.
|
---|
| 388 | * Output: None.
|
---|
| 389 | ****************************************************************/
|
---|
| 390 | public void setSide(String sSide)
|
---|
| 391 | {
|
---|
| 392 | m_sSide = sSide;
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 | /*****************************************************************
|
---|
| 396 | * Method name: setIp()
|
---|
| 397 | * Goal: Setting the agent's ip address.
|
---|
| 398 | * Input: An InetAddress object.
|
---|
| 399 | * Output: None.
|
---|
| 400 | ****************************************************************/
|
---|
| 401 | public void setIp(InetAddress ip)
|
---|
| 402 | {
|
---|
| 403 | m_ip = ip;
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | /*****************************************************************
|
---|
| 407 | * Method name: setIssueAt()
|
---|
| 408 | * Goal: Inserting an Issue to the issues vectors at a specified index.
|
---|
| 409 | * Input: An integer (the index) and an Issue.
|
---|
| 410 | * Output: None.
|
---|
| 411 | ****************************************************************/
|
---|
| 412 | public void setIssueAt(int index, Issue issue)
|
---|
| 413 | {
|
---|
| 414 | m_vecIssues.set(index, issue);
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | /*****************************************************************
|
---|
| 418 | * Method name: setEndNeg()
|
---|
| 419 | * Goal: Initializing the end-negotiation stop watch.
|
---|
| 420 | * Input: A boolean which specifies whether the stop watch counts up or not,
|
---|
| 421 | * three integers (hours, minutes and seconds), another boolean which
|
---|
| 422 | * specifies whether the stop watch is of type end-turn or end-negotiation,
|
---|
| 423 | * and another integer (number of turns in the negotiation).
|
---|
| 424 | * Output: None.
|
---|
| 425 | ****************************************************************/
|
---|
| 426 | public void setEndNeg(boolean bCountUp, int nHours, int nMinutes, int nSeconds, boolean bTurnOrNeg, int nMaxTurn)
|
---|
| 427 | {
|
---|
| 428 | m_gtEndNeg = new GameTimeServer(bCountUp,nHours,nMinutes,nSeconds,this,bTurnOrNeg,nMaxTurn /* DT: ,m_server,m_st*/ );
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | /*****************************************************************
|
---|
| 432 | * Method name: setEndNegRun()
|
---|
| 433 | * Goal: Stopping or continuing the end-negotiation stop watch.
|
---|
| 434 | * Input: A boolean which specifies whether the stop watch should
|
---|
| 435 | * stop (false) or continue (true).
|
---|
| 436 | * Output: None.
|
---|
| 437 | ****************************************************************/
|
---|
| 438 | public void setEndNegRun(boolean bRun)
|
---|
| 439 | {
|
---|
| 440 | m_gtEndNeg.setRun(bRun);
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | /*****************************************************************
|
---|
| 444 | * Method name: setEndTurn()
|
---|
| 445 | * Goal: Initializing the end-turn stop watch.
|
---|
| 446 | * Input: A boolean which specifies whether the stop watch counts up or not,
|
---|
| 447 | * three integers (hours, minutes and seconds), another boolean which
|
---|
| 448 | * specifies whether the stop watch is of type end-turn or end-negotiation,
|
---|
| 449 | * and another integer (number of turns in the negotiation).
|
---|
| 450 | * Output: None.
|
---|
| 451 | ****************************************************************/
|
---|
| 452 | public void setEndTurn(boolean bCountUp, int nHours, int nMinutes, int nSeconds, boolean bTurnOrNeg, int nMaxTurn)
|
---|
| 453 | {
|
---|
| 454 | m_gtEndTurn = new GameTimeServer(bCountUp,nHours,nMinutes,nSeconds,this,bTurnOrNeg,nMaxTurn/* DT: ,m_server,m_st */);
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 | /*****************************************************************
|
---|
| 458 | * Method name: setEndTurnRun()
|
---|
| 459 | * Goal: Stopping or continuing the end-turn stop watch.
|
---|
| 460 | * Input: A boolean which specifies whether the stop watch should
|
---|
| 461 | * stop (false) or continue (true).
|
---|
| 462 | * Output: None.
|
---|
| 463 | ****************************************************************/
|
---|
| 464 | public void setEndTurnRun(boolean bRun)
|
---|
| 465 | {
|
---|
| 466 | m_gtEndTurn.setRun(bRun);
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | /*****************************************************************
|
---|
| 470 | * Method name: getIssuesNum()
|
---|
| 471 | * Goal: Return the number of issues of the negotiation.
|
---|
| 472 | * Input: None.
|
---|
| 473 | * Output: An integer.
|
---|
| 474 | ***************************************************************/
|
---|
| 475 | public int getIssuesNum()
|
---|
| 476 | {
|
---|
| 477 | return m_vecIssues.size();
|
---|
| 478 | }
|
---|
| 479 |
|
---|
| 480 | /*****************************************************************
|
---|
| 481 | * Method name: getIssueAt()
|
---|
| 482 | * Goal: Return the issue at the specified index.
|
---|
| 483 | * Input: An integer (the index).
|
---|
| 484 | * Output: An Issue.
|
---|
| 485 | ***************************************************************/
|
---|
| 486 | public Issue getIssueAt(int index)
|
---|
| 487 | {
|
---|
| 488 | return (Issue)m_vecIssues.elementAt(index);
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | /*****************************************************************
|
---|
| 492 | * Method name: setPort()
|
---|
| 493 | * Goal: Setting the agent's port.
|
---|
| 494 | * Input: An integer (the port).
|
---|
| 495 | * Output: None.
|
---|
| 496 | ****************************************************************/
|
---|
| 497 | public void setPort(int nPort)
|
---|
| 498 | {
|
---|
| 499 | m_nPort = nPort;
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | /*****************************************************************
|
---|
| 503 | * Method name: getPort()
|
---|
| 504 | * Goal: Return the agent's port.
|
---|
| 505 | * Input: None.
|
---|
| 506 | * Output: An integer.
|
---|
| 507 | ***************************************************************/
|
---|
| 508 | public int getPort()
|
---|
| 509 | {
|
---|
| 510 | return m_nPort;
|
---|
| 511 | }
|
---|
| 512 |
|
---|
| 513 | /*****************************************************************
|
---|
| 514 | * Method name: setId()
|
---|
| 515 | * Goal: Setting the agent's ID.
|
---|
| 516 | * Input: A String.
|
---|
| 517 | * Output: None.
|
---|
| 518 | ****************************************************************/
|
---|
| 519 | public void setId(String sId)
|
---|
| 520 | {
|
---|
| 521 | m_sId = sId;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | /*****************************************************************
|
---|
| 525 | * Method name: getId()
|
---|
| 526 | * Goal: Return the agent's ID.
|
---|
| 527 | * Input: None.
|
---|
| 528 | * Output: A String.
|
---|
| 529 | ***************************************************************/
|
---|
| 530 | public String getId()
|
---|
| 531 | {
|
---|
| 532 | return m_sId;
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | /*****************************************************************
|
---|
| 536 | * Method name: getOpponentId()
|
---|
| 537 | * Goal: Return the opponent's ID.
|
---|
| 538 | * Input: None.
|
---|
| 539 | * Output: A String.
|
---|
| 540 | ***************************************************************/
|
---|
| 541 | public String getOpponentId()
|
---|
| 542 | {
|
---|
| 543 | return m_sOppId;
|
---|
| 544 | }
|
---|
| 545 |
|
---|
| 546 | /*****************************************************************
|
---|
| 547 | * Method name: getMedId()
|
---|
| 548 | * Goal: Return the mediator's ID.
|
---|
| 549 | * Input: None.
|
---|
| 550 | * Output: A String.
|
---|
| 551 | ***************************************************************/
|
---|
| 552 | public String getMedId()
|
---|
| 553 | {
|
---|
| 554 | return m_sMedId;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | /*****************************************************************
|
---|
| 558 | * Method name: getIdReligious()
|
---|
| 559 | * Goal: Return the England side ID (in case the agent is a mediator).
|
---|
| 560 | * Input: None.
|
---|
| 561 | * Output: A String.
|
---|
| 562 | ***************************************************************/
|
---|
| 563 | public String getIdReligious()
|
---|
| 564 | {
|
---|
| 565 | return m_sIdReligious;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | /*****************************************************************
|
---|
| 569 | * Method name: getIdSecular()
|
---|
| 570 | * Goal: Return the Zimbabwe side ID (in case the agent is a mediator).
|
---|
| 571 | * Input: None.
|
---|
| 572 | * Output: A String.
|
---|
| 573 | ***************************************************************/
|
---|
| 574 | public String getIdSecular()
|
---|
| 575 | {
|
---|
| 576 | return m_sIdSecular;
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 | /*****************************************************************
|
---|
| 580 | * Method name: setOpponentId()
|
---|
| 581 | * Goal: Setting the opponent's ID.
|
---|
| 582 | * Input: A String.
|
---|
| 583 | * Output: None.
|
---|
| 584 | ****************************************************************/
|
---|
| 585 | public void setOpponentId(String sOppId)
|
---|
| 586 | {
|
---|
| 587 | m_sOppId = sOppId;
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | /*****************************************************************
|
---|
| 591 | * Method name: setMedId()
|
---|
| 592 | * Goal: Setting the mediator's ID.
|
---|
| 593 | * Input: A String.
|
---|
| 594 | * Output: None.
|
---|
| 595 | ****************************************************************/
|
---|
| 596 | public void setMedId(String sMedId)
|
---|
| 597 | {
|
---|
| 598 | m_sMedId = sMedId;
|
---|
| 599 | }
|
---|
| 600 |
|
---|
| 601 | /*****************************************************************
|
---|
| 602 | * Method name: setIdReligious()
|
---|
| 603 | * Goal: Setting the England side ID (in case the agent is a mediator).
|
---|
| 604 | * Input: A String.
|
---|
| 605 | * Output: None.
|
---|
| 606 | ****************************************************************/
|
---|
| 607 | public void setIdReligious(String sId)
|
---|
| 608 | {
|
---|
| 609 | m_sIdReligious = sId;
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | /*****************************************************************
|
---|
| 613 | * Method name: setIdSecular()
|
---|
| 614 | * Goal: Setting the Zimbabwe side ID (in case the agent is a mediator).
|
---|
| 615 | * Input: A String.
|
---|
| 616 | * Output: None.
|
---|
| 617 | ****************************************************************/
|
---|
| 618 | public void setIdSecular(String sId)
|
---|
| 619 | {
|
---|
| 620 | m_sIdSecular = sId;
|
---|
| 621 | }
|
---|
| 622 |
|
---|
| 623 | /*****************************************************************
|
---|
| 624 | * Method name: setSocket()
|
---|
| 625 | * Goal: Setting the agent's socket and setting the PrintWriter to
|
---|
| 626 | * write to the socket.
|
---|
| 627 | * Input: A Socket object.
|
---|
| 628 | * Output: None.
|
---|
| 629 | ****************************************************************/
|
---|
| 630 | public void setSocket(Socket socket)
|
---|
| 631 | {
|
---|
| 632 | m_socket = socket;
|
---|
| 633 | try {
|
---|
| 634 | m_out = new PrintWriter(m_socket.getOutputStream(),true);
|
---|
| 635 | }
|
---|
| 636 | catch (IOException e)
|
---|
| 637 | {
|
---|
| 638 | System.out.println("ERROR----" + "[Agent " + m_sId + "] " + "Error opening socket: " + e.getMessage() + " [Agent::setSocket(614)]");
|
---|
| 639 | System.err.println("ERROR----" + "[Agent " + m_sId + "] " + "Error opening socket: " + e.getMessage() + " [Agent::setSocket(614)]");
|
---|
| 640 | }
|
---|
| 641 | }
|
---|
| 642 |
|
---|
| 643 | /*****************************************************************
|
---|
| 644 | * Method name: closeSocketStream()
|
---|
| 645 | * Goal: Closing the PrintWriter which writes to the agent's socket.
|
---|
| 646 | * Input: None.
|
---|
| 647 | * Output: None.
|
---|
| 648 | ****************************************************************/
|
---|
| 649 | public void closeSocketStream()
|
---|
| 650 | {
|
---|
| 651 | m_out.close();
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | /*****************************************************************
|
---|
| 655 | * Method name: getSocket()
|
---|
| 656 | * Goal: Return the agent's socket.
|
---|
| 657 | * Input: None.
|
---|
| 658 | * Output: A Socket object.
|
---|
| 659 | ***************************************************************/
|
---|
| 660 | public Socket getSocket()
|
---|
| 661 | {
|
---|
| 662 | return m_socket;
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | /*****************************************************************
|
---|
| 666 | * Method name: writeToSocket()
|
---|
| 667 | * Goal: Writing a message to the agent's socket.
|
---|
| 668 | * Input: A string (the message).
|
---|
| 669 | * Output: None.
|
---|
| 670 | ***************************************************************/
|
---|
| 671 | public void writeToSocket(String sMsg)
|
---|
| 672 | {
|
---|
| 673 | m_out.println(sMsg);
|
---|
| 674 | }
|
---|
| 675 |
|
---|
| 676 | /*****************************************************************
|
---|
| 677 | * Method name: incrementCurrentTurn()
|
---|
| 678 | * Goal: Incrementing the current turn of the negotiation.
|
---|
| 679 | * Input: None.
|
---|
| 680 | * Output: None.
|
---|
| 681 | ***************************************************************/
|
---|
| 682 | public void incrementCurrentTurn()
|
---|
| 683 | {
|
---|
| 684 | m_nCurrentTurn++;
|
---|
| 685 | }
|
---|
| 686 |
|
---|
| 687 | /*****************************************************************
|
---|
| 688 | * Method name: setCurrentTurn()
|
---|
| 689 | * Goal: Setting the current turn.
|
---|
| 690 | * Input: An integer.
|
---|
| 691 | * Output: None.
|
---|
| 692 | ****************************************************************/
|
---|
| 693 | public void setCurrentTurn(int nCurrentTurn)
|
---|
| 694 | {
|
---|
| 695 | m_nCurrentTurn = nCurrentTurn;
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | /*****************************************************************
|
---|
| 699 | * Method name: getCurrentTurn()
|
---|
| 700 | * Goal: Return the current turn.
|
---|
| 701 | * Input: None.
|
---|
| 702 | * Output: An integer.
|
---|
| 703 | ***************************************************************/
|
---|
| 704 | public int getCurrentTurn()
|
---|
| 705 | {
|
---|
| 706 | return m_nCurrentTurn;
|
---|
| 707 | }
|
---|
| 708 |
|
---|
| 709 | /*****************************************************************
|
---|
| 710 | * Method name: hasOpponent()
|
---|
| 711 | * Goal: Return a boolean which specifies whether the agent has an opponent.
|
---|
| 712 | * Input: None.
|
---|
| 713 | * Output: A boolean.
|
---|
| 714 | ***************************************************************/
|
---|
| 715 | public boolean hasOpponent()
|
---|
| 716 | {
|
---|
| 717 | return m_bHasOpponent;
|
---|
| 718 | }
|
---|
| 719 |
|
---|
| 720 | /*****************************************************************
|
---|
| 721 | * Method name: setHasOpponent()
|
---|
| 722 | * Goal: Setting whether the agent has an opponent.
|
---|
| 723 | * Input: A boolean.
|
---|
| 724 | * Output: None.
|
---|
| 725 | ****************************************************************/
|
---|
| 726 | public void setHasOpponent(boolean bHasOpponent)
|
---|
| 727 | {
|
---|
| 728 | m_bHasOpponent = bHasOpponent;
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | /*****************************************************************
|
---|
| 732 | * Method name: hasMediator()
|
---|
| 733 | * Goal: Return a boolean which specifies whether the agent has a mediator.
|
---|
| 734 | * Input: None.
|
---|
| 735 | * Output: A boolean.
|
---|
| 736 | ***************************************************************/
|
---|
| 737 | public boolean hasMediator()
|
---|
| 738 | {
|
---|
| 739 | return m_bHasMediator;
|
---|
| 740 | }
|
---|
| 741 |
|
---|
| 742 | /*****************************************************************
|
---|
| 743 | * Method name: setHasMediator()
|
---|
| 744 | * Goal: Setting whether the agent has a mediator.
|
---|
| 745 | * Input: A boolean.
|
---|
| 746 | * Output: None.
|
---|
| 747 | ****************************************************************/
|
---|
| 748 | public void setHasMediator(boolean bHasMediator)
|
---|
| 749 | {
|
---|
| 750 | m_bHasMediator = bHasMediator;
|
---|
| 751 | }
|
---|
| 752 |
|
---|
| 753 | /*****************************************************************
|
---|
| 754 | * Method name: supportMediator()
|
---|
| 755 | * Goal: Return a boolean which specifies whether the agent supports
|
---|
| 756 | * a mediator.
|
---|
| 757 | * Input: None.
|
---|
| 758 | * Output: A boolean.
|
---|
| 759 | ***************************************************************/
|
---|
| 760 | public boolean supportMediator()
|
---|
| 761 | {
|
---|
| 762 | return m_bSupportMediator;
|
---|
| 763 | }
|
---|
| 764 |
|
---|
| 765 | /*****************************************************************
|
---|
| 766 | * Method name: startEndNegThread()
|
---|
| 767 | * Goal: Starting the end-negotiation stop watch's thread.
|
---|
| 768 | * Input: None.
|
---|
| 769 | * Output: None.
|
---|
| 770 | ****************************************************************/
|
---|
| 771 | public void startEndNegThread()
|
---|
| 772 | {
|
---|
| 773 | new Thread(m_gtEndNeg).start();
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | /*****************************************************************
|
---|
| 777 | * Method name: startEndNegThread()
|
---|
| 778 | * Goal: Starting the end-turn stop watch's thread.
|
---|
| 779 | * Input: None.
|
---|
| 780 | * Output: None.
|
---|
| 781 | ****************************************************************/
|
---|
| 782 | public void startEndTurnThread()
|
---|
| 783 | {
|
---|
| 784 | new Thread(m_gtEndTurn).start();
|
---|
| 785 | }
|
---|
| 786 |
|
---|
| 787 | public void setPrefDetails(String sPrefDetails)
|
---|
| 788 | {
|
---|
| 789 | m_sPrefDetails = sPrefDetails;
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | public String getPrefDetails()
|
---|
| 793 | {
|
---|
| 794 | return m_sPrefDetails;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | public double getAgreementTimeEffect()
|
---|
| 798 | {
|
---|
| 799 | return m_dTimeEffect;
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 | public double getAgreementOptOutValue()
|
---|
| 803 | {
|
---|
| 804 | return m_dOptOutValue;
|
---|
| 805 | }
|
---|
| 806 |
|
---|
| 807 | public void setEndNegReason(String sEndNegReason)
|
---|
| 808 | {
|
---|
| 809 | m_sEndNegReason = sEndNegReason;
|
---|
| 810 | }
|
---|
| 811 |
|
---|
| 812 | public String getEndNegReason()
|
---|
| 813 | {
|
---|
| 814 | return m_sEndNegReason;
|
---|
| 815 | }
|
---|
| 816 |
|
---|
| 817 | public void setOptOutNum(int nOptOutNum)
|
---|
| 818 | {
|
---|
| 819 | m_nOptOutNum = nOptOutNum;
|
---|
| 820 | }
|
---|
| 821 |
|
---|
| 822 | public int getOptOutNum()
|
---|
| 823 | {
|
---|
| 824 | return m_nOptOutNum;
|
---|
| 825 | }
|
---|
| 826 |
|
---|
| 827 | public void incrementResponsesNum()
|
---|
| 828 | {
|
---|
| 829 | m_nResponsesNum++;
|
---|
| 830 | }
|
---|
| 831 |
|
---|
| 832 | public int getResponsesNum()
|
---|
| 833 | {
|
---|
| 834 | return m_nResponsesNum++;
|
---|
| 835 | }
|
---|
| 836 |
|
---|
| 837 | public void incrementAcceptsNum()
|
---|
| 838 | {
|
---|
| 839 | m_nAcceptsNum++;
|
---|
| 840 | }
|
---|
| 841 |
|
---|
| 842 | public int getAcceptsNum()
|
---|
| 843 | {
|
---|
| 844 | return m_nAcceptsNum;
|
---|
| 845 | }
|
---|
| 846 |
|
---|
| 847 | public void incrementRejectionsNum()
|
---|
| 848 | {
|
---|
| 849 | m_nRejectionsNum++;
|
---|
| 850 | }
|
---|
| 851 |
|
---|
| 852 | public int getRejectionsNum()
|
---|
| 853 | {
|
---|
| 854 | return m_nRejectionsNum;
|
---|
| 855 | }
|
---|
| 856 |
|
---|
| 857 | public void incrementThreatsNum()
|
---|
| 858 | {
|
---|
| 859 | m_nThreatsNum++;
|
---|
| 860 | }
|
---|
| 861 |
|
---|
| 862 | public int getThreatsNum()
|
---|
| 863 | {
|
---|
| 864 | return m_nThreatsNum;
|
---|
| 865 | }
|
---|
| 866 |
|
---|
| 867 | public void incrementCommentsNum()
|
---|
| 868 | {
|
---|
| 869 | m_nCommentsNum++;
|
---|
| 870 | }
|
---|
| 871 |
|
---|
| 872 | public int getCommentsNum()
|
---|
| 873 | {
|
---|
| 874 | return m_nCommentsNum;
|
---|
| 875 | }
|
---|
| 876 |
|
---|
| 877 | public void incrementQueriesNum()
|
---|
| 878 | {
|
---|
| 879 | m_nQueriesNum++;
|
---|
| 880 | }
|
---|
| 881 |
|
---|
| 882 | public int getQueriesNum()
|
---|
| 883 | {
|
---|
| 884 | return m_nQueriesNum;
|
---|
| 885 | }
|
---|
| 886 |
|
---|
| 887 | public void incrementOffersNum()
|
---|
| 888 | {
|
---|
| 889 | m_nOffersNum++;
|
---|
| 890 | }
|
---|
| 891 |
|
---|
| 892 | public int getOffersNum()
|
---|
| 893 | {
|
---|
| 894 | return m_nOffersNum;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
| 897 | public void incrementPromisesNum()
|
---|
| 898 | {
|
---|
| 899 | m_nPromisesNum++;
|
---|
| 900 | }
|
---|
| 901 |
|
---|
| 902 | public int getPromisesNum()
|
---|
| 903 | {
|
---|
| 904 | return m_nPromisesNum;
|
---|
| 905 | }
|
---|
| 906 | }
|
---|