void JoinedLandscape::AddToDistribution( string & itsConfig ) { unsigned short int strLength = itsConfig.length() / 2; d[itsConfig].AddToDist(); string first = itsConfig; first.replace ( strLength, strLength*2, strLength, '0' ); string second = itsConfig; second.replace ( 0, strLength, strLength, '0' ); LOne.AddToDistribution(first); LTwo.AddToDistribution(second); }
bool Entity::Move( string destination, Landscape & LJoined ) { if ( destination == "EMPTY" ) { return 0; } string previous = itsPayoff.GetConfig(); LJoined.SubFromDistribution( previous ); // cout << "Move from " << itsPayoff.GetConfig() << ":" << itsPayoff.GetFitness() << " to "; itsPayoff.SetConfig( destination ); itsPayoff.SetFitness( LJoined.d[destination].GetFitness() ) ; // cout << "to " << itsPayoff.GetConfig() << ":" << itsPayoff.GetFitness() << endl; LJoined.AddToDistribution( destination ); movesTaken++; return 1; }