author | truelight |
Fri, 19 Oct 2007 14:03:27 +0000 | |
branch | noai |
changeset 9714 | fdbdae7ea647 |
parent 9660 | d0a430e8310b |
child 9814 | be51ea0adc29 |
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 |
/** |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
35 |
* 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
|
36 |
* @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
|
37 |
* @return a random value between 0 .. max. |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
38 |
*/ |
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
|
39 |
static uint RandRange(uint max); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
40 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
41 |
/** |
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
|
42 |
* 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
|
43 |
* After all, it is a random function. |
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 true if the chance worked out. |
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 bool Chance(uint out, 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 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
49 |
#endif /* AI_BASE_HPP */ |