Advanced Strategic Command
baseaiinterface.h
Go to the documentation of this file.
1 
5 /***************************************************************************
6  baseaiinterface.h - description
7  -------------------
8  begin : Tue Feb 17 2001
9  copyright : (C) 2001 by Martin Bickel
10  email : bickel@asc-hq.org
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 
23 #ifndef baseaiinterface_h_included
24  #define baseaiinterface_h_included
25 
26 
27  class Vehicle;
28  class Building;
29  class MapDisplayInterface;
30 
32 const int aiValueTypeNum = 8;
33 
39 class AiThreat {
40  public:
43  void reset ( void );
44  AiThreat ( void ) : threatTypes ( aiValueTypeNum ) { reset(); };
45  AiThreat& operator+= ( const AiThreat& t ) {
46  for ( int i = 0; i < threatTypes; i++ )
47  threat[i] += t.threat[i];
48  return *this;
49  };
50 
51  void read ( tnstream& stream );
52  void write ( tnstream& stream );
53 };
54 
55 
61 class AiValue {
62 #ifdef karteneditor
63  public:
64 #endif
65  int value;
66  int addedValue;
67  public:
69  int valueType;
70 
71  void reset ( int _valueType ) { threat.reset(); value = 0; valueType = _valueType; addedValue = 0; };
72  AiValue ( int _valueType ) { reset( _valueType ); };
73  int getValue() { return value + addedValue; };
74  void setValue ( int _value ) { value = _value; };
75  void setAdditionalValue ( int _addedValue ) { addedValue = _addedValue; };
76  void resetAdditionalValue ( ) { addedValue = 0; };
77 
78  void read ( tnstream& stream );
79  void write ( tnstream& stream );
80  };
81 
83 class AiParameter : public AiValue {
84  Vehicle* unit;
85  public:
86  static const int taskNum = 8;
87  static const int jobNum = 8;
90  typedef vector<AiParameter::Job> JobList;
91 
92  Task getTask ( ) { return task; };
93  void setTask ( Task t ) { task = t; };
94 
95  Job getJob ( ) { if ( jobPos < jobs.size() ) return jobs[jobPos]; else return job_undefined; };
96  void addJob ( Job j, bool front = false );
97 
98  void setNextJob();
99  void restartJobs();
100  void clearJobs();
101  void setJob ( const JobList& jobs );
102  void setJob ( Job j );
103  bool hasJob ( Job j );
104 
105 
108 
111  int data;
113 
114  void reset ( Vehicle* _unit );
115  void setNewHeight();
116  void resetTask ( );
117  AiParameter ( Vehicle* _unit );
118 
119  void read ( tnstream& stream );
120  void write ( tnstream& stream );
121  private:
122  Task task;
123  JobList jobs;
124  int jobPos;
125 };
126 
127 class BaseAI {
128  public:
129  virtual void run ( MapDisplayInterface* mapDisplay ) = 0;
130  virtual bool isRunning ( void ) = 0;
131  virtual VisibilityStates getVision ( void ) = 0;
132  virtual void read ( tnstream& stream ) = 0;
133  virtual void write ( tnstream& stream ) const = 0;
134  virtual ~BaseAI () {};
135  };
136 
137 
138 
139 #endif
virtual bool isRunning(void)=0
the time in ASC, measured in turns and moves
Definition: typen.h:178
virtual void write(tnstream &stream) const =0
void setValue(int _value)
AiThreat(void)
void resetAdditionalValue()
AiValue(int _valueType)
void write(tnstream &stream)
Definition: gamemap.cpp:2012
VisibilityStates
the different states that a player's view on a field can have
Definition: typen.h:403
bool hasJob(Job j)
Definition: gamemap.cpp:2130
vector< AiParameter::Job > JobList
static const int taskNum
virtual VisibilityStates getVision(void)=0
The interface for all kinds of IO stream.
int threat[aiValueTypeNum]
void setNewHeight()
Definition: gamemap.cpp:2135
AiThreat & operator+=(const AiThreat &t)
void setJob(const JobList &jobs)
Definition: gamemap.cpp:2112
virtual ~BaseAI()
void setNextJob()
Definition: gamemap.cpp:2153
const int aiValueTypeNum
how many different target types are there?
GameTime damageTime
virtual void read(tnstream &stream)=0
void clearJobs()
Definition: gamemap.cpp:2163
void read(tnstream &stream)
Definition: gamemap.cpp:2054
The value of a unit for the AI.
void setTask(Task t)
void read(tnstream &stream)
Definition: gamemap.cpp:2022
void reset(void)
Definition: gamemap.cpp:2085
the threat that a unit poses against other units.
virtual void run(MapDisplayInterface *mapDisplay)=0
void restartJobs()
Definition: gamemap.cpp:2158
void resetTask()
Definition: gamemap.cpp:2097
int getValue()
AiThreat threat
void setAdditionalValue(int _addedValue)
All parameters the AI stores persistently about a unit.
void read(tnstream &stream)
Definition: gamemap.cpp:2000
static const int jobNum
AiParameter(Vehicle *_unit)
Definition: gamemap.cpp:2091
Coordinate on the map including height.
Definition: typen.h:238
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
MapCoordinate3D dest
void addJob(Job j, bool front=false)
Definition: gamemap.cpp:2104
void write(tnstream &stream)
Definition: gamemap.cpp:1991
void reset(Vehicle *_unit)
Definition: gamemap.cpp:2141
void write(tnstream &stream)
Definition: gamemap.cpp:2035
void reset(int _valueType)
bool resetAfterJobCompletion