00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef RESOURCEPLACEMENT_H
00013 #define RESOURCEPLACEMENT_H
00014
00015 #include <list>
00016 #include "gamemap.h"
00017
00022 struct Rect {
00023 tfield *a, *b, *c, *d;
00024
00025 };
00026
00027 typedef list<Rect> RectList;
00033 class ResourcePlacement {
00034 private:
00035 GameMap& map;
00036 double fuelRoughness;
00037 double materialRoughness;
00038 bool placeFuel;
00039 bool placeMaterial;
00040 unsigned short maxFuelOffset;
00041 unsigned short maxMaterialOffset;
00042 int additionalResourceFreeFieldsPercentageFuel;
00043 int additionalResourceFreeFieldsPercentageMaterial;
00044
00045 int stepCount;
00046
00047 unsigned short createRandomValue(int limit);
00048 short createAlgebraicSign();
00049
00050 void setFieldValueFuel(tfield* f);
00051 void setFieldValueMaterial(tfield* f);
00052 int calculateCornerValueFuel(tfield* a, tfield* b, tfield* c);
00053 int calculateDiamondValueFuel(tfield* a, tfield* b, tfield* c, tfield* d);
00054 int calculateCornerValueMaterial(tfield* a, tfield* b, tfield* c);
00055 int calculateDiamondValueMaterial(tfield* a, tfield* b, tfield* c, tfield* d);
00056 tfield* calculateCornerPoint(tfield* a, tfield* b, tfield* c);
00057 tfield* calculateDiamondPoint(tfield* a, tfield* b, tfield* c, tfield* d);
00058 int calculateCurrentOffset(int offset);
00059 void step(Rect r);
00060 void runDS();
00061
00062 public:
00073 ResourcePlacement(GameMap& map, double fuelRoughness, double materialRoughness, unsigned short maxFuelOffSet, unsigned short maxMaterialOffSet,
00074 int additionalFreeFieldsPercFuel = 0, int additionalFreeFieldsPercMaterial = 0);
00078 ~ResourcePlacement();
00082 void placeResources();
00086 void placeFuelResources();
00090 void placeMaterialResources();
00091
00092 static const int MAXFUELVALUE;
00093 static const int MINFUELVALUE;
00094 static const int MAXMATERIALVALUE;
00095 static const int MINMATERIALVALUE;
00096
00097 };
00098
00099 #endif
00100
00101