2013-01-03 16:14:16 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "DataDefs.h"
|
|
|
|
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "modules/MapCache.h"
|
|
|
|
|
|
|
|
#include "df/coord.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
//cost is [path cost, building destruction cost, dig cost, construct cost]. Minimize constructions, then minimize dig cost, then minimize path cost.
|
|
|
|
enum CostDimension {
|
2013-01-05 09:06:46 -07:00
|
|
|
Walk,
|
2013-01-03 16:14:16 -07:00
|
|
|
DestroyBuilding,
|
|
|
|
Dig,
|
|
|
|
DestroyConstruction,
|
|
|
|
//Construct,
|
|
|
|
costDim
|
|
|
|
};
|
|
|
|
|
2013-06-09 21:17:31 -06:00
|
|
|
typedef int64_t cost_t;
|
|
|
|
|
|
|
|
extern cost_t costWeight[costDim];
|
2013-01-04 19:02:09 -07:00
|
|
|
/*
|
2013-06-09 21:17:31 -06:00
|
|
|
const cost_t costWeight[] = {
|
2013-01-03 16:14:16 -07:00
|
|
|
//Distance
|
|
|
|
1,
|
|
|
|
//Destroy Building
|
|
|
|
2,
|
|
|
|
//Dig
|
|
|
|
10000,
|
|
|
|
//DestroyConstruction
|
|
|
|
100,
|
|
|
|
};
|
2013-01-04 19:02:09 -07:00
|
|
|
*/
|
2013-01-03 16:14:16 -07:00
|
|
|
|
|
|
|
class Edge {
|
|
|
|
public:
|
|
|
|
//static map<df::coord, int32_t> pointCost;
|
|
|
|
df::coord p1;
|
|
|
|
df::coord p2;
|
2013-06-09 21:17:31 -06:00
|
|
|
cost_t cost;
|
2013-01-04 16:11:38 -07:00
|
|
|
Edge() {
|
|
|
|
cost = -1;
|
|
|
|
}
|
|
|
|
Edge(const Edge& e): p1(e.p1), p2(e.p2), cost(e.cost) {
|
|
|
|
|
|
|
|
}
|
2013-06-09 21:17:31 -06:00
|
|
|
Edge(df::coord p1In, df::coord p2In, cost_t costIn): cost(costIn) {
|
2013-01-03 16:14:16 -07:00
|
|
|
if ( p2In < p1In ) {
|
|
|
|
p1 = p2In;
|
|
|
|
p2 = p1In;
|
|
|
|
} else {
|
|
|
|
p1 = p1In;
|
|
|
|
p2 = p2In;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Edge& e) const {
|
|
|
|
return (cost == e.cost && p1 == e.p1 && p2 == e.p2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const Edge& e) const {
|
|
|
|
if ( cost != e.cost )
|
|
|
|
return cost < e.cost;
|
|
|
|
if ( p1.z != e.p1.z )
|
|
|
|
return p1.z < e.p1.z;
|
|
|
|
if ( p1 != e.p1 )
|
|
|
|
return p1 < e.p1;
|
|
|
|
if ( p2.z != e.p2.z )
|
|
|
|
return p2.z < e.p2.z;
|
|
|
|
if ( p2 != e.p2 )
|
|
|
|
return p2 < e.p2;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PointHash {
|
|
|
|
size_t operator()(const df::coord c) const {
|
|
|
|
return c.x * 65537 + c.y * 17 + c.z;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-09 21:17:31 -06:00
|
|
|
cost_t getEdgeCost(color_ostream& out, df::coord pt1, df::coord pt2);
|
2013-01-03 16:14:16 -07:00
|
|
|
std::vector<Edge>* getEdgeSet(color_ostream &out, df::coord point, MapExtras::MapCache& cache, int32_t xMax, int32_t yMax, int32_t zMax);
|
|
|
|
|