src/ai/api/ai_base.hpp
author truebrain
Wed, 23 Apr 2008 12:05:32 +0000
branchnoai
changeset 10308 0c81dfce3e9b
parent 9835 2541c2d325ed
child 10876 63ac5bfb1a84
permissions -rw-r--r--
(svn r12849) [NoAI] -Fix: when .hpp.sq doesn't exists, don't run diff (tnx to Yexo)
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
9829
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9815
diff changeset
     3
/** @file ai_base.hpp Everything to query basic things. */
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
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    14
 *        RANDOM_DEBUG does some tricky stuff, which messes with those names.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    15
 * @note In MP we cannot use Random because that will cause desyncs (AIs are
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    16
 *        ran on the server only, not on all clients). This means that
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    17
 *        we use InteractiveRandom in MP. Rand() takes care of this for you.
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
    18
 */
9436
e28503f827a5 (svn r9247) [NoAI] -Fix: some small coding-style/double inclusion issues.
rubidium
parents: 9427
diff changeset
    19
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
    20
public:
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    21
	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
    22
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    23
	/**
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    24
	 * Get a random value.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    25
	 * @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
    26
	 */
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
    27
	static uint32 Rand();
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    28
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    29
	/**
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    30
	 * Get a random value.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    31
	 * @param unused_param This param is not used, but is needed to work with lists.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    32
	 * @return A random value between 0 and MAX(uint32).
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    33
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    34
	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
    35
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    36
	/**
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    37
	 * Get a random value in a range.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    38
	 * @param max The maximum value it will return.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    39
	 * @return A random value between 0 .. max.
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    40
	 */
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
    41
	static uint RandRange(uint max);
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    42
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    43
	/**
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    44
	 * 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
    45
	 * @param unused_param This param is not used, but is needed to work with lists.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    46
	 * @param max The maximum value it will return.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    47
	 * @return A random value between 0 .. max.
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    48
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    49
	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
    50
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    51
	/**
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
    52
	 * 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
    53
	 *   After all, it is a random function.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    54
	 * @param out How many times it should return true.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    55
	 * @param max Out of this many times.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    56
	 * @return True if the chance worked out.
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    57
	 */
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
    58
	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
    59
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    60
	/**
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    61
	 * 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
    62
	 *   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
    63
	 * @param unused_param This param is not used, but is needed to work with lists.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    64
	 * @param out How many times it should return true.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    65
	 * @param max Out of this many times.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    66
	 * @return True if the chance worked out.
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    67
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9660
diff changeset
    68
	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
    69
};
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    70
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    71
#endif /* AI_BASE_HPP */