//--------------------------------------------------------------------------- #include #pragma hdrstop #include "restandCell.h" #include "globals.h" //--------------------------------------------------------------------------- #pragma package(smart_init) RestandCell::RestandCell(pAuditory pa,int xx,int yy, float IA, float CTON, float CTOG, float APTOSTD, float CNTSTDNTSTND, float EXHAUST, int RESTAND, int _contStEx ): Cell3(pa,xx,yy,IA,CTON,CTOG,APTOSTD,CNTSTDNTSTND) { exhaust=EXHAUST; restand=RESTAND; contStEx=_contStEx; initialize(); }; void RestandCell::recalculate() { if (switched) { if (++swRoundsforEach(&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) swRounds=0; if (nowStanding && ((++swRounds) > exhaust)) { switched=1; swRounds=0; nowApplaus=0; nowStanding=false; }; nowApplaus=nowStanding?max(nowApplaus,applausToStand):nowApplaus; }; void RestandCell::initialize() { standing=(applaus>=applausToStand); swRounds=standing; switched=0; };