public class Items extends SensorModule<UT2004Bot>
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.
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
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<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.
|
worldView
agent, controller, eventBus, log
Constructor and Description |
---|
Items(UT2004Bot bot)
Constructor.
|
Items(UT2004Bot bot,
AgentInfo agentInfo,
Game game,
Weaponry weaponry,
Logger log)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanUp() |
protected Items.ItemsListener |
createItemsListener(IWorldView worldView)
This method is called from the constructor to hook a listener that updated the items field.
|
protected Items.MapPointsListener |
createMapPointsListener(IWorldView worldView)
This method is called from the constructor to create a listener that initialize items field from
the MapPointListObtained event.
|
Map<UnrealId,Item> |
getAllItems()
Retrieves list of all items, which includes all known pickups and all
visible thrown items.
|
Map<UnrealId,Item> |
getAllItems(ItemType.Category category)
Retrieves map of all items belonging to a specific 'category' of items, which
includes all known pickups.
|
Map<UnrealId,Item> |
getAllItems(ItemType.Group group)
Retrieves map of all items belonging to a specific 'group' of items, which
includes all known pickups.
|
Map<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(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(UnrealId id)
Retrieves a specific pickup point.
|
Map<UnrealId,Item> |
getKnownPickups()
Retrieves list of all known item pickup points.
|
Map<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<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<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<UnrealId,Item> |
getSpawnedItems()
Uses
isPickupSpawned(Item) to return all items that are believed to
be currently spawned. |
Map<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<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<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(UnrealId id)
Retrieves a specific item from the visible items in the map.
|
Map<UnrealId,Item> |
getVisibleItems()
Retreives list of all visible items, which includes all visible known
pickups and all visible thrown items.
|
Map<UnrealId,Item> |
getVisibleItems(ItemType.Category category)
Retrieves map of visible items belonging to a specific 'category' of items, which
includes all known pickups.
|
Map<UnrealId,Item> |
getVisibleItems(ItemType.Group group)
Retrieves map of visible items belonging to a specific 'group' of items, which
includes all known pickups.
|
Map<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(UnrealId itemId)
Tells, whether the given pickup point contains a spawned item.
|
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
protected Items.ItemsListener itemsListener
protected Items.MapPointsListener mapPointsListener
protected List<NavPoint> navPointsToProcess
protected Items.NavPointListener navPointListener
protected Items.EndMessageListener endMessageListener
protected Items.ItemPickedUpListener itemPickedUpListener
protected AgentInfo agentInfo
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 loggerpublic 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<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<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<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<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(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<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<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<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<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(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<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<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<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<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(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<UnrealId,Item> getSpawnedItems()
isPickupSpawned(Item)
to return all items that are believed to
be currently spawned.
WARNING: O(n) complexity!
public Map<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<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<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(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(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(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 AgentModule<UT2004Bot>
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.