//--------------------------------------------------------------------------- #include #pragma hdrstop #include "dynamicExhaustCell.h" #include "globals.h" //--------------------------------------------------------------------------- #pragma package(smart_init) DynamicExhaustCell::DynamicExhaustCell(pAuditory pa,int xx,int yy, float _IAM, float _IASD, float _CTONM, float _CTONSD, float _CTOGM, float _CTOGSD, float _APTOSTDM, float _APTOSTDSD, float _CNTSTDNTSTNDM, float _CNTSTDNTSTNDSD, float _EXHAUSTM, float _EXHAUSTSD, int _contStEx ) : GrCell(pa,xx,yy) { IAM=_IAM; IASD=_IASD; CTONM=_CTONM; CTONSD=_CTONSD; CTOGM=_CTOGM; CTOGSD=_CTOGSD; APTOSTDM=_APTOSTDM; APTOSTDSD=_APTOSTDSD; CNTSTDNTSTNDM=_CNTSTDNTSTNDM; CNTSTDNTSTNDSD=_CNTSTDNTSTNDSD; EXHAUSTM = _EXHAUSTM; EXHAUSTSD = _EXHAUSTSD; contStEx=_contStEx; applaus=getGaussPosit(IAM,IASD); initialize(); }; int DynamicExhaustCell::isStanding() { return standing; }; void DynamicExhaustCell::recalculate() { float confToNeigh=getGaussPositButR(CTONM,CTONSD,1), confToGlobal=getGaussPositButR(CTOGM,CTOGSD,1-confToNeigh), applausToStand=getGaussPosit(APTOSTDM,APTOSTDSD), countStandNeighToStand=getGaussPosit(CNTSTDNTSTNDM,CNTSTDNTSTNDSD), exhaust=getGaussPosit(EXHAUSTM,EXHAUSTSD); 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; if (nowStanding && ((++standRounds) > exhaust)) { switched=1; nowApplaus=0; nowStanding=false; }; nowApplaus=nowStanding?max(nowApplaus,applausToStand):nowApplaus; }; void DynamicExhaustCell::initialize() { standing=(applaus>=getGaussPosit(APTOSTDM,APTOSTDSD)); standRounds=standing; switched=0; };