00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FIRETREE__HEXMOVE_H
00025 #define FIRETREE__HEXMOVE_H 1
00026
00027
00028 #include "hex.h"
00029
00030
00031 namespace hex {
00032
00034 namespace move {
00035
00036
00037 class no_solution: public hex::exception
00038 {
00039 public:
00040 no_solution(const std::string& w) throw(): hex::exception(w) {}
00041 virtual ~no_solution() throw() {}
00042 };
00043
00044
00045 typedef double Cost;
00046
00047
00049 class Topography
00050 {
00051 bool _has_default;
00053 Cost _default;
00055 std::map<hex::Hex*,Cost> _hexes;
00059 std::map<hex::Edge*,Cost> _edges;
00060 public:
00061 Topography();
00062 Topography(Cost default_hex_cost);
00063 virtual ~Topography() {}
00064
00066 std::set<hex::Hex*> accessible(void) const;
00067
00069 void increase_hex_cost(hex::Hex* h, Cost c);
00071 void override_hex_cost(hex::Hex* h, Cost c);
00072
00074 void increase_edge_cost(hex::Edge* e, Cost c);
00076 void override_edge_cost(hex::Edge* e, Cost c);
00077
00078
00079 void increase_cost(const hex::Area& a, Cost c);
00080 void override_cost(const hex::Area& a, Cost c);
00081 void increase_cost(const hex::Boundary& b, Cost c);
00082 void override_cost(const hex::Boundary& b, Cost c);
00083
00086 hex::Path best_path(hex::Hex* start, hex::Hex* goal) const throw(no_solution);
00087
00089 hex::Area horizon(hex::Hex* start, Cost budget) const throw(no_solution);
00090
00091 protected:
00092 struct Step
00093 {
00094 hex::Hex* to_hex;
00095 Cost cost;
00096 };
00097
00101 Step step(hex::Hex* from_hex, Direction direction) const;
00102 };
00103
00104
00109 class _Route
00110 {
00111 Cost _value;
00112
00113 public:
00114 std::list<Hex*> path;
00115 Cost cost;
00116
00118 static _Route factory(hex::Hex* start, hex::Hex* goal=NULL);
00119
00121 _Route step(hex::Hex* next, Cost cost, hex::Hex* goal=NULL) const;
00122
00125 hex::Distance distance(hex::Hex* goal) const;
00126
00128 bool operator<(const _Route& right) const { return _value < right._value; }
00129 };
00130
00131
00132 }
00133 }
00134
00135 #endif