~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/api/ai_base.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: ai_base.hpp 15060 2009-01-13 15:44:36Z smatz $ */
 
2
 
 
3
/** @file ai_base.hpp Everything to query basic things. */
 
4
 
 
5
#ifndef AI_BASE_HPP
 
6
#define AI_BASE_HPP
 
7
 
 
8
#include "ai_object.hpp"
 
9
 
 
10
/**
 
11
 * Class that handles some basic functions.
 
12
 *
 
13
 * @note The random functions are not called Random and RandomRange, because
 
14
 *        RANDOM_DEBUG does some tricky stuff, which messes with those names.
 
15
 * @note In MP we cannot use Random because that will cause desyncs (AIs are
 
16
 *        ran on the server only, not on all clients). This means that
 
17
 *        we use InteractiveRandom in MP. Rand() takes care of this for you.
 
18
 */
 
19
class AIBase : public AIObject {
 
20
public:
 
21
        static const char *GetClassName() { return "AIBase"; }
 
22
 
 
23
        /**
 
24
         * Get a random value.
 
25
         * @return A random value between 0 and MAX(uint32).
 
26
         */
 
27
        static uint32 Rand();
 
28
 
 
29
        /**
 
30
         * Get a random value.
 
31
         * @param unused_param This param is not used, but is needed to work with lists.
 
32
         * @return A random value between 0 and MAX(uint32).
 
33
         */
 
34
        static uint32 RandItem(int unused_param);
 
35
 
 
36
        /**
 
37
         * Get a random value in a range.
 
38
         * @param max The first number this function will never return (the maximum it returns is max - 1).
 
39
         * @return A random value between 0 .. max - 1.
 
40
         */
 
41
        static uint RandRange(uint max);
 
42
 
 
43
        /**
 
44
         * Get a random value in a range.
 
45
         * @param unused_param This param is not used, but is needed to work with lists.
 
46
         * @param max The first number this function will never return (the maximum it returns is max - 1).
 
47
         * @return A random value between 0 .. max - 1.
 
48
         */
 
49
        static uint RandRangeItem(int unused_param, uint max);
 
50
 
 
51
        /**
 
52
         * Returns approximatelly 'out' times true when called 'max' times.
 
53
         *   After all, it is a random function.
 
54
         * @param out How many times it should return true.
 
55
         * @param max Out of this many times.
 
56
         * @return True if the chance worked out.
 
57
         */
 
58
        static bool Chance(uint out, uint max);
 
59
 
 
60
        /**
 
61
         * Returns approximatelly 'out' times true when called 'max' times.
 
62
         *   After all, it is a random function.
 
63
         * @param unused_param This param is not used, but is needed to work with lists.
 
64
         * @param out How many times it should return true.
 
65
         * @param max Out of this many times.
 
66
         * @return True if the chance worked out.
 
67
         */
 
68
        static bool ChanceItem(int unused_param, uint out, uint max);
 
69
};
 
70
 
 
71
#endif /* AI_BASE_HPP */