Documentation
¶
Overview ¶
Package network is what runs from cell to cell across a board, rivers and roads, as a graph over its grid: the cells it runs through (Network.Set, a Node of a board kind, a width and a fade) and which neighbours each runs on to; a road [Network.Link]s its cells both ways, water [Network.Flow]s down to where it leaves the network. It is a way to make a board's layout, not a plugin: a game works one out, by hand or as plugins/board/water drains a relief, and lays it on the board as its Network.Ways; Network.Along is how far down its flow a cell lies, Network.Crossings where two networks meet. A road is found over the grid with Route and laid along its cells with Network.Path.
Index ¶
- func Route(grid grid.Grid, from, to cell.ID, cost func(a, b cell.ID) float64) ([]cell.ID, bool)
- type Network
- func (n *Network) Along(c cell.ID) float64
- func (n *Network) Cells() []cell.ID
- func (n *Network) Crossings(o *Network) []cell.ID
- func (n *Network) Down(c cell.ID) (cell.ID, bool)
- func (n *Network) Flow(from, to cell.ID) bool
- func (n *Network) Lead(a, b cell.ID) bool
- func (n *Network) Link(a, b cell.ID) bool
- func (n *Network) Links(c cell.ID) cell.Links
- func (n *Network) Node(c cell.ID) (Node, bool)
- func (n *Network) Path(cells []cell.ID, node Node)
- func (n *Network) Set(c cell.ID, node Node)
- func (n *Network) Ways() []cell.WayEntry
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network is what runs from cell to cell over a board's grid — a river, a road: the cells it runs through and which of their neighbours each runs on to. A link that Flows has a way down: water running from cell to cell towards where it leaves the network, the sea.
func (*Network) Along ¶
Along is how far down its flow c lies: 0 at the head of the longest flow running into it, 1 at the last cell before it leaves the network, by the cells above and below it; 0 where the network does not run, or does not flow.
func (*Network) Crossings ¶
Crossings is every cell both n and o run through: where a road meets a river, a ford or a bridge.
func (*Network) Flow ¶
Flow has from run down on to its neighbour to, linked back where the network runs through to; a river's last cell runs on to the sea, which is no part of it. It is false where they are no neighbours.
func (*Network) Lead ¶ added in v0.22.0
Lead has a run on to its neighbour b and b not back: a way led onto what stands in b's cell, a bridge, a ford or a tunnel, leaves a way running in that cell as it was; false where they are no neighbours.
func (*Network) Link ¶
Link has a and b, neighbours, run on to each other; false where they are no neighbours.
func (*Network) Links ¶
Links is which of c's neighbours the network runs on to from it; none where it does not run.
func (*Network) Path ¶
Path has the network run along cells, each a node as given, each linked to the next.