src/ai/core/ai_base.hpp
author truelight
Thu, 15 Mar 2007 00:27:28 +0000
branchnoai
changeset 9397 d8f8db9c1a2e
parent 9388 032008c3f6e3
child 9404 ef9e171617a3
permissions -rw-r--r--
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
wrappers instead of doing it ourself.
-Add: added a AddMethod overload which takes userdata as extra param
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
9361
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents: 9360
diff changeset
    10
class AIBase: public AIObject {
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents: 9360
diff changeset
    11
public:
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    12
	/**
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    13
	 * Get a random value.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    14
	 * @return A random value between 0 and MAX(uint32)
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    15
	 */
9362
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    16
#if defined(RANDOM_DEBUG)
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    17
	uint32 DoRandom(int line, const char *file);
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    18
#else
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    19
	uint32 Random();
9362
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    20
#endif
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    21
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    22
	/**
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    23
	 * Get a random value in a range.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    24
	 * @param max The maximum value it will return.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    25
	 * @return A random value between 0 .. max.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    26
	 */
9362
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    27
#if defined(RANDOM_DEBUG)
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    28
	uint DoRandomRange(uint max, int line, const char *file);
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    29
#else
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    30
	uint RandomRange(uint max);
3aebc515446a (svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
truelight
parents: 9361
diff changeset
    31
#endif
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    32
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
	 * Take a chance of 'out' out of 'max'.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    35
	 * @param out How many times is should return true.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    36
	 * @param max What the max value of 'out' can be.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    37
	 * @return True if the chance worked out.
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    38
	 */
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    39
	bool Chance(uint out, uint max);
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
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents: 9362
diff changeset
    42
#ifdef SQUIRREL_CLASS
9397
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    43
void SQAIBaseRegister(SquirrelEngine *engine) {
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents: 9362
diff changeset
    44
	DefSQClass <AIBase> SQAIBase("AIBase");
9397
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    45
	SQAIBase.PreRegister(engine);
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    46
	SQAIBase.DefSQFunction(engine, &AIBase::Random,      "Random");
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    47
	SQAIBase.DefSQFunction(engine, &AIBase::RandomRange, "RandomRange");
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    48
	SQAIBase.DefSQFunction(engine, &AIBase::Chance,      "Chance");
d8f8db9c1a2e (svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents: 9388
diff changeset
    49
	SQAIBase.PostRegister(engine);
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents: 9362
diff changeset
    50
}
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents: 9362
diff changeset
    51
#endif /* SQUIRREL_CLASS */
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents: 9362
diff changeset
    52
9360
c20d0a9e0a5c (svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff changeset
    53
#endif /* AI_BASE_HPP */