//--------------------------------------------------------------------------- #include #pragma hdrstop #include "cell2.h" #include "globals.h" //--------------------------------------------------------------------------- #pragma package(smart_init) Cell2::Cell2(pAuditory pa,int xx,int yy) : GrCell(pa,xx,yy) { initialize(); }; int Cell2::isStanding() { return standing; }; #define STANDAPPLAUS 10 DECLAREGAUSS(InitialApplaus,7,3); #define GCONFORMITY 0.2 #define NCONFORMITY 0.6 #define STNEIGH_TO_STAND 2 void Cell2::recalculate() { Sum nGood = { 0 }; neighbourList->forEach(&TCell::addApplaus,&nGood); Count nStand = { 0 }; neighbourList->forEach(&TCell::addStanding,&nStand); nowApplaus=applaus*(1-NCONFORMITY-GCONFORMITY)+GCONFORMITY*(auditory->getGlobalGood()) + NCONFORMITY*(nGood.a)/(float)(neighbourList->getCount()); nowApplaus=(nowStanding=(applaus>=STANDAPPLAUS) || (nStand.a>=STNEIGH_TO_STAND))?max(nowApplaus,STANDAPPLAUS):nowApplaus; }; void Cell2::initialize() { GETGAUSSpositive(applaus,InitialApplaus); standing=(applaus>=STANDAPPLAUS); };