//--------------------------------------------------------------------------- #include #pragma hdrstop #include "dynamicCell3.h" #include "globals.h" //--------------------------------------------------------------------------- #pragma package(smart_init) DynamicCell3::DynamicCell3(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) : GrCell(pa,xx,yy) { IAM=_IAM; IASD=_IASD; CTONM=_CTONM; CTONSD=_CTONSD; CTOGM=_CTOGM; CTOGSD=_CTOGSD; APTOSTDM=_APTOSTDM; APTOSTDSD=_APTOSTDSD; CNTSTDNTSTNDM=_CNTSTDNTSTNDM; CNTSTDNTSTNDSD=_CNTSTDNTSTNDSD; applaus=getGaussPosit(IAM,IASD); initialize(); }; int DynamicCell3::isStanding() { return standing; }; void DynamicCell3::recalculate() { Sum nGood = { 0 }; neighbourList->forEach(&TCell::addApplaus,&nGood); Count nStand = { 0 }; neighbourList->forEach(&TCell::addStanding,&nStand); float confToNeigh=getGaussPositButR(CTONM,CTONSD,1), confToGlobal=getGaussPositButR(CTOGM,CTOGSD,1-confToNeigh), applausToStand=getGaussPosit(APTOSTDM,APTOSTDSD), countStandNeighToStand=getGaussPosit(CNTSTDNTSTNDM,CNTSTDNTSTNDSD); if (neighbourList->getCount()!=0) { nowApplaus=applaus*(1-confToNeigh-confToGlobal)+confToGlobal*(auditory->getGlobalGood()) + confToNeigh*(nGood.a)/(float)(neighbourList->getCount()); nowApplaus= (nowStanding=((nowApplaus>=applausToStand) || (((float)nStand.a)/(float)(neighbourList->getCount()) >= countStandNeighToStand))) ? max(nowApplaus,applausToStand):nowApplaus; } else { nowApplaus=applaus*(1-confToGlobal)+confToGlobal*(auditory->getGlobalGood()); nowStanding=(nowApplaus>=applausToStand); }; }; void DynamicCell3::initialize() { standing=(applaus>=getGaussPosit(APTOSTDM,APTOSTDSD)); };