student
Class MyMedic

java.lang.Object
  extended by jade.core.Agent
      extended by es.upv.dsic.gti_ia.jgomas.CJGomasAgent
          extended by es.upv.dsic.gti_ia.jgomas.CBasicTroop
              extended by es.upv.dsic.gti_ia.jgomas.CTroop
                  extended by es.upv.dsic.gti_ia.jgomas.CMedic
                      extended by student.MyMedic
All Implemented Interfaces:
jade.core.TimerListener, java.io.Serializable, java.lang.Runnable

public class MyMedic
extends es.upv.dsic.gti_ia.jgomas.CMedic

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.Agent
jade.core.Agent.Interrupted
 
Field Summary
 
Fields inherited from class es.upv.dsic.gti_ia.jgomas.CMedic
m_iPacksDelivered
 
Fields inherited from class es.upv.dsic.gti_ia.jgomas.CBasicTroop
ARG_TEAM, CLASS_ENGINEER, CLASS_FIELDOPS, CLASS_MEDIC, CLASS_NONE, CLASS_SOLDIER, m_AimedAgent, m_AStarPath, m_bEscaping, m_bFighting, m_bObjectiveCarried, m_ControlPoints, m_CurrentTask, m_eClass, m_eTeam, m_FOVObjects, m_iAStarPathIndex, m_iControlPointsIndex, m_iEngineersCount, m_iFieldOpsCount, m_iMedicsCount, m_iSoldiersCount, m_iTeamCount, m_Manager, m_Map, m_Movement, m_sAmmoService, m_sBackupService, m_sMedicService, m_TaskList, m_TaskPriority, m_Threshold, MV_CANNOT_GET_POSITION, MV_NOT_MOVED_BY_TIME, MV_OK, TEAM_ALLIED, TEAM_AXIS, TEAM_NONE, TRANSITION_DEFAULT, TRANSITION_TO_FIGHTING, TRANSITION_TO_GOTO_TARGET, TRANSITION_TO_STANDING, TRANSITION_TO_TARGET_REACHED
 
Fields inherited from class es.upv.dsic.gti_ia.jgomas.CJGomasAgent
m_ID, m_ServiceList
 
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN
 
Constructor Summary
MyMedic()
           
 
Method Summary
protected  void CallForAmmo()
          Request for ammunition.
protected  void CallForBackup()
          Request for backup.
protected  void CallForMedic()
          Request for medicine.
protected  boolean checkMedicAction(java.lang.String _sContent)
          Decides if agent accepts the CFM request This method is a decision function invoked when a CALL FOR MEDIC request has arrived.
protected  void CreateControlPoints()
          Calculates an array of positions for patrolling.
protected  void GenerateEscapePosition()
          Calculates a new destiny position to escape.
protected  boolean GeneratePath()
          Calculates a new destiny position to walk.
protected  boolean GetAgentToAim()
          Calculates if there is an enemy at sight.
protected  void ObjectivePackTaken()
          The agent has got the objective pack.
protected  void PerformInjuryAction()
          Action to do when an agent is being shot.
protected  void PerformLookAction()
          Action to do when the agent is looking at.
protected  void PerformNoAmmoAction()
          Action to do if this agent cannot shoot.
protected  void PerformTargetReached(es.upv.dsic.gti_ia.jgomas.CTask _CurrentTask)
          Action to do when this agent reaches the target of current task.
protected  void PerformThresholdAction()
          Action to do when ammo or health values exceed the threshold allowed.
protected  void setup()
           
protected  void SetUpPriorities()
          Definition of priorities for each kind of task.
protected  boolean ShouldUpdateTargets()
          Should we update now all 'prepared (to execute)' tasks?
protected  void UpdateTargets()
          Update priority of all 'prepared (to execute)' tasks.
 
Methods inherited from class es.upv.dsic.gti_ia.jgomas.CMedic
CreateMedicPack
 
Methods inherited from class es.upv.dsic.gti_ia.jgomas.CTroop
takeDown
 
Methods inherited from class es.upv.dsic.gti_ia.jgomas.CBasicTroop
AddServiceType, AddTask, AddTask, CheckStaticPosition, CheckStaticPosition, GetAmmo, GetHealth, GetPower, GetStamina, HaveAgentToShot, Look, Move, PerformAimAction, Shot, UsePower, UseStamina
 
Methods inherited from class es.upv.dsic.gti_ia.jgomas.CJGomasAgent
AddService
 
Methods inherited from class jade.core.Agent
addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, getState, here, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restartLater, restore, restoreBufferedState, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setQueueSize, waitUntilStarted, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyMedic

public MyMedic()
Method Detail

setup

protected void setup()
Overrides:
setup in class es.upv.dsic.gti_ia.jgomas.CMedic

CallForMedic

protected void CallForMedic()
Request for medicine. This method sends a FIPA REQUEST message to all agents who offers the m_sMedicService service. The content of message is: ( x , y , z ) ( health ) . Variable m_iMedicsCount is updated. It's very useful to overload this method.

Overrides:
CallForMedic in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

CallForAmmo

protected void CallForAmmo()
Request for ammunition. This method sends a FIPA REQUEST message to all agents who offers the m_sAmmoService service. The content of message is: ( x , y , z ) ( ammo ) . Variable m_iFieldOpsCount is updated. It's very useful to overload this method.

Overrides:
CallForAmmo in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

CallForBackup

protected void CallForBackup()
Request for backup. This method sends a FIPA REQUEST message to all agents who offers the m_sBackupService service. The content of message is: ( x , y , z ) ( SoldiersCount ) . Variable m_iSoldiersCount is updated. It's very useful to overload this method.

Overrides:
CallForBackup in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

UpdateTargets

protected void UpdateTargets()
Update priority of all 'prepared (to execute)' tasks. This method is invoked in the state STANDING, and it's used to re-calculate the priority of all tasks (targets) int the task list of the agent. The reason is because JGOMAS Kernel always execute the maximum priority task. It's very useful to overload this method.

Overrides:
UpdateTargets in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

ShouldUpdateTargets

protected boolean ShouldUpdateTargets()
Should we update now all 'prepared (to execute)' tasks? This method is a decision function invoked in the state GOTO_TARGET. A value of TRUE break out the inner loop, making possible to JGOMAS Kernel extract a more priority task, or update some attributes of the current task. By default, the return value is FALSE, so we execute the current task until it finalizes. It's very useful to overload this method.

Overrides:
ShouldUpdateTargets in class es.upv.dsic.gti_ia.jgomas.CBasicTroop
Returns:
FALSE

ObjectivePackTaken

protected void ObjectivePackTaken()
The agent has got the objective pack. This method is called when this agent walks on the objective pack, getting it. It's very useful to overload this method.

Overrides:
ObjectivePackTaken in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

SetUpPriorities

protected void SetUpPriorities()
Definition of priorities for each kind of task. This method can be implemented in CTroop's derived classes to define the task's priorities in agreement to the role of the new class. Priorities must be defined in the array m_TaskPriority. It's very useful to overload this method.

Overrides:
SetUpPriorities in class es.upv.dsic.gti_ia.jgomas.CMedic

PerformNoAmmoAction

protected void PerformNoAmmoAction()
Action to do if this agent cannot shoot. This method is called when the agent try to shoot, but has no ammo. The agent will spit enemies out. :-) It's very useful to overload this method.

Overrides:
PerformNoAmmoAction in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

GenerateEscapePosition

protected void GenerateEscapePosition()
Calculates a new destiny position to escape. This method is called before the agent creates a task for escaping. It generates a valid random point in a radius of 50 units. Once position is calculated, agent updates its destiny to the new position, and automatically calculates the new direction. It's very useful to overload this method.

Overrides:
GenerateEscapePosition in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

GeneratePath

protected boolean GeneratePath()
Calculates a new destiny position to walk. This method is called before the agent creates a TASK_GOTO_POSITION task. It will try (for 5 attempts) to generate a valid random point in a radius of 20 units. If it doesn't generate a valid position in this cycle, it will try it in next cycle. Once a position is calculated, agent updates its destination to the new position, and automatically calculates the new direction. It's very useful to overload this method.

Overrides:
GeneratePath in class es.upv.dsic.gti_ia.jgomas.CBasicTroop
Returns:
TRUE: valid position generated / FALSE cannot generate a valid position

CreateControlPoints

protected void CreateControlPoints()
Calculates an array of positions for patrolling. When this method is called, it creates an array of n random positions. For medics and fieldops, the rank of n is [1..1]. For soldiers, the rank of n is [5..10]. It's very useful to overload this method.

Overrides:
CreateControlPoints in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

PerformInjuryAction

protected void PerformInjuryAction()
Action to do when an agent is being shot. This method is called every time this agent receives a messager from agent Manager informing it is being shot. It's very useful to overload this method.

Overrides:
PerformInjuryAction in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

PerformThresholdAction

protected void PerformThresholdAction()
Action to do when ammo or health values exceed the threshold allowed. This method is called when current values of ammo and health exceed the threshold allowed. These values are checked by Launch_MedicAmmo_RequestBehaviour behaviour, every ten seconds. Perhaps it is convenient to create a TASK_RUN_AWAY task. It's very useful to overload this method.

Overrides:
PerformThresholdAction in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

GetAgentToAim

protected boolean GetAgentToAim()
Calculates if there is an enemy at sight. This method scans the list m_FOVObjects (objects in the Field Of View of the agent) looking for an enemy. If an enemy agent is found, a value of TRUE is returned and variable m_AimedAgent is updated. Note that there is no criterion (proximity, etc.) for the enemy found. Otherwise, the return value is FALSE. It's very useful to overload this method.

Overrides:
GetAgentToAim in class es.upv.dsic.gti_ia.jgomas.CBasicTroop
Returns:
TRUE: enemy found / FALSE enemy not found

PerformLookAction

protected void PerformLookAction()
Action to do when the agent is looking at. This method is called just after Look method has ended. It's very useful to overload this method.

Overrides:
PerformLookAction in class es.upv.dsic.gti_ia.jgomas.CBasicTroop

checkMedicAction

protected boolean checkMedicAction(java.lang.String _sContent)
Decides if agent accepts the CFM request This method is a decision function invoked when a CALL FOR MEDIC request has arrived. Parameter sContent is the content of message received in CFM responder behaviour as result of a CallForMedic request, so it must be: ( x , y , z ) ( health ) . By default, the return value is TRUE, so agents always accept all CFM requests. It's very useful to overload this method.

Overrides:
checkMedicAction in class es.upv.dsic.gti_ia.jgomas.CMedic
Parameters:
_sContent -
Returns:
TRUE

PerformTargetReached

protected void PerformTargetReached(es.upv.dsic.gti_ia.jgomas.CTask _CurrentTask)
Action to do when this agent reaches the target of current task. This method is called when this agent goes to state TARGET_REACHED. If current task is TASK_GIVE_MEDICPAKS, agent must give medic packs, but in other case, it calls to parent's method. It's very useful to overload this method.

Overrides:
PerformTargetReached in class es.upv.dsic.gti_ia.jgomas.CMedic
Parameters:
_CurrentTask -