Debian Codegraph @

src/mas/environment.h

raw symbols SCIP
1 /***************************************************************************
2 environment.h - description
3 -------------------
4 begin : dec 11th, 2005
5 copyright : (C) 2005-2010 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7 author : Victor STINNER
8
9 $Id: environment.h 448 2010-05-09 15:18:32Z neoneurone $
10 ***************************************************************************/
11
12 /***************************************************************************
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * any later version. *
18 * *
19 ***************************************************************************/
20
21
22 #ifndef _OPENCITY_MAS_ENVIRONMENT_H_
23 #define _OPENCITY_MAS_ENVIRONMENT_H_ 1
24
25 #include <vector>
26 #include <map>
27
28 #include "agent.h"
29 #include "agentposition.h"
30
31 #define MAX_PATH_LENGTH 20
32
33 class Destination;
34 class Structure;
35 class Layer;
36
37 /*=====================================================================*/
38 unsigned char randomBool();
39 int randomInt(int min, int max);
40 MAS_DIRECTION rotate180(MAS_DIRECTION dir);
41 MAS_DIRECTION rotateLeft(MAS_DIRECTION dir);
42 MAS_DIRECTION rotateRight(MAS_DIRECTION dir);
43
44
45 //========================================================================
46 /** This is the environment of the Multi-Agent System.
47 @author Victor STINNER
48 @author Duong Khang NGUYEN
49 */
50 class Environment
51 {
52 public:
53 //========================================================================
54 /** Create a new Environment instance with the specified width, and height.
55 @note The specified width and height must be equal to the width and
56 the height of the specified Layer respectively
57 @see BuildingLayer
58 */
59 Environment(unsigned int width, unsigned int height, Layer* pBL, Kernel *kernel);
60
61 unsigned int getHeight() const;
62 unsigned int getWidth() const;
63
64
65 //========================================================================
66 /** Display all the registered agents.
67 @see GraphicManager
68 */
69 void displayAgent();
70
71
72 void registerAgent(Agent* agent, int x, int y);
73 void unregisterAgent(Agent* agent);
74
75 Agent* getAgentAt(int x, int y);
76 bool hasAgentAt(const Agent* agent, int x, int y) const;
77 bool moveAgent(Agent* agent, int x, int y);
78
79
80 //========================================================================
81 /** Return the shortest path between 2 points. The length of the path
82 is limited to MAX_PATH_LENGTH
83 @see PathFinder
84 */
85 const bool
86 findShortestPath(
87 unsigned int x1, unsigned int y1,
88 unsigned int x2, unsigned int y2,
89 std::vector<Destination> & rvdest );
90
91 Structure* getBuildingXY(unsigned int x, unsigned int y);
92
93
94 /*=====================================================================*/
95 /* STATIC METHODS */
96 /*=====================================================================*/
97 //========================================================================
98 /** Calculate the square of the euclidian distance between 2 points
99 @return The square of the euclidian distance
100 */
101 static unsigned int
102 toSquareDistance(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2);
103
104
105 private:
106 unsigned int _width; ///< Width of the map
107 unsigned int _height; ///< Height of the map
108 Kernel* _pKernel;
109 Layer* _pBuildingLayer;
110
111 std::map<Agent*, AgentPosition> _last_pos;
112 typedef std::map<Agent*, AgentPosition>::iterator _last_pos_it;
113 std::vector<Agent*> _vector;
114 typedef std::vector<Agent*>::iterator _vector_it;
115 typedef std::vector<Agent*>::const_iterator _vector_cit;
116 };
117
118 #endif