master
Raw Download raw file
 1package grid
 2
 3// Cartesian
 4type Coord struct {
 5	X int
 6	Y int
 7}
 8
 9// Cartesian coordinates of all adjacent Neighbors
10// Does not take into consideration edges, maximum
11// .....
12// .nnn.
13// .ncn.
14// .nnn.
15// .....
16func (c Coord) Neighbors() []Coord {
17	return []Coord{
18		{X: c.X - 1, Y: c.Y - 1},
19		{X: c.X - 1, Y: c.Y},
20		{X: c.X - 1, Y: c.Y + 1},
21		{X: c.X, Y: c.Y - 1},
22		{X: c.X, Y: c.Y + 1},
23		{X: c.X + 1, Y: c.Y - 1},
24		{X: c.X + 1, Y: c.Y},
25		{X: c.X + 1, Y: c.Y + 1},
26	}
27}