Class WeightedGoalMap
Implementation of the second half of the goal map system described in this article -- the ability to combine multiple goal maps with different weights.
Inheritance
Implements
Inherited Members
Namespace: GoRogue.Pathing
Assembly: GoRogue.dll
Syntax
public class WeightedGoalMap : IMapView<double?>
Remarks
This class encapsulates the work of building one overall goal map out of multiple existing maps. It holds references to one or more maps, each with its own "weight". The higher the weight value, the more strongly an AI will attempt to pursue this goal. A negative weight inverts the map, turning its goal into something to avoid. Inverting the weight does not create a "safety map" as described in the article, as the resulting goal map will show no concept of global vs. local avoidance. For that functionality, see FleeMap.
Constructors
| Improve this Doc View SourceWeightedGoalMap(IMapView<Nullable<Double>>)
Constructor. Takes a single goal map and assigns it a weight of 1.0.
Declaration
public WeightedGoalMap(IMapView<double?> map)
Parameters
Type | Name | Description |
---|---|---|
IMapView<System.Nullable<System.Double>> | map | The goal map. |
WeightedGoalMap(IDictionary<IMapView<Nullable<Double>>, Double>)
Constructor. Takes an existing goal map dictionary and copies it.
Declaration
public WeightedGoalMap(IDictionary<IMapView<double?>, double> maps)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<IMapView<System.Nullable<System.Double>>, System.Double> | maps | The goal maps. Each one should be of the same size, and all weights should have a nonzero value. |
WeightedGoalMap(IEnumerable<IMapView<Nullable<Double>>>)
Constructor. Takes a sequence of goal maps and assigns each one a weight of 1.0.
Declaration
public WeightedGoalMap(IEnumerable<IMapView<double?>> maps)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IMapView<System.Nullable<System.Double>>> | maps | The goal maps. Each one should be of the same size. |
Fields
| Improve this Doc View SourceWeights
The list of weighted goal maps. Can be used to add or remove goal maps, or change their weights.
Declaration
public readonly Dictionary<IMapView<double?>, double> Weights
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<IMapView<System.Nullable<System.Double>>, System.Double> |
Remarks
When adding a new goal map, its Width and Height should be identical to the WeightedGoalMap's Width and Height.
Properties
| Improve this Doc View SourceHeight
The height of the goal map, and the goal maps that compose it.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Coord]
Returns the value of the combined goal maps at any given point.
Declaration
public double? this[Coord point] { get; }
Parameters
Type | Name | Description |
---|---|---|
Coord | point |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
Item[Int32]
Returns the value of the combined goal maps at the given point.
Declaration
public double? this[int index1D] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index1D |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
Item[Int32, Int32]
Returns the value of the combined goal maps at any given point.
Declaration
public double? this[int x, int y] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
Width
The width of the goal map, and the goal maps that compose it.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceCombine()
Computes the entire aggregate goal map and returns it, effectively caching the result. This may be useful in situations where the goals are shared between many characters and do not change frequently.
Declaration
public ArrayMap<double?> Combine()
Returns
Type | Description |
---|---|
ArrayMap<System.Nullable<System.Double>> |