Class: GridWithWeights
grids.GridWithWeights
Hierarchy
-
↳
GridWithWeights
Implements
Constructors
constructor
• new GridWithWeights(width
, height
, walls?
, weights?
): GridWithWeights
Parameters
Name | Type | Default value |
---|---|---|
width |
number |
undefined |
height |
number |
undefined |
walls |
GridLocation [] |
[] |
weights |
Map <GridLocation , number > |
undefined |
Returns
Overrides
Properties
height
• Readonly
height: number
Inherited from
weights
• Private
weights: Map
<string
, number
>
width
• Readonly
width: number
Inherited from
Methods
getCost
▸ getCost(fromId
, toId
): number
Provides the cost to move directly from location A to location B, assuming there is a direct connection For some graphs, this may just be the cost to enter location B, but it is technically the cost of traversing the connection.
Ensure a direct connection exists before using! Allowed to throw, but may also return a weight for a non-existant connection.
Parameters
Name | Type | Description |
---|---|---|
fromId |
GridLocation |
Location A |
toId |
GridLocation |
Location B |
Returns
number
Implementation of
inBounds
▸ inBounds(id
): boolean
Parameters
Name | Type |
---|---|
id |
GridLocation |
Returns
boolean
Inherited from
neighbors
▸ neighbors(id
): GridLocation
[]
Returns the set of direct connections reachable from a location.
Parameters
Name | Type | Description |
---|---|---|
id |
GridLocation |
The location to check for connections from |
Returns
Implementation of
Inherited from
passable
▸ passable(id
): boolean
Parameters
Name | Type |
---|---|
id |
GridLocation |
Returns
boolean