|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT> cz.cuni.amis.pogamut.base.agent.module.SensorModule<UT2004Bot> cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Items
public class Items
Memory module specialized on items on the map.
Apart from providing useful getters based on ItemType
, ItemType.Group
and ItemType.Category
it also
provides an optimistic approach for guessing whether some item is spawned inside the map via getSpawnedXYZ methods
such as getSpawnedItems()
.
WARNING:There are methods that contains "reachable" in its name but it is totally unclear what UT2004 means by reachable!!! These methods are for experimenting purposes only.
It is designed to be initialized inside IUT2004BotController.prepareBot(UT2004Bot)
method call
and may be used since IUT2004BotController.botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)
is called.
Nested Class Summary | |
---|---|
protected class |
Items.EndMessageListener
EndMessage listener. |
protected class |
Items.ItemPickedUpListener
ItemPickedUp listener. |
protected class |
Items.ItemsListener
|
protected class |
Items.MapPointsListener
MapPointsListObtained listener. |
protected class |
Items.NavPointListener
MapPointsListObtained listener. |
Field Summary | |
---|---|
protected AgentInfo |
agentInfo
AgentInfo memory module. |
protected Items.EndMessageListener |
endMessageListener
|
protected Items.ItemPickedUpListener |
itemPickedUpListener
|
protected Items.ItemsListener |
itemsListener
|
protected Items.MapPointsListener |
mapPointsListener
MapPointsListObtained listener |
protected Items.NavPointListener |
navPointListener
|
protected Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,NavPoint> |
navPoints
|
protected List<NavPoint> |
navPointsToProcess
Contains only navpoints that are visible so we can check whether they are spawning-points, if so - we may check whether the item is laying there or not to handle spawning times. |
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensorModule |
---|
worldView |
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
agent, controller, eventBus, log |
Constructor Summary | |
---|---|
Items(UT2004Bot bot)
Constructor. |
|
Items(UT2004Bot bot,
AgentInfo agentInfo,
Game game,
Weaponry weaponry,
Logger log)
Constructor. |
Method Summary | |
---|---|
protected void |
cleanUp()
|
protected Items.ItemsListener |
createItemsListener(cz.cuni.amis.pogamut.base.communication.worldview.IWorldView worldView)
This method is called from the constructor to hook a listener that updated the items field. |
protected Items.MapPointsListener |
createMapPointsListener(cz.cuni.amis.pogamut.base.communication.worldview.IWorldView worldView)
This method is called from the constructor to create a listener that initialize items field from the MapPointListObtained event. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getAllItems()
Retrieves list of all items, which includes all known pickups and all visible thrown items. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getAllItems(ItemType.Category category)
Retrieves map of all items belonging to a specific 'category' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getAllItems(ItemType.Group group)
Retrieves map of all items belonging to a specific 'group' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getAllItems(ItemType type)
Retrieves list of all items of specific type. |
Item |
getItem(String stringUnrealId)
Retrieves a specific item from the all items in the map. |
Item |
getItem(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Retrieves a specific item from the all items in the map. |
double |
getItemRespawnTime(Item item)
Returns how fast are the items respawning based on their item type (in real seconds according to System.currentTimeMillis() . |
double |
getItemRespawnTime(ItemType itemType)
Returns how fast are the items respawning based on their item type (in real seconds according to System.currentTimeMillis() . |
double |
getItemRespawnUT2004Time(Item item)
Returns how fast are the items respawning based on their item type (in UT Time == UT seconds == UnrealUtils.UT2004_TIME_SPEED * 1 seconds). |
double |
getItemRespawnUT2004Time(ItemType itemType)
Returns how fast are the items respawning based on their item type (in UT Time == UT seconds == UnrealUtils.UT2004_TIME_SPEED * 1 seconds). |
Item |
getKnownPickup(String stringUnrealId)
Retrieves a specific pickup point. |
Item |
getKnownPickup(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Retrieves a specific pickup point. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getKnownPickups()
Retrieves list of all known item pickup points. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getKnownPickups(ItemType.Category category)
Retrieves map of all known pickups belonging to a specific 'category' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getKnownPickups(ItemType.Group group)
Retrieves map of all known pickups belonging to a specific 'group' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getKnownPickups(ItemType type)
Retrieves list of all known item pickup points of specific type. |
Item |
getRandomItem()
Returns random item from 'all' items. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getSpawnedItems()
Uses isPickupSpawned(Item) to return all items that are believed to
be currently spawned. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getSpawnedItems(ItemType.Category category)
Uses isPickupSpawned(Item) to return all items belonging to a specific 'category' that are believed to
be currently spawned. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getSpawnedItems(ItemType.Group group)
Uses isPickupSpawned(Item) to return all items belonging to a specific 'group' that are believed to
be currently spawned. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getSpawnedItems(ItemType type)
Uses isPickupSpawned(Item) to return all items of 'type' that are believed to
be currently spawned. |
Item |
getVisibleItem(String stringUnrealId)
Retrieves a specific item from the visible items in the map. |
Item |
getVisibleItem(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Retrieves a specific item from the visible items in the map. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getVisibleItems()
Retreives list of all visible items, which includes all visible known pickups and all visible thrown items. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getVisibleItems(ItemType.Category category)
Retrieves map of visible items belonging to a specific 'category' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getVisibleItems(ItemType.Group group)
Retrieves map of visible items belonging to a specific 'group' of items, which includes all known pickups. |
Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> |
getVisibleItems(ItemType type)
Retreives list of all visible items of specific type, which includes all visible known pickups and all visible thrown items. |
boolean |
isPickable(Item item)
Method that determines whether 'item' is pickable in the current state of the bot. |
boolean |
isPickupSpawned(Item item)
Tells, whether the given pickup point contains a spawned item. |
boolean |
isPickupSpawned(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId itemId)
Tells, whether the given pickup point contains a spawned item. |
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Items.ItemsListener itemsListener
protected Items.MapPointsListener mapPointsListener
protected Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,NavPoint> navPoints
protected List<NavPoint> navPointsToProcess
protected Items.NavPointListener navPointListener
protected Items.EndMessageListener endMessageListener
protected Items.ItemPickedUpListener itemPickedUpListener
protected AgentInfo agentInfo
Constructor Detail |
---|
public Items(UT2004Bot bot)
bot
- owner of the module that is using itpublic Items(UT2004Bot bot, AgentInfo agentInfo, Game game, Weaponry weaponry, Logger log)
bot
- owner of the module that is using itagentInfo
- AgentInfo memory modulelog
- Logger to be used for logging runtime/debug info, if null is provided the module creates its own loggerMethod Detail |
---|
public boolean isPickable(Item item)
Contributed by: David Holan
item
-
public Item getRandomItem()
Note that there is no need to provide all "getRandomXYZ(xyz)", just
use MyCollections.getRandom(java.util.Collection)
.
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getAllItems()
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getAllItems(ItemType type)
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getAllItems(ItemType.Category category)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
category
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getAllItems(ItemType.Group group)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
group
-
public Item getItem(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Once obtained it is self-updating based on what happens in the game.
id
-
public Item getItem(String stringUnrealId)
Once obtained it is self-updating based on what happens in the game.
stringUnrealId
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getVisibleItems()
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getVisibleItems(ItemType type)
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getVisibleItems(ItemType.Category category)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
category
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getVisibleItems(ItemType.Group group)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
group
-
public Item getVisibleItem(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Once obtained it is self-updating based on what happens in the game.
id
-
public Item getVisibleItem(String stringUnrealId)
Once obtained it is self-updating based on what happens in the game.
stringUnrealId
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getKnownPickups()
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
isPickupSpawned(Item)
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getKnownPickups(ItemType type)
Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of items from this module, the Map will get updated based on what happens within the map.
isPickupSpawned(Item)
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getKnownPickups(ItemType.Category category)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
category
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getKnownPickups(ItemType.Group group)
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
group
-
public Item getKnownPickup(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId id)
Once obtained it is self-updating based on what happens in the game.
id
-
public Item getKnownPickup(String stringUnrealId)
Once obtained it is self-updating based on what happens in the game.
stringUnrealId
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getSpawnedItems()
isPickupSpawned(Item)
to return all items that are believed to
be currently spawned.
WARNING: O(n) complexity!
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getSpawnedItems(ItemType type)
isPickupSpawned(Item)
to return all items of 'type' that are believed to
be currently spawned.
WARNING: O(n) complexity!
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getSpawnedItems(ItemType.Category category)
isPickupSpawned(Item)
to return all items belonging to a specific 'category' that are believed to
be currently spawned.
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
category
-
public Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Item> getSpawnedItems(ItemType.Group group)
isPickupSpawned(Item)
to return all items belonging to a specific 'group' that are believed to
be currently spawned.
Note: The returned Map is modifiable and is always constructed upon every invocation of this method.
WARNING: O(n) complexity!
group
-
public double getItemRespawnUT2004Time(Item item)
UnrealUtils.UT2004_TIME_SPEED
* 1 seconds).
item
-
public double getItemRespawnUT2004Time(ItemType itemType)
UnrealUtils.UT2004_TIME_SPEED
* 1 seconds).
itemType
-
public double getItemRespawnTime(Item item)
System.currentTimeMillis()
.
item
-
public double getItemRespawnTime(ItemType itemType)
System.currentTimeMillis()
.
itemType
-
public boolean isPickupSpawned(Item item)
This implementation is guessing (optimistically) whether the item is spawned based on the last time we have seen it missing (bot has seen its spawning-navpoint but the item was not laying there).
Note that the guessing is not perfect, experiment with it or check the source code and possibly reimplement (probably copy-paste) to suit your needs.
Note that this method is working correctly only if items are respawning.
item
- Item, for which its pickup point is to be examined.
getKnownPickups(boolean,boolean)
public boolean isPickupSpawned(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId itemId)
This implementation is guessing (optimistically) whether the item is spawned based on the last time we have seen it missing (saw its navpoint but the item was not laying there).
Note that the guessing is not perfect, experiment with it or check the source code and possibly reimplement to suit your needs.
Note that this method is working only if items are respawning.
itemId
- Id of the item, for which its pickup point is to be examined.
getKnownPickups(boolean,boolean)
protected Items.ItemsListener createItemsListener(cz.cuni.amis.pogamut.base.communication.worldview.IWorldView worldView)
It must:
By overriding this method you may provide your own listener that may wrap Items with your class adding new fields into them.
worldView
- protected Items.MapPointsListener createMapPointsListener(cz.cuni.amis.pogamut.base.communication.worldview.IWorldView worldView)
By overriding this method you may provide your own listener that may wrap Items with your class adding new fields into them.
worldView
-
protected void cleanUp()
cleanUp
in class cz.cuni.amis.pogamut.base.agent.module.AgentModule<UT2004Bot>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |