概述
-
class CommunicationMessage //通信
主要内容:
private boolean isRadio;//是否为无线电
abstract public int getByteArraySize();//获得信息大小
abstract public byte[] toByteArray();//将信息转换成字节,并存到字节数组中
abstract public BitOutputStream toBitOutputStream();//输出流?
abstract public String getCheckKey();//获得检查钥匙?
-
class StandardMessage extends CommunicationMessage //消息标准
涉及的主要单词:
priority:优先权,优先
主要内容:
优先权的三种状态:LOW低 NORMAL普通 HIGH高
int rawSenderID = -1;//记录发送智能体的ID
EntityID mySenderID;//发送消息的智能体
int ttl = -1;//?
StandardMessagePriority sendingPriority = StandardMessagePriority.NORMAL;//消息的优先
public StandardMessage(boolean isRadio, StandardMessagePriority sendingPriority)
public StandardMessage(boolean isRadio, int senderID, int ttl, adf.component.communication.util.BitStreamReader bsr) //两种构造方式
public EntityID getSenderID() //获得发送信息的智能体的ID
public int getTTL() //获得TTL
public StandardMessagePriority getSendingPriority()//获得消息的优先权
protected int getBitSize(int value) //获得信息大小
-
class CommandAmbulance extends StandardMessage//医护人员控制
涉及的主要英文单词:
target:目标,靶子
command:控制
raw:生的,未处理的
主要内容:
public static final int ACTION_REST = 0;//休息
public static final int ACTION_MOVE = 1;//移动
public static final int ACTION_RESCUE = 2;//救援
public static final int ACTION_LOAD = 3;//负重
public static final int ACTION_UNLOAD = 4;//卸载
public static final int ACTION_AUTONOMY = 5;//自治
private static final int SIZE_TO = 32;
private static final int SIZE_TARGET = 32;
private static final int SIZE_ACTION = 4;
protected int rawToID;
protected int rawTargetID;
protected EntityID commandToID;
protected EntityID commandTargetID;
protected int myAction;//行为的代号
protected boolean broadcast;//广播?
public CommandAmbulance(boolean isRadio, @Nullable EntityID toID, @Nullable EntityID targetID, int action)
public CommandAmbulance(boolean isRadio, StandardMessagePriority sendingPriority, @Nullable EntityID toID, @Nullable EntityID targetID, int action)
public CommandAmbulance(boolean isRadio, int from, int ttl, @Nonnull BitStreamReader bitStreamReader)//三种构造方式
public int getAction() //获得当前行为
public int getByteArraySize() //获得消息对应的字节数组的大小
public byte[] toByteArray() //将消息转换成字节数组
public BitOutputStream toBitOutputStream() //消息输出,to与target的区别?
public EntityID getToID() //获得ToID
public EntityID getTargetID() //获得TargetID
public boolean isBroadcast() //判断当前是否负重
public boolean isToIDDefined() //判断ToID是否使用过
public boolean isTargetIDDefined() //判断TargetID是否使用过
public String getCheckKey() //以字符串返回当前智能体当前的ToID TargetID action
-
class CommandFire extends StandardMessage//消防人员控制
涉及主要的英文单词:
extinguish:熄灭
refill:重新充满
主要内容:
public static final int ACTION_REST = 0;//休息
public static final int ACTION_MOVE = 1;//移动
public static final int ACTION_EXTINGUISH = 2;//灭火
public static final int ACTION_REFILL = 3;//补水
public static final int ACTION_AUTONOMY = 4;//自治
以上部分为此类与其他类相比较,存在不同之处,其他方法与变量均一样
-
class CommandPolice extends StandardMessage//警察控制
public static final int ACTION_REST = 0;//休息
public static final int ACTION_MOVE = 1;//移动
public static final int ACTION_CLEAR = 2;//清障
public static final int ACTION_AUTONOMY = 3;//自治
以上部分为此类与其他类相比较,存在不同之处,其他方法与变量均一样
-
class CommandScout extends StandardMessage//搜索控制
private static final int SIZE_RANGE = 32;//范围大小
protected int scoutRange;//搜索范围
以上部分为此类与其他类相比较,存在不同之处,其他方法与变量均一样
-
Command类汇总
Command类即控制类中有Ambulance(医护人员) Police(警察) Fire(消防人员) Scout(搜索)四个类,其内容主要是针对世界中的消息,通过处理消息得到智能体的行为和目标,其中
private static final int SIZE_TO = 32;
private static final int SIZE_TARGET = 32;
private static final int SIZE_ACTION = 4;
protected int rawToID;//
protected int rawTargetID;
protected EntityID commandToID;
protected EntityID commandTargetID;
protected int myAction;
上述四类都有,不过我对其含义不理解
-
class MessageAmbulanceTeam extends StandardMessage//关于医护人员的消息
涉及的主要英文单词:
buried:埋葬的
damage:损毁
主要内容:
//主要参数
public static final int ACTION_REST = 0;//休息
public static final int ACTION_MOVE = 1;//移动
public static final int ACTION_RESCUE = 2;//救援
public static final int ACTION_LOAD = 3;//装载
public static final int ACTION_UNLOAD = 4;//卸载
private static final int SIZE_ID = 32;
private static final int SIZE_HP = 14;//HP
private static final int SIZE_BURIEDNESS = 13;//埋葬?
private static final int SIZE_DAMAGE = 14;//损毁
private static final int SIZE_POSITION = 32;//位置
private static final int SIZE_TARGET = 32;//
private static final int SIZE_ACTION = 4;
protected int rawAgentID;
protected EntityID agentID;
protected Integer rawHumanPosition;
protected Integer humanHP;//智能体的健康指数之一
protected Integer humanBuriedness;//智能体的健康指数之一
protected Integer humanDamage;//智能体的健康指数之一,损毁值
protected EntityID humanPosition;//智能体位置
protected Integer rawTargetID;
protected EntityID myTargetID;
protected int myAction;
//主要方法
public MessageAmbulanceTeam(boolean isRadio, @Nonnull AmbulanceTeam ambulanceTeam, int action, @Nullable EntityID target) //构造方法
public MessageAmbulanceTeam(boolean isRadio, StandardMessagePriority sendingPriority, @Nonnull AmbulanceTeam ambulanceTeam, int action, @Nullable EntityID target)
public MessageAmbulanceTeam(boolean isRadio, int from, int ttl, @Nonnull BitStreamReader bitStreamReader)//通过消息内容来改变智能体属性
public EntityID getAgentID() //获得智能体ID
public int getAction()//获得当前行为
public EntityID getTargetID() //获得目标ID
public int getByteArraySize()//获得消息字节数组的大小
public byte[] toByteArray()//转换成字节数组
public BitOutputStream toBitOutputStream()//消息输出
public int getHP() //获得HP
public int getBuriedness()//获得Buriedness参数
public int getDamage()//获得损毁值
public EntityID getPosition()//获得位置
public boolean isTargetDefined() //判断是否有目标
public boolean isHPDefined()//判断是否有HP
public boolean isBuriednessDefined()//对Buriedness是否有效进行判断
public boolean isDamageDefined() //对损毁值是否有效进行判断
public boolean isPositionDefined() //对位置是否有效进行判断
public String getCheckKey()
-
class MessageBuilding extends StandardMessage//建筑物通信
涉及主要英文单词:
broken:破坏
fiery:炽热的
temperature:温度
主要内容:
private static final int SIZE_ID = 32;
private static final int SIZE_BROKENNESS = 32;
private static final int SIZE_FIERYNESS = 32;
private static final int SIZE_TEMPERATURE = 32;
protected int rawBuildingID;
protected EntityID buildingID;
protected int buildingBrokenness;//破坏值
protected int buildingFieryness;//燃烧值
protected int buildingTemperature;//温度
-
class MessageCivilian extends StandardMessage//普通群众通信
主要内容:
跟前面的医护人员通信一样,只不过没有了医护人员的几种行为参数。
-
class MessageDummy extends StandardMessage//虚拟通信
final private int SIZE_TEST = 32;
private int dummyTest;//虚拟测试
-
class MessageFireBrigade extends StandardMessage//消防队通信
跟MessageAmbulanceTeam类相比:
没有了:
ACTION_RESCUE //救援
ACTION_LOAD //装载
ACTION_UNLOAD = 4//卸载
多了:
private static final int SIZE_WATER = 32;
public static final int ACTION_EXTINGUISH = 2;//灭火
public static final int ACTION_REFILL = 3;//补水
protected int fireBrigadeWater;//水量
-
class MessagePoliceForce extends StandardMessage//警察通信
//多了一个清障行为
public static final int ACTION_CLEAR = 2;//清障
-
class MessageReport extends StandardMessage
private static final int SIZE_DONE = 1;
private static final int SIZE_BROADCAST = 1;
private static final int SIZE_FROM = 32;
private boolean reportDone;//消息是否传达完成
private boolean reportBroadcast;//是否是无线电传达
private EntityID reportFromID;//接收消息智能体
private int rawReportFromID;//
-
class MessageRoad extends StandardMessage//道路通信
涉及主要英文单词:
passable:能通过的
blockade:堵塞
主要内容:
private static final int SIZE_ROADID = 32;
private static final int SIZE_BLOCKADEID = 32;
private static final int SIZE_COST = 32;
private static final int SIZE_PASSABLE = 1;
private static final int SIZE_X = 32;
private static final int SIZE_Y = 32;
protected int rawRoadID;
protected int rawBlockadeID;
protected EntityID roadID;//道路位置
protected EntityID roadBlockadeID;//被堵道路位置
protected int blockadeRepairCost;//被堵道路清障需要花费的时间
protected Boolean roadPassable;//道路是否能通过
protected Integer blockadeX;//被堵位置横坐标
protected Integer blockadeY;//被堵位置纵坐标
protected boolean isSendBlockadeLocation;
-
Message类汇总
Message类里面包括了MessageAmbulanceTeam(医护队通信) MessageBuilding(建筑物通信) MessageCivilian(普通群众通信) MessageDummy(虚拟通信) MessageFireBrigade(消防队通信) MessagePoliceForce(警察通信) MessageReport(?) MessageRoad(道路通信),
最后
以上就是开朗小天鹅为你收集整理的Class CommunicationMessage及它的子类简介class CommunicationMessage //通信的全部内容,希望文章能够帮你解决Class CommunicationMessage及它的子类简介class CommunicationMessage //通信所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复