Exemple #1
0
func (t *t_pf_state) setStart(start *TileWrapper, heuristics bool) {
	startx, starty := start.tile.GetIndices()
	t.startNode = &t.nodemap[startx][starty]
	t.addToOpen(t.startNode)

	if heuristics {
		for x := 0; x < env.MAX_SIZE; x++ {
			for y := 0; y < env.MAX_SIZE; y++ {
				// Map the manhattan distance
				node := &t.nodemap[x][y]
				node.h = util.Absi(startx-x) +
					util.Absi(starty-y)
			}
		}
	}
}
Exemple #2
0
func manhattanDistance(a, b *t_pathnode) int {
	ax, ay := a.tile.tile.GetIndices()
	bx, by := b.tile.tile.GetIndices()
	return util.Absi(ax-bx) + util.Absi(ay-by)
}