//--------------------------------------------------------------------------- #include #pragma hdrstop #include "exhaustCell.h" #include "globals.h" //--------------------------------------------------------------------------- #pragma package(smart_init) ExhaustCell::ExhaustCell(pAuditory pa,int xx,int yy, float IA, float CTON, float CTOG, float APTOSTD, float CNTSTDNTSTND, float EXHAUST, int _contStEx ): Cell3(pa,xx,yy,IA,CTON,CTOG,APTOSTD,CNTSTDNTSTND) { exhaust=EXHAUST; contStEx=_contStEx; initialize(); }; int ExhaustCell::isStanding() { return standing; }; void ExhaustCell::recalculate() { if (switched) return; Sum nGood = { 0 }; neighbourList->forEach(&TCell::addApplaus,&nGood); Count nStand = { 0 }; neighbourList->forEach(&TCell::addStanding,&nStand); if (neighbourList->getCount()!=0) { nowApplaus=applaus*(1-confToNeigh-confToGlobal)+confToGlobal*(auditory->getGlobalGood()) + confToNeigh*(nGood.a)/(float)(neighbourList->getCount()); nowStanding=((nowApplaus>=applausToStand) || (((float)nStand.a)/(float)(neighbourList->getCount()) >= countStandNeighToStand)); } else { nowApplaus=applaus*(1-confToGlobal)+confToGlobal*(auditory->getGlobalGood()); nowStanding=(nowApplaus>=applausToStand); }; if ((!nowStanding) && contStEx) standRounds=0; else if (nowStanding && ((++standRounds) > exhaust)) { switched=1; nowApplaus=0; nowStanding=false; }; nowApplaus=nowStanding?max(nowApplaus,applausToStand):nowApplaus; }; void ExhaustCell::initialize() { standing=(applaus>=applausToStand); standRounds=standing; switched=0; };