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
System.Object
WeightedGoalMap
Implements
IMapView<System.Nullable<System.Double>>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

WeightedGoalMap(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

Weights

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 Source

Height

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

Declaration
public int Height { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

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>
| Improve this Doc View Source

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>
| Improve this Doc View Source

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>
| Improve this Doc View Source

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 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 ArrayMap<double?> Combine()
Returns
Type Description
ArrayMap<System.Nullable<System.Double>>

Implements

IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.Bounds<T>(IMapView<T>)
IMapViewExtensions.Contains<T>(IMapView<T>, Int32, Int32)
IMapViewExtensions.Contains<T>(IMapView<T>, Coord)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, Int32, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.Positions<T>(IMapView<T>)
IMapViewExtensions.RandomItem<T>(IMapView<T>, IGenerator)
IMapViewExtensions.RandomItem<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, T, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IEnumerable<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, HashSet<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator, T[])
IMapViewExtensions.RandomPosition<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator)
GoalMapExtensions.GetDirectionOfMinValue(IMapView<Nullable<Double>>, Coord, AdjacencyRule)
GoalMapExtensions.GetDirectionOfMinValue(IMapView<Nullable<Double>>, Int32, Int32, AdjacencyRule)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX