aboutsummaryrefslogtreecommitdiff
path: root/DijkstraPathfinder.h
blob: ab2136197878211cba0cc519ad70516cac2689ec (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
#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;
	};

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

	void dijkstra(const XY &);
};