src/ai/api/ai_base.hpp
author truelight
Sun, 19 Aug 2007 13:31:04 +0000
branchnoai
changeset 9698 1d50fe99b7e9
parent 9660 d0a430e8310b
child 9814 be51ea0adc29
permissions -rw-r--r--
(svn r10939) [NoAI] -Add: added AITileList valuator Water
[NoAI] -Add: added AITile::IsWater
/* $Id$ */

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

#ifndef AI_BASE_HPP
#define AI_BASE_HPP

#include "ai_object.hpp"

/**
 * Class that handles some basic functions.
 *
 * @note The random functions are not called Random and RandomRange, because
 *       when including them the RANDOM_DEBUG stuff messes with their names.
 *       However, because in MP we cannot use Random because that will cause
 *       desyncs (AIs are ran locally, not on all clients). This means that
 *       we use InteractiveRandom in MP, thus the whole random debugging is
 *       pointless for the AIs. Therefor the random functions are called
 *       differently.
 */
class AIBase : public AIObject {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AIBase"; }

	/**
	 * Get a random value.
	 * @return a random value between 0 and MAX(uint32).
	 */
	static uint32 Rand();

	/**
	 * Get a random value in a range.
	 * @param max the maximum value it will return.
	 * @return a random value between 0 .. max.
	 */
	static uint RandRange(uint max);

	/**
	 * Returns approximatelly 'out' times true when called 'max' times.
	 *   After all, it is a random function.
	 * @return true if the chance worked out.
	 */
	static bool Chance(uint out, uint max);
};

#endif /* AI_BASE_HPP */