truelight@9360: /* $Id$ */ truelight@9360: rubidium@9430: /** @file ai_base.cpp handles the functions of the AIBase class */ truelight@9360: rubidium@9430: #include "ai_base.hpp" truelight@9360: truelight@9362: #if defined(RANDOM_DEBUG) truelight@9362: uint32 AIBase::DoRandom(int line, const char *file) truelight@9362: #else truelight@9360: uint32 AIBase::Random() truelight@9362: #endif truelight@9360: { truelight@9360: /* We pick RandomRange if we are in SP (so when saved, we do the same over and over) truelight@9360: * but we pick InteractiveRandomRange if we are a network_server or network-client. */ truelight@9360: if (_networking) return InteractiveRandom(); truelight@9362: #if defined(RANDOM_DEBUG) truelight@9362: return ::DoRandom(line, file); truelight@9362: #else truelight@9361: return ::Random(); truelight@9362: #endif truelight@9360: } truelight@9360: truelight@9362: #if defined(RANDOM_DEBUG) truelight@9362: uint AIBase::DoRandomRange(uint max, int line, const char *file) truelight@9362: #else truelight@9362: uint AIBase::RandomRange(uint max) truelight@9362: #endif truelight@9360: { truelight@9360: /* We pick RandomRange if we are in SP (so when saved, we do the same over and over) truelight@9360: * but we pick InteractiveRandomRange if we are a network_server or network-client. */ truelight@9360: if (_networking) return InteractiveRandomRange(max); truelight@9362: #if defined(RANDOM_DEBUG) truelight@9362: return ::DoRandomRange(max, line, file); truelight@9362: #else truelight@9361: return ::RandomRange(max); truelight@9362: #endif truelight@9360: } truelight@9360: truelight@9360: bool AIBase::Chance(uint out, uint max) truelight@9360: { rubidium@9371: return (uint16)this->Random() <= (uint16)((65536 * out) / max); truelight@9360: }