virtual ValueArray log_probabilities(const StateArray& states, const StateArray& cond_states, const InputArray& cond_inputs) const { assert(states.size() == cond_inputs.size()); auto probs = ValueArray(states.size()); for (int i = 0; i < states.size(); ++i) { probs[i] = log_probability(states[i], cond_states[i], cond_inputs[i]); } return probs; }
int CampaignEastWest::stage_9_create_town() { //------- set the range of placements of objects -------// enum { TOWN_STATE_MAP_WIDTH = 100, TOWN_STATE_MAP_HEIGHT = 100 }; //------ generate a StateArray ---------// int townAddCount = 4 + misc.random(2); // add 4 to 5 player towns int addedCount=0; StateArray townStateArray; townStateArray.init(TOWN_STATE_MAP_WIDTH, TOWN_STATE_MAP_HEIGHT); townStateArray.generate(13); for( int i=townStateArray.size() ; i>0 && addedCount<townAddCount ; i-- ) { StateInfo* stateInfo = townStateArray[i]; int xLoc = (int) stateInfo->center_x * MAX_WORLD_X_LOC / TOWN_STATE_MAP_WIDTH; int yLoc = (int) stateInfo->center_y * MAX_WORLD_Y_LOC / TOWN_STATE_MAP_HEIGHT; int soldierAddCount; if( addedCount==0 ) soldierAddCount = MAX_SOLDIER; else soldierAddCount = MAX_SOLDIER/2 + misc.random(MAX_SOLDIER/2) + 1; if( create_nation_town(PLAYER_NATION_RECNO, xLoc, yLoc, 1, 1, soldierAddCount) ) // 1-the race of the town should be the same as the nation addedCount++; } //----- create independent towns ------// Battle::create_independent_town(4+misc.random(3)); //-------- update links -------// town_array.update_all_camp_link(); return 1; }
int CampaignEastWest::stage_12_create_town() { //------- set the range of placements of objects -------// enum { TOWN_STATE_MAP_WIDTH = 100, TOWN_STATE_MAP_HEIGHT = 100 }; //------ generate a StateArray ---------// int townAddCount = 8 + m.random(3); // add 8 to 10 player towns int addedCount=0; StateArray townStateArray; townStateArray.init(TOWN_STATE_MAP_WIDTH, TOWN_STATE_MAP_HEIGHT); townStateArray.generate(13); for( int i=townStateArray.size() ; i>0 && addedCount<townAddCount ; i-- ) { StateInfo* stateInfo = townStateArray[i]; int xLoc = (int) stateInfo->center_x * MAX_WORLD_X_LOC / TOWN_STATE_MAP_WIDTH; int yLoc = (int) stateInfo->center_y * MAX_WORLD_Y_LOC / TOWN_STATE_MAP_HEIGHT; int soldierAddCount; if( addedCount%2==0 ) soldierAddCount = MAX_SOLDIER/4 + m.random(MAX_SOLDIER/4) + 1; else soldierAddCount = MAX_SOLDIER/2 + m.random(MAX_SOLDIER/2) + 1; if( create_nation_town(PLAYER_NATION_RECNO, xLoc, yLoc, 1, 0, soldierAddCount) ) // 0-the race of the town need not to be the same as the nation addedCount++; } town_array.update_all_camp_link(); return 1; }
void iqrcommon::moduleEPuck::replyToData(string strReply, StateArray& stateArray, double fMaxValue){ // cout << "moduleEPuck::replyToData(string strReply, StateArray& stateArray, double fMaxValue)" << endl; int ii = 0; cleanupReply(strReply); istringstream is(strReply); istream_iterator<int> itStart(is); istream_iterator<int> itEnd; int iContainerSize = stateArray.getWidth(); while (itStart != itEnd && ii<iContainerSize){ // cout << "itStart: " << *itStart << endl; stateArray[0][ii] = (double)*itStart / fMaxValue; // cout << (double)*itStart << endl; ++itStart; ii++; } }