aboutsummaryrefslogtreecommitdiff
path: root/DijkstraPathfinder.h
blob: eddb26ffde01b87a7dc18e5a4344ce60360a60cb (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
#pragma once

#include <unordered_map>

#include "Pathfinder.h"

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

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

protected:
	virtual void clear();

private:
	Path solution;
	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 &);
};