aboutsummaryrefslogtreecommitdiff
path: root/DijkstraPathfinder.h
blob: 93e6943798b6854bc1d5291d783e0be8c095467c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <unordered_map>

#include "Pathfinder.h"

class DijkstraPathfinder : public Pathfinder {
	using Pathfinder::Pathfinder;

public:
	virtual void find_between(const XY &, const XY &);

protected:
	virtual void clear();

private:
	XY end;

	struct Node {
		unsigned int distance = -1;
		XY parent;
	};
	struct Neighbor {
		unsigned int distance = -1;
		XY position;
	};

	Node & map_get(const XY &);
	std::unordered_map<XY, Node> map;

	void dijkstra(const XY &);
};