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

📄 partitionfinishedmessage.java

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

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

import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;

import MRL.Utilities.Partitioning.Partition;

//saeed 85-2-3
public class PartitionFinishedMessage extends Message
{
    int index;
    static final int indexSize = 6;

    public PartitionFinishedMessage(int index)
    {
        super(Type.PARTITIONFINISHED_REPORT, null);
        this.index = index;
    }

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

        char[] temp = Util.intToCharArray(index, indexSize);
        Util.copyArray(temp, result, 0, 0, indexSize);

        return result;
    }

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

    protected static int staticLength()
    {
        return indexSize;
    }

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

    public int hashCode()
    {
        return index;
    }


    void updateWorld(DisasterSpace world, int time)
    {
        if (world.self instanceof PoliceOffice)
        {
            Collections.sort(world.policeForces, yab.agent.Util.idComparator);
            Humanoid agent = (Humanoid) world.policeForces.get(index);
            //TODO:
              /*
            if(!(agent instanceof PoliceForce)) return;
            int nPartID = getNewPartIDUsingUnSearchedParts(index);
            if(nPartID == -1){
              nPartID =getNewPartIDUsingPolicePopulation(index);
            }
            if (nPartID != -1) {
              Partition partition = world.partitioner.getPartition(nPartID);
              world.messagepool.SetPartition((PoliceForce)agent,partition);
            }
            */
        }
    }

    public PartitionFinishedMessage(char[] message)
    {
        super(Type.PARTITIONFINISHED_REPORT, null);
        this.index = Util.charArrayToint(message, 0, indexSize);
    }
}

⌨️ 快捷键说明

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