src/ai/core/ai_base.hpp
author truelight
Thu, 15 Mar 2007 19:33:07 +0000
branchnoai
changeset 9422 33efcc5f1b09
parent 9404 ef9e171617a3
child 9425 8eec6d10844a
permissions -rw-r--r--
(svn r9223) [NoAI] -Change: moved squirrel/engine.cpp to squirrel.cpp in root
-Change: renamed SquirrelEngine to Squirrel
/* $Id$ */

/** @file ai_base.hpp declaration of class for AIBase class */

#ifndef AI_BASE_HPP
#define AI_BASE_HPP

#include "ai_object.hpp"

class AIBase: public AIObject {
public:
	/**
	 * Get a random value.
	 * @return A random value between 0 and MAX(uint32)
	 */
#if defined(RANDOM_DEBUG)
	uint32 DoRandom(int line, const char *file);
#else
	uint32 Random();
#endif

	/**
	 * Get a random value in a range.
	 * @param max The maximum value it will return.
	 * @return A random value between 0 .. max.
	 */
#if defined(RANDOM_DEBUG)
	uint DoRandomRange(uint max, int line, const char *file);
#else
	uint RandomRange(uint max);
#endif

	/**
	 * Take a chance of 'out' out of 'max'.
	 * @param out How many times is should return true.
	 * @param max What the max value of 'out' can be.
	 * @return True if the chance worked out.
	 */
	bool Chance(uint out, uint max);
};

#ifdef SQUIRREL_CLASS
void SQAIBaseRegister(Squirrel *engine) {
	DefSQClass <AIBase> SQAIBase("AIBase");
	SQAIBase.PreRegister(engine);
	SQAIBase.AddConstructor(engine);
	SQAIBase.DefSQFunction(engine, &AIBase::Random,      "Random");
	SQAIBase.DefSQFunction(engine, &AIBase::RandomRange, "RandomRange");
	SQAIBase.DefSQFunction(engine, &AIBase::Chance,      "Chance");
	SQAIBase.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_BASE_HPP */