Show / Hide Table of Contents

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
object
GridViewBase<double?>
WeightedGoalMap
Implements
IGridView<double?>
Inherited Members
GridViewBase<double?>.Count
GridViewBase<double?>.this[int, int]
GridViewBase<double?>.this[int]
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.Pathing
Assembly: GoRogue.dll
Syntax
public sealed class WeightedGoalMap : GridViewBase<double?>, IGridView<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.

Note that all the grid views held by this class must have the same width and height. If their width and height change after they are added such that this is not the case, unexpected behavior will occur.

Constructors

View Source

WeightedGoalMap(IGridView<double?>)

Constructor. Takes a single goal map and assigns it a weight of 1.0.

Declaration
public WeightedGoalMap(IGridView<double?> map)
Parameters
Type Name Description
IGridView<double?> map

The goal map.

View Source

WeightedGoalMap(IEnumerable<GoalMapWeightPair>)

Constructor. Takes an existing goal map dictionary and copies it.

Declaration
public WeightedGoalMap(IEnumerable<GoalMapWeightPair> maps)
Parameters
Type Name Description
IEnumerable<GoalMapWeightPair> maps

The goal maps. Each one must be of the same size, and all weights should have a nonzero value.

View Source

WeightedGoalMap(IEnumerable<IGridView<double?>>)

Constructor. Takes a sequence of goal maps and assigns each one a weight of 1.0.

Declaration
public WeightedGoalMap(IEnumerable<IGridView<double?>> maps)
Parameters
Type Name Description
IEnumerable<IGridView<double?>> maps

The goal maps. Each one must be of the same size.

Fields

View Source

Weights

The list of weighted goal maps. Can be used to add or remove goal maps, or change their weights.

Declaration
public readonly List<GoalMapWeightPair> Weights
Field Value
Type Description
List<GoalMapWeightPair>
Remarks

When adding a new goal map, its Width and Height should be identical to the WeightedGoalMap's Width and Height.

Properties

View Source

Height

The height of the goal map, and the goal maps that compose it.

Declaration
public override int Height { get; }
Property Value
Type Description
int
Overrides
SadRogue.Primitives.GridViews.GridViewBase<double?>.Height
View Source

this[Point]

Returns the value of the combined goal maps at any given point.

Declaration
public override double? this[Point point] { get; }
Parameters
Type Name Description
Point point
Property Value
Type Description
double?
Overrides
SadRogue.Primitives.GridViews.GridViewBase<double?>.this[SadRogue.Primitives.Point]
View Source

Width

The width of the goal map, and the goal maps that compose it.

Declaration
public override int Width { get; }
Property Value
Type Description
int
Overrides
SadRogue.Primitives.GridViews.GridViewBase<double?>.Width

Methods

View Source

Combine()

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 ArrayView<double?> Combine()
Returns
Type Description
ArrayView<double?>

Implements

IGridView<T>

Extension Methods

Utility.Yield<T>(T)
GoalMapExtensions.GetDirectionOfMinValue(IGridView<double?>, Point, AdjacencyRule)
GoalMapExtensions.GetDirectionOfMinValue(IGridView<double?>, int, int, AdjacencyRule)
  • View Source
In this article
Back to top Generated by DocFX