author | truebrain |
Wed, 26 Mar 2008 15:17:40 +0000 | |
branch | noai |
changeset 9823 | 0b7f816cf46f |
parent 9815 | efac4d882b25 |
child 9829 | 80fbe02a4184 |
permissions | -rw-r--r-- |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
2 |
|
9388
032008c3f6e3
(svn r9180) [NoAI] -Fix: copy/pasting can be nasty: wrong @file headers
truelight
parents:
9387
diff
changeset
|
3 |
/** @file ai_base.hpp declaration of class for AIBase class */ |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
4 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
5 |
#ifndef AI_BASE_HPP |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
6 |
#define AI_BASE_HPP |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
7 |
|
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
8 |
#include "ai_object.hpp" |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
9 |
|
9440
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
10 |
/** |
9447
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
11 |
* Class that handles some basic functions. |
9440
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
12 |
* |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
13 |
* @note The random functions are not called Random and RandomRange, because |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
14 |
* when including them the RANDOM_DEBUG stuff messes with their names. |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
15 |
* However, because in MP we cannot use Random because that will cause |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
16 |
* desyncs (AIs are ran locally, not on all clients). This means that |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
17 |
* we use InteractiveRandom in MP, thus the whole random debugging is |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
18 |
* pointless for the AIs. Therefor the random functions are called |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
19 |
* differently. |
0986434f3af8
(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
rubidium
parents:
9436
diff
changeset
|
20 |
*/ |
9436
e28503f827a5
(svn r9247) [NoAI] -Fix: some small coding-style/double inclusion issues.
rubidium
parents:
9427
diff
changeset
|
21 |
class AIBase : public AIObject { |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
22 |
public: |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
23 |
/** |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
24 |
* The name of the class, needed by several sub-processes. |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
25 |
*/ |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
26 |
static const char *GetClassName() { return "AIBase"; } |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
27 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
28 |
/** |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
29 |
* Get a random value. |
9447
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
30 |
* @return a random value between 0 and MAX(uint32). |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
31 |
*/ |
9660
d0a430e8310b
(svn r10569) [NoAI] -Add: added AIListRandomize as Valuator for all lists to attach a random value to all items
truelight
parents:
9596
diff
changeset
|
32 |
static uint32 Rand(); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
33 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
34 |
/** |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
35 |
* Get a random value. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
36 |
* @param unused_param This param is not used, but is needed to work with lists. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
37 |
* @return a random value between 0 and MAX(uint32). |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
38 |
*/ |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
39 |
static uint32 RandItem(int unused_param); |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
40 |
|
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
41 |
/** |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
42 |
* Get a random value in a range. |
9447
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
43 |
* @param max the maximum value it will return. |
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
44 |
* @return a random value between 0 .. max. |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
45 |
*/ |
9660
d0a430e8310b
(svn r10569) [NoAI] -Add: added AIListRandomize as Valuator for all lists to attach a random value to all items
truelight
parents:
9596
diff
changeset
|
46 |
static uint RandRange(uint max); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
47 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
48 |
/** |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
49 |
* Get a random value in a range. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
50 |
* @param unused_param This param is not used, but is needed to work with lists. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
51 |
* @param max the maximum value it will return. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
52 |
* @return a random value between 0 .. max. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
53 |
*/ |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
54 |
static uint RandRangeItem(int unused_param, uint max); |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
55 |
|
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
56 |
/** |
9447
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
57 |
* Returns approximatelly 'out' times true when called 'max' times. |
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
58 |
* After all, it is a random function. |
9815
efac4d882b25
(svn r12412) [NoAI] -Fix: three functions missed documentation
truebrain
parents:
9814
diff
changeset
|
59 |
* @param out how many times it should return true. |
efac4d882b25
(svn r12412) [NoAI] -Fix: three functions missed documentation
truebrain
parents:
9814
diff
changeset
|
60 |
* @param max out of this many times. |
9447
8f3c1bc72204
(svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents:
9440
diff
changeset
|
61 |
* @return true if the chance worked out. |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
62 |
*/ |
9660
d0a430e8310b
(svn r10569) [NoAI] -Add: added AIListRandomize as Valuator for all lists to attach a random value to all items
truelight
parents:
9596
diff
changeset
|
63 |
static bool Chance(uint out, uint max); |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
64 |
|
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
65 |
/** |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
66 |
* Returns approximatelly 'out' times true when called 'max' times. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
67 |
* After all, it is a random function. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
68 |
* @param unused_param This param is not used, but is needed to work with lists. |
9815
efac4d882b25
(svn r12412) [NoAI] -Fix: three functions missed documentation
truebrain
parents:
9814
diff
changeset
|
69 |
* @param out how many times it should return true. |
efac4d882b25
(svn r12412) [NoAI] -Fix: three functions missed documentation
truebrain
parents:
9814
diff
changeset
|
70 |
* @param max out of this many times. |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
71 |
* @return true if the chance worked out. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
72 |
*/ |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9660
diff
changeset
|
73 |
static bool ChanceItem(int unused_param, uint out, uint max); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
74 |
}; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
75 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
76 |
#endif /* AI_BASE_HPP */ |