gpt4 book ai didi

java - 读取导入包的内容

转载 作者:行者123 更新时间:2023-12-01 12:56:07 25 4
gpt4 key购买 nike

我正在致力于使用 Java 为游戏创建计算机控制的机器人。我有一个示例机器人程序,我目前正在理解这一点。

我无法理解下面代码中@JProp 的含义。谁可以帮我这个事。另外,如何在程序启动时查看导入文件的所有内容。

package com.mycompany.mavenproject1;

import cz.cuni.amis.introspection.java.JProp;
import cz.cuni.amis.pogamut.base.agent.impl.AgentId;
import cz.cuni.amis.pogamut.base.agent.module.comm.PogamutJVMComm;
import cz.cuni.amis.pogamut.base.agent.navigation.IPathExecutorState;
import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.EventListener;
import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
import cz.cuni.amis.pogamut.ut2004.agent.module.utils.TabooSet;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004PathAutoFixer;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004DistanceStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004PositionStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004TimeStuckDetector;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController;
import cz.cuni.amis.pogamut.ut2004.bot.params.UT2004BotParameters;
import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Initialize;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.FlagInfo;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Item;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerKilled;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
import cz.cuni.amis.pogamut.ut2004.utils.UT2004BotRunner;
import cz.cuni.amis.utils.Heatup;
import cz.cuni.amis.utils.exception.PogamutException;
import cz.cuni.amis.utils.flag.FlagListener;

/**
* Example of Simple Pogamut bot, that randomly walks around the map searching
* for preys shooting at everything that is in its way.
*
* @author Rudolf Kadlec aka ik
* @author Jimmy
*/
@AgentScoped
public class CTFBot extends UT2004BotModuleController<UT2004Bot> {

/** boolean switch to activate engage behavior */
@JProp
public boolean shouldEngage = true;

/** boolean switch to activate pursue behavior */

最佳答案

这个 JProp 注释似乎用于自省(introspection)目的(允许在 IDE 中轻松检查被修饰的变量的内容)。

引用this manual :

Introspection is designed to ease the bot's parameterization. It is often needed to adjust multiple behavior parameters at runtime and you will probably end up creating your own GUI (graphical user interface) for this purpose. In introspection, you just annotate desired variables with @JProp annotation and they will be accessible via the Netbeans GUI.

Let's look how logging and introspection works in EmptyBot example. First start the bot (F6), then have a look on it's source code. In the initial section several variables annotated with the @JProp are defined.

@JProp
public String stringProp = "Hello bot example";
@JProp
public boolean boolProp = true;
@JProp
public int intProp = 2;
@JProp
public double doubleProp = 1.0;

Now expand bot's node under the UT server node (in Services tab), you will see two new nodes - Logs and Introspection. After selecting the Introspection node the annotated variables will be shown in the Properties (Ctrl + Shift + 7) window. Note that the intProp variable is being continuously updated. New values of variables can be also set in this window.

关于java - 读取导入包的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23876724/

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