⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clearedpathmessage.java

📁 2004年robotcup世界冠军源代码
💻 JAVA
字号:
package MRL.Utilities.MessageManagement;

import yab.agent.DisasterSpace;
import yab.agent.Condition;
import yab.agent.object.*;

import java.util.*;

import MRL.Utilities.Partitioning.Partition;
import MRL.Utilities.Partitioning.Path;
import MRL.Police.EPoliceForce;

/**
 * Message Manager for SBCe_Saviour 2006
 * by Maryam Kalantary
 *
 **/
public class ClearedPathMessage extends Message
{
    int pathIndex;
    static final int pathIndexSize = 14;

    public ClearedPathMessage(int pathIndex)
    {
        super(Type.CLEAREDPATH_REPORT, null);
        this.pathIndex = pathIndex;
    }

    char[] toCharArray(Map ids)
    {
        char[] result = new char[length()];

        char[] temp = Util.intToCharArray(pathIndex, pathIndexSize);
        Util.copyArray(temp, result, 0, 0, pathIndexSize);

        return result;
    }

    protected int length()
    {
        return staticLength();
    }

    protected static int staticLength()
    {
        return pathIndexSize;
    }

    public boolean equals(Object m)
    {
        if (!(m instanceof ClearedPathMessage)) return false;
        return ((ClearedPathMessage) m).pathIndex == pathIndex;
    }

    public int hashCode()
    {
        return pathIndex;
    }


    void updateWorld(DisasterSpace world, int time)
    {
        if (world.self instanceof PoliceForce)
        {
            EPoliceForce me = (EPoliceForce)world.self;
            Path path = (Path) world.paths.get(pathIndex);
//            me.validRouteBldgs.addAll(REFUGE_C.extract(path.getConnectedBuildings()));
            me.reportedBlockades.remove(path);
            me.reportedBlockadesIP.remove(path);
            world.setPathCleared(path,time);
            me.openPathBuildings.addAll(path.getConnectedBuildings());
        }
    }

    public ClearedPathMessage(char[] message)
    {
        super(Type.CLEAREDPATH_REPORT, null);
        this.pathIndex = Util.charArrayToint(message, 0, pathIndexSize);
    }

    static final Condition REFUGE_C = new Condition() {
    public boolean eval(Object obj) {
      return (obj instanceof Refuge);
    }
  };
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -