gpt4 book ai didi

java - 为什么注册代理会返回此错误 : FIPAAgentManagement. MissingParameter?

转载 作者:行者123 更新时间:2023-11-30 03:41:49 27 4
gpt4 key购买 nike

我想注册几个代理。

为此,我使用以下代码

类(class)

public class Main {

public static void main(String[] args) {
String[] services = {"-gui"};
Boot.main(services);
Agent1 = new Agent1(0,0,"a");
}

}

public class Agent1 extends Agent{

public Agent1(int x, int y, String name) {
super(x, y, name);
setup();
}

protected void setup(){
System.out.println("hi");
ServiceDescription sd = new ServiceDescription();
sd.setType( "buyer" );
sd.setName( "asa" );
register( sd );
}

void register( ServiceDescription sd){
DFAgentDescription dfd = new DFAgentDescription();
dfd.setName(getAID());
dfd.addServices(sd);

try {
DFService.register(this, dfd );
}
catch (FIPAException fe) { fe.printStackTrace(); }

}

protected void takeDown(){
System.out.println("bye");
}

}

但我收到以下错误:

jade.domain.FIPAAgentManagement.MissingParameter: (missing-parameter df-agent-description name)

如何修复该错误?

谢谢

最佳答案

您没有正确创建代理。 getAID() 将返回 null,并且 DFAgentDescription 变得无效。

您应该将 -agents 传递给 jade.Boot,它将为您创建代理。

public static void main(String[] args) {
// the agent's name is agent1, change xy.zy to your package
String[] services = {"-gui", "-agents", "agent1:xy.zy.Agent1"};
Boot.main(services);
}

您不需要 Agent1 = new Agent1(0,0,"a"); 并且您不需要 Agent1 中的构造函数。 setup() 方法会自动调用。

关于java - 为什么注册代理会返回此错误 : FIPAAgentManagement. MissingParameter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26695358/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com