-
Notifications
You must be signed in to change notification settings - Fork 0
/
AStar.h
44 lines (33 loc) · 920 Bytes
/
AStar.h
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
34
35
36
37
38
39
40
41
42
43
44
//
// Created by tomer on 1/16/19.
//
#ifndef FLIGTSIMPROJ2_ASTAR_H
#define FLIGTSIMPROJ2_ASTAR_H
#include "PQueueSearcher.h"
#include "State.h"
#include "CompareState.h"
#include "ISearcher.h"
#include "Searcher.h"
#include <limits>
template <class T>
class AStar: public PQueueSearcher<T> {
public:
double getStatePriority(State<T>* curr_state);
};
template<class T>
double AStar<T>::getStatePriority(State<T> *curr_state) {
set<State<T>*> extension = Searcher<T>::curr_Searchable->getAllPossibleStates();
double upper_bound = numeric_limits<double>::max();
for(auto x : extension){
double tmp_weight=x->getWeight();
if(tmp_weight<upper_bound){
upper_bound=tmp_weight;
}
delete x;
}
if(numeric_limits<double>::max()==upper_bound){
upper_bound=curr_state->getWeight();
}
return upper_bound;
}
#endif //FLIGTSIMPROJ2_ASTAR_H