cz.cuni.amis.pogamut.ut2004.agent.module.sensor
Class AdvancedItems

java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AdvancedItems

public class AdvancedItems
extends java.lang.Object

Module specialized on items on the map. This module extends the Items module by adding filters for usability and/or "takeability". These filters may help the agent to decide, whether it is useful for him, to forage specific items from the map.

You have to provide the implementation of IItemUsefulness interface where you have to specify what usefulness is.

Note that it might be useful to instantiate this class multiple times with different item filters to achieve various specialized filters (e.g., different useful filter for weapons and health).

It is designed to be initialized inside IUT2004BotController.initializeController(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.


Constructor Summary
AdvancedItems(Items items, IItemUsefulness filter)
          Constructor.
AdvancedItems(UT2004Bot bot, IItemUsefulness filter)
          Constructor.
 
Method Summary
 java.util.Map<UnrealId,Item> filterUsefulItems(java.util.Collection<Item> items, double usefulness)
          Determines, whether an item can be useful for the agent.
 java.util.Map<UnrealId,Item> getAllItems(double usefulness)
          Retrieves map of all items (both known and thrown).
 java.util.Map<UnrealId,Item> getAllItems(ItemType.Category category, double usefulness)
          Retrieves map of all items of specific category (both known and thrown).
 java.util.Map<UnrealId,Item> getAllItems(ItemType.Group group, double usefulness)
          Retrieves map of all items of specific group (both known and thrown).
 java.util.Map<UnrealId,Item> getAllItems(ItemType type, double usefulness)
          Retrieves map of all items of specific type (both known and thrown).
 Items getItems()
          Returns underlying Items module.
 java.util.Map<UnrealId,Item> getKnownPickups(double usefulness)
          Retrieves map of all item pickup points.
 java.util.Map<UnrealId,Item> getKnownPickups(ItemType.Category category, double usefulness)
          Retrieves map of all item pickup points of items of a specific category.
 java.util.Map<UnrealId,Item> getKnownPickups(ItemType.Group group, double usefulness)
          Retrieves map of all item pickup points of items of a specific group.
 java.util.Map<UnrealId,Item> getKnownPickups(ItemType type, double usefulness)
          Retrieves map of all item pickup points of items of a specific type.
 java.util.Map<UnrealId,Item> getReachableItems(double usefulness)
          Retrieves map of all reachable items.
 java.util.Map<UnrealId,Item> getReachableItems(ItemType.Category category, double usefulness)
          Retrieves map of all reachable items of a specific category.
 java.util.Map<UnrealId,Item> getReachableItems(ItemType.Group group, double usefulness)
          Retrieves map of all reachable items of a specific group.
 java.util.Map<UnrealId,Item> getReachableItems(ItemType type, double usefulness)
          Retrieves map of all reachable items of a specific type.
 java.util.Map<UnrealId,Item> getSpawnedItems(double usefulness)
          Returns a filtered list of items that are guessed to be currently spawned in the map.
 java.util.Map<UnrealId,Item> getSpawnedItems(ItemType.Category category, double usefulness)
          Returns a filtered list of items of a specific category that are guessed to be currently spawned in the map.
 java.util.Map<UnrealId,Item> getSpawnedItems(ItemType.Group group, double usefulness)
          Returns a filtered list of items of a specific group that are guessed to be currently spawned in the map.
 java.util.Map<UnrealId,Item> getSpawnedItems(ItemType type, double usefulness)
          Returns a filtered list of items of a specific type that are guessed to be currently spawned in the map.
 java.util.Map<UnrealId,Item> getVisibleItems(double usefulness)
          Retrieves map of all visible items.
 java.util.Map<UnrealId,Item> getVisibleItems(ItemType.Category category, double usefulness)
          Retrieves map of all visible items of specific category.
 java.util.Map<UnrealId,Item> getVisibleItems(ItemType.Group group, double usefulness)
          Retrieves map of all visible items of specific group.
 java.util.Map<UnrealId,Item> getVisibleItems(ItemType type, double usefulness)
          Retrieves map of all visible items of specific type.
 boolean isItemUseful(Item item, double usefulness)
          Determines, whether an item can be useful for the agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedItems

public AdvancedItems(UT2004Bot bot,
                     IItemUsefulness filter)
Constructor. Setups the memory module based on bot's world view.

Parameters:
bot - owner of the module
filter - the filter of the usefulness

AdvancedItems

public AdvancedItems(Items items,
                     IItemUsefulness filter)
Constructor. Setups the memory module based on bot's world view.

Parameters:
items - items memory module
filter - the filter of the usefulness
Method Detail

getSpawnedItems

public java.util.Map<UnrealId,Item> getSpawnedItems(double usefulness)
Returns a filtered list of items that are guessed to be currently spawned in the map.

WARNING: O(n) complexity!

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.

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
True, if the item is spawned; false if the pickup is empty.

getSpawnedItems

public java.util.Map<UnrealId,Item> getSpawnedItems(ItemType type,
                                                    double usefulness)
Returns a filtered list of items of a specific type that are guessed to be currently spawned in the map.

WARNING: O(n) complexity!

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.

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of spawned items.

getSpawnedItems

public java.util.Map<UnrealId,Item> getSpawnedItems(ItemType.Category category,
                                                    double usefulness)
Returns a filtered list of items of a specific category that are guessed to be currently spawned in the map.

WARNING: O(n) complexity!

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.

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of spawned items.

getSpawnedItems

public java.util.Map<UnrealId,Item> getSpawnedItems(ItemType.Group group,
                                                    double usefulness)
Returns a filtered list of items of a specific group that are guessed to be currently spawned in the map.

WARNING: O(n) complexity!

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.

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of spawned items.

getAllItems

public java.util.Map<UnrealId,Item> getAllItems(double usefulness)
Retrieves map of all items (both known and thrown).

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: non-spawned items are included too.

getAllItems

public java.util.Map<UnrealId,Item> getAllItems(ItemType type,
                                                double usefulness)
Retrieves map of all items of specific type (both known and thrown).

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: non-spawned items are included too.

getAllItems

public java.util.Map<UnrealId,Item> getAllItems(ItemType.Category category,
                                                double usefulness)
Retrieves map of all items of specific category (both known and thrown).

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: non-spawned items are included too.

getAllItems

public java.util.Map<UnrealId,Item> getAllItems(ItemType.Group group,
                                                double usefulness)
Retrieves map of all items of specific group (both known and thrown).

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: non-spawned items are included too.

getVisibleItems

public java.util.Map<UnrealId,Item> getVisibleItems(double usefulness)
Retrieves map of all visible items.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all visible items. Note: Spawned items are included only.

getVisibleItems

public java.util.Map<UnrealId,Item> getVisibleItems(ItemType type,
                                                    double usefulness)
Retrieves map of all visible items of specific type.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all visible items. Note: Spawned items are included only.

getVisibleItems

public java.util.Map<UnrealId,Item> getVisibleItems(ItemType.Category category,
                                                    double usefulness)
Retrieves map of all visible items of specific category.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all visible items. Note: Spawned items are included only.

getVisibleItems

public java.util.Map<UnrealId,Item> getVisibleItems(ItemType.Group group,
                                                    double usefulness)
Retrieves map of all visible items of specific group.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all visible items. Note: Spawned items are included only.

getReachableItems

public java.util.Map<UnrealId,Item> getReachableItems(double usefulness)
Retrieves map of all reachable items.

WARNING: O(n) complexity!

WARNING:It is totally unclear what UT2004 means by reachable!!!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all reachable items. Note: Spawned items are included only.

getReachableItems

public java.util.Map<UnrealId,Item> getReachableItems(ItemType type,
                                                      double usefulness)
Retrieves map of all reachable items of a specific type.

WARNING: O(n) complexity!

WARNING:It is totally unclear what UT2004 means by reachable!!!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all reachable items. Note: Spawned items are included only.

getReachableItems

public java.util.Map<UnrealId,Item> getReachableItems(ItemType.Category category,
                                                      double usefulness)
Retrieves map of all reachable items of a specific category.

WARNING: O(n) complexity!

WARNING:It is totally unclear what UT2004 means by reachable!!!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all reachable items. Note: Spawned items are included only.

getReachableItems

public java.util.Map<UnrealId,Item> getReachableItems(ItemType.Group group,
                                                      double usefulness)
Retrieves map of all reachable items of a specific group.

WARNING: O(n) complexity!

WARNING:It is totally unclear what UT2004 means by reachable!!!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all reachable items. Note: Spawned items are included only.

getKnownPickups

public java.util.Map<UnrealId,Item> getKnownPickups(double usefulness)
Retrieves map of all item pickup points.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: Empty pickups are included as well.
See Also:
isPickupSpawned(Item)

getKnownPickups

public java.util.Map<UnrealId,Item> getKnownPickups(ItemType type,
                                                    double usefulness)
Retrieves map of all item pickup points of items of a specific type.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: Empty pickups are included as well.
See Also:
isPickupSpawned(Item)

getKnownPickups

public java.util.Map<UnrealId,Item> getKnownPickups(ItemType.Category category,
                                                    double usefulness)
Retrieves map of all item pickup points of items of a specific category.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: Empty pickups are included as well.
See Also:
isPickupSpawned(Item)

getKnownPickups

public java.util.Map<UnrealId,Item> getKnownPickups(ItemType.Group group,
                                                    double usefulness)
Retrieves map of all item pickup points of items of a specific group.

WARNING: O(n) complexity!

Parameters:
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all items. Note: Empty pickups are included as well.
See Also:
isPickupSpawned(Item)

isItemUseful

public boolean isItemUseful(Item item,
                            double usefulness)
Determines, whether an item can be useful for the agent.

Parameters:
item - Given item to be checked.
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
True, if the item can be useful.

filterUsefulItems

public java.util.Map<UnrealId,Item> filterUsefulItems(java.util.Collection<Item> items,
                                                      double usefulness)
Determines, whether an item can be useful for the agent.

WARNING: O(n) complexity!

Parameters:
items - Items to be filtered on.
usefulness - degree of usefulness, 0 - return also useless, 1 - return only really truly useful items which are MUST HAVE!
Returns:
Map of all useful items.

getItems

public Items getItems()
Returns underlying Items module.