File: resourceplacement.h

package info (click to toggle)
asc 2.1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 59,052 kB
  • ctags: 25,676
  • sloc: cpp: 145,189; sh: 8,705; ansic: 5,564; makefile: 551; perl: 150
file content (101 lines) | stat: -rw-r--r-- 2,961 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// C++ Interface: resourceplacement
//
// Description:
//
//
// Author: Martin Bickel <bickel@asc-hq.org>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef RESOURCEPLACEMENT_H
#define RESOURCEPLACEMENT_H

#include <list>
#include "gamemap.h"

/**
@author Kevin Hirschmann
*/

struct Rect {
  tfield *a, *b, *c, *d;

};

typedef list<Rect> RectList;
/**
@author Kevin Hirschmann
@brief Fills a map with resources using the diamond-square algorithm
*/

class ResourcePlacement {
private:
  GameMap& map;
  double fuelRoughness;
  double materialRoughness;
  bool placeFuel;
  bool placeMaterial;
  unsigned short maxFuelOffset;
  unsigned short maxMaterialOffset;
  int additionalResourceFreeFieldsPercentageFuel;
  int additionalResourceFreeFieldsPercentageMaterial;
  
  int stepCount;

  unsigned short createRandomValue(int limit);
  short createAlgebraicSign();
  
  void setFieldValueFuel(tfield* f);
  void setFieldValueMaterial(tfield* f);
  int calculateCornerValueFuel(tfield* a, tfield* b, tfield* c);
  int calculateDiamondValueFuel(tfield* a, tfield* b, tfield* c, tfield* d);
  int calculateCornerValueMaterial(tfield* a, tfield* b, tfield* c);
  int calculateDiamondValueMaterial(tfield* a, tfield* b, tfield* c, tfield* d);
  tfield* calculateCornerPoint(tfield* a, tfield* b, tfield* c);
  tfield* calculateDiamondPoint(tfield* a, tfield* b, tfield* c, tfield* d);
  int calculateCurrentOffset(int offset);
  void step(Rect r);
  void runDS();

public:
  /**  
  @brief Constructor. Configures algorithm with algorithm determining parameters
  @param map The map which is filled with resources
  @param fuelRoughness Decides how large the offset (relative) for fuel between the fields may be. Value must be 0 < value < 4.0
         The higher the value the more "hills" and "valleys" you get
  @param materialRoughness Decides how large the offset (relative) for material between neighbouring fields may be. Value must be 0 < value < 4.0
         The higher the value the more "hills" and "valleys" you get
  @param maxFuelOffSet Determines the absolut offset fuelFields might have
  @param maxMaterialOffSet Determines the absolut offset materialFields might have
  */
  ResourcePlacement(GameMap& map, double fuelRoughness, double materialRoughness, unsigned short maxFuelOffSet, unsigned short maxMaterialOffSet, 
                    int additionalFreeFieldsPercFuel = 0, int additionalFreeFieldsPercMaterial = 0);
  /**  
  @brief Destructor
  */
  ~ResourcePlacement();
  /**  
  @brief Fills the map with all resources 
  */
  void placeResources();
  /**  
  @brief Fills the map only with fuel resources
  */
  void placeFuelResources();
  /**  
  @brief Fills the map only with material resources
  */
  void placeMaterialResources();
  
  static const int MAXFUELVALUE;
  static const int MINFUELVALUE;
  static const int MAXMATERIALVALUE;
  static const int MINMATERIALVALUE;

};

#endif