static void gen_M2L_interaction_list2(FmmvHandle *FMMV, Box *box, Box **list, Box **neighbor2_list) { int i,j,k; Box *nb; Box *nb_nb2_list[124]; int non_reduced_neighbors; if (FMMV->periodicBoundaryConditions && (box->level==0)) { for (i=0; i<124; i++) { neighbor2_list[i] = box; nb_nb2_list[i] = box; } } else { gen_neighbor2_list(box, neighbor2_list); } non_reduced_neighbors = (FMMV->reducedScheme?26:124); memset(list, 0, 8*non_reduced_neighbors*sizeof(Box*)); k = 0; for (i=0; i<non_reduced_neighbors; i++) { nb = neighbor2_list[i]; if (isTarget(nb) && hasTargetChilds(nb)) { if (nb->noOfXin == -1) { if (!(FMMV->periodicBoundaryConditions && (box->level==0))) { gen_neighbor2_list(nb, nb_nb2_list); } nb->noOfXin = noOfSourceNeighborsWithSourceChilds2(nb_nb2_list, 0, non_reduced_neighbors); for (j=0; j<8; j++) { if (isTarget(nb->child[j])) { list[k] = nb->child[j]; ++(FMMV->noOfStoredXin); if (FMMV->noOfStoredXin>FMMV->maxNoOfStoredXin) { FMMV->maxNoOfStoredXin = FMMV->noOfStoredXin; } } k++; } } else { for (j=0; j<8; j++) { if (isTarget(nb->child[j])) { list[k] = nb->child[j]; } k++; } } } else { k += 8; } } }
bool Actor::selectTarget(Creature* creature) { #ifdef __DEBUG__ std::cout << "Selecting target... " << std::endl; #endif if(!isTarget(creature)){ return false; } CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature); if(it == targetList.end()){ //Target not found in our target list. #ifdef __DEBUG__ std::cout << "Target not found in targetList." << std::endl; #endif return false; } if(isHostile() || isSummon()){ if(setAttackedCreature(creature) && !isSummon()){ g_dispatcher.addTask(createTask( boost::bind(&Game::checkCreatureAttack, &g_game, getID()))); } } return setFollowCreature(creature, true); }
bool SimultaneousKeyPresses::FromInfo::isTargetKeyUp(const EventInputQueue::Item& item) const { bool isKeyDown = false; if (! isTarget(isKeyDown, item)) return false; return ! isKeyDown; }
void ForwarderRank::_generateDelegatesFor(const DataObjectRef &dObj, const NodeRef &target, const NodeRefList *other_targets) { List<Pair<NodeRef, bubble_metric_t> > sorted_delegate_list; // Figure out which node to look for: bubble_node_id_t target_id = id_from_string(target->getIdStr()); LABEL_T targetLabel = rib[target_id].first; //RANK_T targetRank = rib[target_id].second; HAGGLE_DBG("HAGGLE_DBG:_generateDelegatesFor node %d string %s label %s\n", target_id, target->getIdStr(), targetLabel.c_str()); for (bubble_rib_t::iterator it = rib.begin();it != rib.end(); it++) { if (it->first != this_node_id && it->first != target_id) { NodeRef delegate = kernel->getNodeStore()->retrieve(id_number_to_nodeid[it->first], true); if (delegate && !isTarget(delegate, other_targets)) { LABEL_T &neighborLabel = it->second.first; RANK_T &neighborRank = it->second.second; HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor neighborLabel=%s, targetLabel=%s\n", neighborLabel.c_str(), targetLabel.c_str()); if (neighborLabel.compare(targetLabel)==0) { //NodeRef delegate = Node::create_with_id(Node::TYPE_PEER, id_number_to_nodeid[it->first].c_str(), "Label delegate node"); sortedNodeListInsert(sorted_delegate_list, delegate, it->second); HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor Label same: Node '%s' is a good delegate for target '%s' [label=%s, rank=%ld]\n", delegate->getName().c_str(), target->getName().c_str(), neighborLabel.c_str(), neighborRank); } } } } // Add up to max_generated_delegates delegates to the result in order of decreasing metric if (!sorted_delegate_list.empty()) { NodeRefList delegates; unsigned long num_delegates = max_generated_delegates; while (num_delegates && sorted_delegate_list.size()) { NodeRef delegate = sorted_delegate_list.front().first; sorted_delegate_list.pop_front(); delegates.push_back(delegate); num_delegates--; } kernel->addEvent(new Event(EVENT_TYPE_DELEGATE_NODES, dObj, target, delegates)); HAGGLE_DBG("HAGGLE_DBG: Forward Generated %lu delegates for target %s\n", delegates.size(), target->getName().c_str()); } else { HAGGLE_DBG("No delegates found for target %s\n", target->getName().c_str()); } }
int SimpleDeadlockDetector::init(const BoardState& s) { std::vector<int> targets; int index = 0; for (auto i = s.begin(); i != s.end(); ++i, ++index) { if (!isTarget(*i) && !isPackageOnTarget(*i)) { continue; } targets.push_back(index); } Log::debug(LOG_GAMEIMPL, "Found %i targets", (int)targets.size()); BoardState copy(s); index = 0; for (auto i = s.begin(); i != s.end(); ++i, ++index) { const char field = *i; if (isPackage(field)) { copy.clearFieldForIndex(index); copy.setFieldForIndex(index, Sokoban::GROUND); Log::debug(LOG_GAMEIMPL, "replaced package with ground at %i", index); } else if (isPackageOnTarget(field)) { copy.clearFieldForIndex(index); copy.setFieldForIndex(index, Sokoban::TARGET); Log::debug(LOG_GAMEIMPL, "replaced packageontarget with target at %i", index); } } #ifdef DEBUG Log::debug(LOG_GAMEIMPL, "board state:\n%s", copy.toString().c_str()); #endif for (int targetIndex : targets) { moveBackwards(copy, targetIndex); } index = 0; for (auto i = copy.begin(); i != copy.end(); ++i, ++index) { const char field = *i; if (!isGround(field) && !isPackage(field)) { continue; } if (_visited.find(index) != _visited.end()) { continue; } #ifdef DEBUG int col; int row; s.getColRowFromIndex(index, col, row); Log::debug(LOG_GAMEIMPL, "Simple deadlock detected at %i:%i", col, row); #endif _deadlocks.insert(index); } Log::info(LOG_GAMEIMPL, "Found %i simple deadlocks", (int)_deadlocks.size()); Log::debug(LOG_GAMEIMPL, "Visited %i fields", (int)_visited.size()); _visited.clear(); return (int)_deadlocks.size(); }
static void gen_M2L_interaction_list(FmmvHandle *FMMV, Box *box, Box **list) { int i,j,k; Box *nb; memset(list, 0, 8*26*sizeof(Box*)); k = 0; for (i=0; i<26; i++) { nb = box->neighbor[i]; if (isTarget(nb) && hasTargetChilds(nb)) { if (nb->noOfXin == -1) { nb->noOfXin = noOfSourceNeighborsWithSourceChilds(nb); for (j=0; j<8; j++) { if (isTarget(nb->child[j])) { list[k] = nb->child[j]; ++(FMMV->noOfStoredXin); if (FMMV->noOfStoredXin>FMMV->maxNoOfStoredXin) { FMMV->maxNoOfStoredXin = FMMV->noOfStoredXin; } } k++; } } else { for (j=0; j<8; j++) { if (isTarget(nb->child[j])) { list[k] = nb->child[j]; } k++; } } } else { k += 8; } } }
bool Monster::selectTarget(Creature* creature) { if (!isTarget(creature)) { return false; } auto it = std::find(targetList.begin(), targetList.end(), creature); if (it == targetList.end()) { //Target not found in our target list. return false; } if (isHostile() || isSummon()) { if (setAttackedCreature(creature) && !isSummon()) { g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID()))); } } return setFollowCreature(creature); }
bool Map::movePlayer (Player* player, char step) { int x; int y; getXY(step, x, y); debug(LOG_SERVER, String::format("move player %i:%i (current: %i:%i)", x, y, player->getCol(), player->getRow())); // move player and move touching packages const int targetCol = player->getCol() + x; const int targetRow = player->getRow() + y; MapTile* package = getPackage(targetCol, targetRow); if (package != nullptr) { const int pCol = targetCol + x; const int pRow = targetRow + y; if (!isFree(pCol, pRow)) { debug(LOG_SERVER, "can't move here - can't move package. target field is blocked"); return false; } if (!package->setPos(pCol, pRow)) { debug(LOG_SERVER, "failed to move the package - thus can't move the player"); return false; } debug(LOG_SERVER, String::format("moved package %i", package->getID())); increasePushes(); rebuildField(); if (isTarget(pCol, pRow)) { package->setState(CavePackerEntityStates::DELIVERED); debug(LOG_SERVER, String::format("mark package as delivered %i", package->getID())); } else if (package->getState() == CavePackerEntityStates::DELIVERED) { debug(LOG_SERVER, String::format("reset package state %i", package->getID())); package->setState(CavePackerEntityStates::NONE); } // sokoban standard - if a package was moved, the move char is uppercase step = toupper(step); } if (!player->setPos(targetCol, targetRow)) { debug(LOG_SERVER, "failed to move the player"); return false; } player->storeStep(step); increaseMoves(); return true; }
bool Actor::searchTarget(TargetSearchType_t searchType /*= TARGETSEARCH_DEFAULT*/) { #ifdef __DEBUG__ std::cout << "Searching target... " << std::endl; #endif std::list<Creature*> resultList; const Position& myPos = getPosition(); for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it){ if(followCreature != (*it) && isTarget(*it)){ if(searchType == TARGETSEARCH_RANDOM || canUseAttack(myPos, *it)){ resultList.push_back(*it); } } } if(!resultList.empty()){ uint32_t index = random_range(0, resultList.size() - 1); CreatureList::iterator it = resultList.begin(); std::advance(it, index); #ifdef __DEBUG__ std::cout << "Selecting target " << (*it)->getName() << std::endl; #endif return selectTarget(*it); } if(searchType == TARGETSEARCH_ATTACKRANGE){ return false; } //lets just pick the first target in the list for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it){ if(followCreature != (*it) && selectTarget(*it)){ #ifdef __DEBUG__ std::cout << "Selecting target " << (*it)->getName() << std::endl; #endif return true; } } return false; }
//services void BurungUnta::Reaction(MakhlukHidup& M) { if (getPosisi() == M.getPosisi()) { if (get_DNA() == M.get_DNA()) { setMati(true); } else { if (isPredator(M.get_DNA())) { setMati(true); } else if (isTarget(M.get_DNA())) { set_tingkat_kekenyangan(get_maks_tingkat_kekenyangan()); } } } else { if (isRadius(2,M.getPosisi())) { if (isPredator(M.get_DNA())) { prosesMempercepat(); gerak_bebas(getPosisi()); } } else { set_Kecepatan(kecepatan_BurungUnta); } } }
bool Monster::selectTarget(Creature* creature) { #ifdef __DEBUG__ std::cout << "Selecting target... " << std::endl; #endif if(!isTarget(creature)) return false; if(!isHostile()) return false; std::string value; if(getStorage(505, value) && value != "-1") { if(creature->isSummon()){ if(value != creature->getMaster()->getName()) return false; }else if(value != creature->getName()) //&& value != "0"){ -- se bugar return false; } CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature); if(it == targetList.end()) { //Target not found in our target list. #ifdef __DEBUG__ std::cout << "Target not found in targetList." << std::endl; #endif return false; } if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon()) Dispatcher::getInstance().addTask(createTask( boost::bind(&Game::checkCreatureAttack, &g_game, getID()))); return setFollowCreature(creature, true); }
void eval_direct(FmmvHandle *FMMV, Box *target, Box *source) #endif { #if ((FMM_KIND==FMM_ST_STANDARD)||(FMM_KIND==FMM_ST_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) if (!(isTarget(target)&&isSource(source))) return; #else if (!(target&&source)||(target->firstTarget>source->firstParticle)) return; #endif if (FMMV->beta!=0){ #ifdef PERIODIC eval_direct_yukawa_periodic(FMMV, target, source, dx, dy, dz); #else eval_direct_yukawa(FMMV, target, source); #endif return; } else { DEFINE_IDA_LOCAL_ALIASES(FMMV) _FLOAT_ x, y, z, one_over_r; _FLOAT_ xi,yi,zi, qj; #if ((FMM_KIND==FMM_STANDARD)||(FMM_KIND==FMM_GRAD) \ ||(FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD)) _FLOAT_ qi; #endif int i,j,ni,nj,i0,j0,j00,j1; #if ((FMM_KIND==FMM_GRAD)||(FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD) \ ||(FMM_KIND==FMM_ST_GRAD)||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) _FLOAT_ one_o_r_3; #endif #if ((FMM_KIND==FMM_GRAD)||(FMM_KIND==FMM_DIPOLE_GRAD) \ ||(FMM_KIND==FMM_ST_GRAD)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) _FLOAT_ qj_o_r_3; #endif #if ((FMM_KIND==FMM_GRAD)||(FMM_KIND==FMM_DIPOLE_GRAD)) _FLOAT_ qi_o_r_3; #endif #if ((FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) _FLOAT_ mxj, myj, mzj; _FLOAT_ m_times_rj; #endif #if ((FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD)) _FLOAT_ mxi, myi, mzi; _FLOAT_ m_times_ri; #endif #if ((FMM_KIND==FMM_DIPOLE_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) _FLOAT_ one_o_r_5; #endif i0 = target->firstTarget; ni = target->noOfTargets; j0 = source->firstParticle; nj = source->noOfParticles; #if ((FMM_KIND==FMM_ST_STANDARD)||(FMM_KIND==FMM_ST_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) j00 =j0; FMMV->noOfDirectInteractions += ni*nj; #else if (i0==j0) { FMMV->noOfDirectInteractions += (ni*(ni-1))/2; } else { FMMV->noOfDirectInteractions += (ni*(ni-1))/2; } #endif j1 = j0+nj; for (i=i0; i<i0+ni; i++) { #ifdef PERIODIC xi = access_tx(i) - dx; yi = access_ty(i) - dy; zi = access_tz(i) - dz; #else xi = access_tx(i); yi = access_ty(i); zi = access_tz(i); #endif #if ((FMM_KIND==FMM_STANDARD)||(FMM_KIND==FMM_GRAD) \ ||(FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD)) qi = access_q(i); #endif #if ((FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD)) mxi = access_mx(i); myi = access_my(i); mzi = access_mz(i); #endif #if ((FMM_KIND==FMM_ST_STANDARD)||(FMM_KIND==FMM_ST_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) #else j00 = (i<j0 ? j0 : i+1); #endif for (j=j00; j<j1; j++) { x = xi - access_x(j); y = yi - access_y(j); z = zi - access_z(j); #if (EVAL_DIRECT_ACCURACY==0) one_over_r = RECIP_SQRT0(x*x + y*y + z*z); #elif (EVAL_DIRECT_ACCURACY==1) one_over_r = RECIP_SQRT1(x*x + y*y + z*z); #elif (EVAL_DIRECT_ACCURACY==2) one_over_r = RECIP_SQRT2(x*x + y*y + z*z); #endif qj = access_q(j); #if ((FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD) \ ||(FMM_KIND==FMM_ST_DIPOLE)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) mxj = access_mx(j); myj = access_my(j); mzj = access_mz(j); one_o_r_3 = one_over_r*one_over_r*one_over_r; m_times_rj = x*mxj + y*myj + z*mzj; access_pot(i) += qj*one_over_r + m_times_rj*one_o_r_3; #if ((FMM_KIND==FMM_DIPOLE)||(FMM_KIND==FMM_DIPOLE_GRAD)) m_times_ri = x*mxi + y*myi + z*mzi; access_pot(j) += qi*one_over_r - m_times_ri*one_o_r_3; #endif #else access_pot(i) += qj*one_over_r; #if ((FMM_KIND==FMM_STANDARD)||(FMM_KIND==FMM_GRAD)) access_pot(j) += qi*one_over_r; #endif #endif #if ((FMM_KIND==FMM_GRAD)||(FMM_KIND==FMM_ST_GRAD)) one_o_r_3 = one_over_r*one_over_r*one_over_r; qj_o_r_3 = qj*one_o_r_3; access_gradx(i) -= x*qj_o_r_3; access_grady(i) -= y*qj_o_r_3; access_gradz(i) -= z*qj_o_r_3; #endif #if (FMM_KIND==FMM_GRAD) qi_o_r_3 = qi*one_o_r_3; access_gradx(j) += x*qi_o_r_3; access_grady(j) += y*qi_o_r_3; access_gradz(j) += z*qi_o_r_3; #endif #if ((FMM_KIND==FMM_DIPOLE_GRAD)||(FMM_KIND==FMM_ST_DIPOLE_GRAD)) one_o_r_5 = one_o_r_3*one_over_r*one_over_r; qj_o_r_3 = qj*one_o_r_3 + 3.0*m_times_rj*one_o_r_5; access_gradx(i) -= x*qj_o_r_3 - mxj*one_o_r_3; access_grady(i) -= y*qj_o_r_3 - myj*one_o_r_3; access_gradz(i) -= z*qj_o_r_3 - mzj*one_o_r_3; #endif #if (FMM_KIND==FMM_DIPOLE_GRAD) qi_o_r_3 = qi*one_o_r_3 - 3.0*m_times_ri*one_o_r_5; access_gradx(j) += x*qi_o_r_3 + mxi*one_o_r_3; access_grady(j) += y*qi_o_r_3 + myi*one_o_r_3; access_gradz(j) += z*qi_o_r_3 + mzi*one_o_r_3; #endif } } } }
/** followSegment **************************************** * follow segment until a turn is found, an end of the line * or the target * * @params left -- by reference if a left branches was found * right -- by reference if a right branches was found * straight -- by reference if a straight line was found */ void followSegment(bool& left, bool& right, bool& straight) { // the value returned from the line sensors int sensorValue = 2000; // the raw sensor values from the 3pi unsigned int sensors[5]; // the change in speed signed int delta_speed = 0; // inital read of the sensor value sensorValue = read_line(sensors, IR_EMITTERS_ON); left = right = false; // while we have a line at center and not at a branch while (!left && !right) { // could have this in the while but this way is slightly easier to read // if we go off the line stop we break out of the loop if (sensorValue > 2000 + sensor_threshold || sensorValue < 2000 - sensor_threshold) { break; } // normalize the sensor value to a motor delta value and turn motors on // delta is between 0 and motor_speed delta_speed = ((motor_speed - (-motor_speed)) * (sensorValue - 0.0))/(4000.0 - 0.0) + (-motor_speed); set_motors(motor_speed + delta_speed, motor_speed - delta_speed); // we need to update the sensor values of the 3pi will just repeat forever sensorValue = read_line(sensors, IR_EMITTERS_ON); left = sensors[left_sensor] > 500; right = sensors[right_sensor] > 500; // if we have a reading to the left or right keep moving forward a bit // this is to fix a big where the 3pi would read one part of a branch but // miss the other because it read one side too fast if (left || right) { // move forward some and read the sensors again set_motors(motor_speed, motor_speed); delay_ms(55); sensorValue = read_line(sensors, IR_EMITTERS_ON); left = sensors[left_sensor] > 500; right = sensors[right_sensor] > 500; } // if we are at target we stop and return from the function if (isTarget()) { set_motors(0,0); done = true; return; } } set_motors(motor_speed, motor_speed); // if we have left and right sensor values we move forward until they are both clear of a line // if only left we wait for the left sensor to clear // if only right we wait for the right sensor to clear // we always break out when we move off the center of the line if (left && right) { while (sensors[center_sensor] > 500 && ((sensors[left_sensor] > 500) == left) && ((sensors[right_sensor] > 500) == right)) { read_line(sensors, IR_EMITTERS_ON); } } else if (left) { while (sensors[center_sensor] > 500 && ((sensors[left_sensor] > 500) == left)) { read_line(sensors, IR_EMITTERS_ON); } } else if (right) { while (sensors[center_sensor] > 500 && ((sensors[right_sensor] > 500) == right)) { read_line(sensors, IR_EMITTERS_ON); } } // check straight now since we are off the intersection straight = (sensors[center_sensor] > 500); // let us know what you are doing Mr. 3pi play_from_program_space(beep_button_b); set_motors(0,0); }
void GTicketInternalClient::PreProcessMessage(int message, GNetTarget & target) { if(target.number==0) return; last_connection_activity = GSERVER->GetClock().Get(); list<GTicketPtr>::iterator pos; pos=find_if(wait.begin(),wait.end(),isTarget(target.number)); if(pos!=wait.end()) { if (target.timestamp > 0) { last_latency = GSERVER->GetClock().Get() - target.timestamp; if (last_latency >= GSECOND_1) { SNetMsgDesc * format; format = msg_base.Get((*pos)->message, ENetCmdInternal); string m; if (format) { m = format->name; } RAPORT("Long Ticket acknowledgment latency: %5lld ms. %s:%s%s", last_latency, GetServiceName(client_service_type), m.c_str(), pos == wait.begin() ? "" : " (not in order)"); } } if(pos!=wait.begin()) { string stable_sequence_identifier = (*pos)->stable_sequence_identifier; wait.erase(pos); list<GTicketPtr>::iterator it; for (it = wait.begin(); it != wait.end(); ) { if ((*it)->OldLoop()) { if (dropped_ticket_callback) { dropped_ticket_callback(**it, ETDR_TooManyRetries); } it = wait.erase(it); } else { it++; } } wait.erase(wait.begin(),find_if(wait.begin(),wait.end(),boost::bind(>icketInternalClient::RollbackTicket,this,_1,target.number,stable_sequence_identifier))); SRAP(WARNING_LOGIC_ROLLBACK); } else { wait.erase(pos); } } else { list<GTicketPtr>::iterator pos; pos=find_if(out.begin(),out.end(),isTarget(target.number)); if(pos!=out.end()) { out.erase(pos); SRAP(WARNING_LOGIC_OUT_ERASE); } } }
bool Monster::searchTarget(TargetSearchType_t searchType /*= TARGETSEARCH_DEFAULT*/) { std::list<Creature*> resultList; const Position& myPos = getPosition(); for (Creature* creature : targetList) { if (followCreature != creature && isTarget(creature)) { if (searchType == TARGETSEARCH_RANDOM || canUseAttack(myPos, creature)) { resultList.push_back(creature); } } } switch (searchType) { case TARGETSEARCH_NEAREST: { Creature* target = nullptr; if (!resultList.empty()) { auto it = resultList.begin(); target = *it; if (++it != resultList.end()) { const Position& targetPosition = target->getPosition(); int32_t minRange = Position::getDistanceX(myPos, targetPosition) + Position::getDistanceY(myPos, targetPosition); do { const Position& pos = (*it)->getPosition(); int32_t distance = Position::getDistanceX(myPos, pos) + Position::getDistanceY(myPos, pos); if (distance < minRange) { target = *it; minRange = distance; } } while (++it != resultList.end()); } } else { int32_t minRange = std::numeric_limits<int32_t>::max(); for (Creature* creature : targetList) { if (!isTarget(creature)) { continue; } const Position& pos = creature->getPosition(); int32_t distance = Position::getDistanceX(myPos, pos) + Position::getDistanceY(myPos, pos); if (distance < minRange) { target = creature; minRange = distance; } } } if (target && selectTarget(target)) { return true; } break; } case TARGETSEARCH_DEFAULT: case TARGETSEARCH_ATTACKRANGE: case TARGETSEARCH_RANDOM: default: { if (!resultList.empty()) { auto it = resultList.begin(); std::advance(it, uniform_random(0, resultList.size() - 1)); return selectTarget(*it); } if (searchType == TARGETSEARCH_ATTACKRANGE) { return false; } break; } } //lets just pick the first target in the list for (Creature* target : targetList) { if (followCreature != target && selectTarget(target)) { return true; } } return false; }
void M2L_ws2(FmmvHandle *FMMV, Box *box) { int s_exp = FMMV->s_exp; SIMD_ALIGN _FLOAT_ X1[8*FMM_S_EXP_MAX]; SIMD_ALIGN _FLOAT_ X2[8*FMM_S_EXP_MAX]; SIMD_ALIGN _FLOAT_ X[13*FMM_S_EXP_MAX]; Box *nb; int i, j, k; Box *IL[992]; Box *neighbor2_list[124]; if (!isSource(box) || !hasSourceChilds(box)) return; gen_M2L_interaction_list2(FMMV, box, IL, neighbor2_list); /*** U/D lists ***/ memset(X + s_exp*XU_all, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XD_all, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XU_D, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XD_D, 0, s_exp*sizeof(_FLOAT_)); M2X(FMMV, 0, box, X1, X2); handle_T0(FMMV, box, T0_UD, X, X1, X2); handle_T1(FMMV, T1_U_ws2, 18, X, XU_D, XU, IL); handle_T1(FMMV, T1_D_ws2, 18, X, XD_D, XD, IL); handle_T1(FMMV, T1_U_ws2+18, 100, X, XU_all, XU, IL); handle_T1(FMMV, T1_D_ws2+18, 100, X, XD_all, XD, IL); /*** N/S lists ***/ memset(X, 0, 12*s_exp*sizeof(_FLOAT_)); M2X(FMMV, 1, box, X1, X2); handle_T0(FMMV, box, T0_NS, X, X1, X2); handle_T1(FMMV, T1_N_ws2, 12, X, XU_D, XN, IL); handle_T1(FMMV, T1_S_ws2, 12, X, XD_D, XS, IL); handle_T1(FMMV, T1_N_ws2+12, 60, X, XU_all, XN, IL); handle_T1(FMMV, T1_S_ws2+12, 60, X, XD_all, XS, IL); handle_T2(FMMV, T2_N_ws2, 24, X, XN, IL); handle_T2(FMMV, T2_S_ws2, 24, X, XS, IL); /*** E/W lists ***/ memset(X, 0, 12*s_exp*sizeof(_FLOAT_)); M2X(FMMV, 2, box, X1, X2); handle_T0(FMMV, box, T0_EW, X, X1, X2); handle_T1(FMMV, T1_E_ws2, 8, X, XU_D, XE, IL); handle_T1(FMMV, T1_W_ws2, 8, X, XD_D, XW, IL); handle_T1(FMMV, T1_E_ws2+8, 36, X, XU_all, XE, IL); handle_T1(FMMV, T1_W_ws2+8, 36, X, XD_all, XW, IL); handle_T2(FMMV, T2_E_ws2, 36, X, XE, IL); handle_T2(FMMV, T2_W_ws2, 36, X, XW, IL); for (i=0; i< 124; i++) { nb = neighbor2_list[i]; if (isTarget(nb) && hasTargetChilds(nb)) { --(nb->noOfXin); --(FMMV->noOfStoredXin); if (nb->noOfXin == 0) { X2L(FMMV, 0, nb, 0); X2L(FMMV, 1, nb, 0); X2L(FMMV, 2, nb, 0); for (j=0; j<8; j++) if (nb->child[j]) { for (k=0; k<6; k++) { FREE_X(FMMV, nb->child[j]->X[k]); nb->child[j]->X[k] = 0; } } } } } }
bool Monster::searchTarget(TargetSearchType_t searchType /*= TARGETSEARCH_DEFAULT*/) { #ifdef __DEBUG__ std::cout << "Searching target... " << std::endl; #endif std::list<Creature*> resultList; const Position& myPos = getPosition(); for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it) { if(followCreature != (*it) && isTarget(*it)) { if(searchType == TARGETSEARCH_RANDOM || canUseAttack(myPos, *it)) resultList.push_back(*it); } } switch(searchType) { case TARGETSEARCH_NEAREAST: { Creature* target = NULL; int32_t minRange = -1; for(std::list<Creature*>::iterator it = resultList.begin(); it != resultList.end(); ++it) { const Position& pos = (*it)->getPosition(); if(minRange == -1 || std::max(std::abs(myPos.x - pos.x), std::abs(myPos.y - pos.y)) < minRange) { target = *it; minRange = std::max(std::abs(myPos.x - pos.x), std::abs(myPos.y - pos.y)); } } if(target && selectTarget(target)) return true; break; } case TARGETSEARCH_DEFAULT: case TARGETSEARCH_ATTACKRANGE: case TARGETSEARCH_RANDOM: default: { if(!resultList.empty()) { uint32_t index = random_range(0, resultList.size() - 1); CreatureList::iterator it = resultList.begin(); std::advance(it, index); #ifdef __DEBUG__ std::cout << "Selecting target " << (*it)->getName() << std::endl; #endif return selectTarget(*it); } if(searchType == TARGETSEARCH_ATTACKRANGE) return false; break; } } //lets just pick the first target in the list for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it) { if(followCreature != (*it) && selectTarget(*it)) { #ifdef __DEBUG__ std::cout << "Selecting target " << (*it)->getName() << std::endl; #endif return true; } } return false; }
void M2L_ws2_reduced(FmmvHandle *FMMV, Box *box0) { int s_exp = FMMV->s_exp; SIMD_ALIGN _FLOAT_ X1[8*FMM_S_EXP_MAX]; SIMD_ALIGN _FLOAT_ X2[8*FMM_S_EXP_MAX]; SIMD_ALIGN _FLOAT_ X[13*FMM_S_EXP_MAX]; SIMD_ALIGN _FLOAT_ z1[FMM_S_EXP_MAX]; Box *nb; int i, j, k, kk; Box *IL[208]; Box *box; Box *ILR[98]; Box *neighbor2_list[124]; if (!((FMMV->periodicBoundaryConditions)&&(box0->level==-1))) { if (!isSource(box0) || !hasSourceChilds(box0)) return; for (i=0; i<26; i++) { nb = box0->neighbor[i]; if (isTarget(nb) && hasTargetChilds(nb) && (nb->noOfXin2 == -1)) { nb->noOfXin2 = noOfSourceNeighborsWithSourceChilds(nb); ++(FMMV->noOfStoredXin); if (FMMV->noOfStoredXin>FMMV->maxNoOfStoredXin) { FMMV->maxNoOfStoredXin = FMMV->noOfStoredXin; } } } } for (k=0; k<8; k++) { if ((FMMV->periodicBoundaryConditions)&&(box0->level==-1)&&(k==1)) { break; } box = box0->child[k]; if (!isSource(box) || !hasSourceChilds(box)) continue; gen_M2L_interaction_list2(FMMV, box, IL, neighbor2_list); for (i=0; i<124-26; i++) { nb = neighbor2_list[i+26]; if (isTarget(nb) && hasTargetChilds(nb)) { ILR[i] = nb; } else { ILR[i] = 0; } } /*** U/D lists ***/ memset(X + s_exp*XU_all, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XD_all, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XU_D, 0, s_exp*sizeof(_FLOAT_)); memset(X + s_exp*XD_D, 0, s_exp*sizeof(_FLOAT_)); M2X(FMMV, 0, box, X1, X2); handle_T0(FMMV, box, T0_UD, X, X1, X2); handle_T1(FMMV, T1_U_ws2, 18, X, XU_D, XU, IL); handle_T1(FMMV, T1_D_ws2, 18, X, XD_D, XD, IL); handle_T1_reduced(FMMV, T1_U_ws2_reduced, 12, X, XU_all, XU, ILR); handle_T1_reduced(FMMV, T1_D_ws2_reduced, 12, X, XD_all, XD, ILR); if (ILR[ir_0_0_8]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XU_all, z1); ILR[ir_0_0_8]->X2[XU] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_0_0_8]->X2[XU]); } if (ILR[ir_0_0_m8]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XD_all, z1); ILR[ir_0_0_m8]->X2[XD] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_0_0_m8]->X2[XD]); } /*** N/S lists ***/ memset(X, 0, 12*s_exp*sizeof(_FLOAT_)); M2X(FMMV, 1, box, X1, X2); handle_T0(FMMV, box, T0_NS, X, X1, X2); handle_T1(FMMV, T1_N_ws2, 12, X, XU_D, XN, IL); handle_T1(FMMV, T1_S_ws2, 12, X, XD_D, XS, IL); handle_T1_reduced(FMMV, T1_N_ws2_reduced, 7, X, XU_all, XN, ILR); handle_T1_reduced(FMMV, T1_S_ws2_reduced, 7, X, XD_all, XS, ILR); if (ILR[ir_0_8_0]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XU_all, z1); ILR[ir_0_8_0]->X2[XN] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_0_8_0]->X2[XN]); } if (ILR[ir_0_m8_0]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XD_all, z1); ILR[ir_0_m8_0]->X2[XS] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_0_m8_0]->X2[XS]); } handle_T2(FMMV, T2_N_ws2, 24, X, XN, IL); handle_T2(FMMV, T2_S_ws2, 24, X, XS, IL); /*** E/W lists ***/ memset(X, 0, 12*s_exp*sizeof(_FLOAT_)); M2X(FMMV, 2, box, X1, X2); handle_T0(FMMV, box, T0_EW, X, X1, X2); handle_T1(FMMV, T1_E_ws2, 8, X, XU_D, XE, IL); handle_T1(FMMV, T1_W_ws2, 8, X, XD_D, XW, IL); handle_T1_reduced(FMMV, T1_E_ws2_reduced, 4, X, XU_all, XE, ILR); handle_T1_reduced(FMMV, T1_W_ws2_reduced, 4, X, XD_all, XW, ILR); if (ILR[ir_8_0_0]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XU_all, z1); ILR[ir_8_0_0]->X2[XE] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_8_0_0]->X2[XE]); } if (ILR[ir_m8_0_0]) { VEC_MUL(s_exp, FMMV->D_X2X + s_exp*dr_0_0_8, X + s_exp*XD_all, z1); ILR[ir_m8_0_0]->X2[XW] = VEC_ADD2(FMMV, s_exp, z1, ILR[ir_m8_0_0]->X2[XW]); } handle_T2(FMMV, T2_E_ws2, 36, X, XE, IL); handle_T2(FMMV, T2_W_ws2, 36, X, XW, IL); if (!((FMMV->periodicBoundaryConditions)&&(box0->level==-1))) { for (i=0; i<26; i++) { //TODO: check 26! nb = neighbor2_list[i]; if (isTarget(nb) && hasTargetChilds(nb)) { --(nb->noOfXin); --(FMMV->noOfStoredXin); if (nb->noOfXin == 0) { X2L(FMMV, 0, nb, 0); X2L(FMMV, 1, nb, 0); X2L(FMMV, 2, nb, 0); for (j=0; j<8; j++) if (nb->child[j]) { for (kk=0; kk<6; kk++) { FREE_X(FMMV, nb->child[j]->X[kk]); nb->child[j]->X[kk] = 0; } } } } } } } if ((FMMV->periodicBoundaryConditions)&&(box0->level==-1)) { box = box0->child[0]; /* box == root */ X2L(FMMV, 0, box, 0); X2L(FMMV, 1, box, 0); X2L(FMMV, 2, box, 0); for (j=0; j<8; j++) if (box->child[j]) { for (k=0; k<6; k++) { FREE_X(FMMV, box->child[j]->X[k]); box->child[j]->X[k] = 0; } } for (j=1; j<8; j++) { box0->child[j]= 0; } X2L(FMMV, 0, box0, 1); X2L(FMMV, 1, box0, 1); X2L(FMMV, 2, box0, 1); for (k=0; k<6; k++) { FREE_X(FMMV, box->X2[k]); box->X2[k] = 0; } } else { for (i=0; i<26; i++) { nb = box0->neighbor[i]; if (isTarget(nb) && hasTargetChilds(nb)) { --(nb->noOfXin2); --(FMMV->noOfStoredXin); if (nb->noOfXin2 == 0) { X2L(FMMV, 0, nb, 1); X2L(FMMV, 1, nb, 1); X2L(FMMV, 2, nb, 1); for (j=0; j<8; j++) if (nb->child[j]) { for (k=0; k<6; k++) { FREE_X(FMMV, nb->child[j]->X2[k]); nb->child[j]->X2[k] = 0; } } } } } } }
bool Monster::searchTarget(TargetSearchType_t searchType /*= TARGETSEARCH_DEFAULT*/) { #ifdef __DEBUG__ std::clog << "Searching target... " << std::endl; #endif std::list<Creature*> resultList; const Position& myPos = getPosition(); for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it) { if(followCreature != (*it) && isTarget(*it) && (searchType == TARGETSEARCH_RANDOM || canUseAttack(myPos, *it))) resultList.push_back(*it); } switch(searchType) { case TARGETSEARCH_NEAREST: { Creature* target = NULL; int32_t range = -1; for(CreatureList::iterator it = resultList.begin(); it != resultList.end(); ++it) { int32_t tmp = std::max(std::abs(myPos.x - (*it)->getPosition().x), std::abs(myPos.y - (*it)->getPosition().y)); if(range >= 0 && tmp >= range) continue; target = *it; range = tmp; } if(target && selectTarget(target)) return target; break; } default: { if(!resultList.empty()) { CreatureList::iterator it = resultList.begin(); std::advance(it, random_range(0, resultList.size() - 1)); #ifdef __DEBUG__ std::clog << "Selecting target " << (*it)->getName() << std::endl; #endif return selectTarget(*it); } if(searchType == TARGETSEARCH_ATTACKRANGE) return false; break; } } //lets just pick the first target in the list for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it) { if(followCreature == (*it) || !selectTarget(*it)) continue; #ifdef __DEBUG__ std::clog << "Selecting target " << (*it)->getName() << std::endl; #endif return true; } return false; }
void L2L(FmmvHandle *FMMV, Box *box) { int p = FMMV->pL; int len0 = (p+1)*(p+1); int len = (p+1)*(p+2); int *P_RT = FMMV->P_LRT; int *P_riri2rrii = FMMV->P_Lriri2rrii; _FLOAT_ x1[(FMM_P_MAX+1)*(FMM_P_MAX+2)]; _FLOAT_ x2[(FMM_P_MAX+1)*(FMM_P_MAX+2)]; _FLOAT_ xx[(FMM_P_MAX+1)*(FMM_P_MAX+2)]; if (!isTarget(box)||!box->L) return; if (isTarget(box->child[NEU])) { Rz_pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_pi_minus_theta, x1, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_minus_pi_minus_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_pi4(p, x2, x1); box->child[NEU]->L = VEC_ADD2(FMMV, len, x1, box->child[NEU]->L); if (isTarget(box->child[SWD])) { Ry_pi(p, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_pi4(p, x2, x1); box->child[SWD]->L = VEC_ADD2(FMMV, len, x1, box->child[SWD]->L); } } else if (isTarget(box->child[SWD])) { Rz_pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_minus_theta, x1, x2); perm(len0, P_RT, x2, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_pi4(p, x2, x1); box->child[SWD]->L = VEC_ADD2(FMMV, len, x1, box->child[SWD]->L); } if (isTarget(box->child[SEU])) { Rz_minus_pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_pi_minus_theta, x1, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_minus_pi_minus_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_pi4(p, x2, x1); box->child[SEU]->L = VEC_ADD2(FMMV, len, x1, box->child[SEU]->L); if (isTarget(box->child[NWD])) { Ry_pi(p, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_pi4(p, x2, x1); box->child[NWD]->L = VEC_ADD2(FMMV, len, x1, box->child[NWD]->L); } } else if (isTarget(box->child[NWD])) { Rz_minus_pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_minus_theta, x1, x2); perm(len0, P_RT, x2, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_pi4(p, x2, x1); box->child[NWD]->L = VEC_ADD2(FMMV, len, x1, box->child[NWD]->L); } if (isTarget(box->child[NWU])) { Rz_3pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_pi_minus_theta, x1, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_minus_pi_minus_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_3pi4(p, x2, x1); box->child[NWU]->L = VEC_ADD2(FMMV, len, x1, box->child[NWU]->L); if (isTarget(box->child[SED])) { Ry_pi(p, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_3pi4(p, x2, x1); box->child[SED]->L = VEC_ADD2(FMMV, len, x1, box->child[SED]->L); } } else if (isTarget(box->child[SED])) { Rz_3pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_minus_theta, x1, x2); perm(len0, P_RT, x2, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_minus_3pi4(p, x2, x1); box->child[SED]->L = VEC_ADD2(FMMV, len, x1, box->child[SED]->L); } if (isTarget(box->child[SWU])) { Rz_minus_3pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_pi_minus_theta, x1, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_minus_pi_minus_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_3pi4(p, x2, x1); box->child[SWU]->L = VEC_ADD2(FMMV, len, x1, box->child[SWU]->L); if (isTarget(box->child[NED])) { Ry_pi(p, xx); perm(len0, P_RT, xx, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_3pi4(p, x2, x1); box->child[NED]->L = VEC_ADD2(FMMV, len, x1, box->child[NED]->L); } } else if (isTarget(box->child[NED])) { Rz_minus_3pi4(p, box->L, x2); perm(len0, P_riri2rrii, x2, x1); Ry(p, FMMV->Ry_minus_theta, x1, x2); perm(len0, P_RT, x2, x1); Tz_L2L(FMMV, x1); perm_inv(len0, P_RT, x1, x2); Ry(p, FMMV->Ry_theta, x2, x1); perm_inv(len0, P_riri2rrii, x1, x2); Rz_3pi4(p, x2, x1); box->child[NED]->L = VEC_ADD2(FMMV, len, x1, box->child[NED]->L); } }
void X2L(FmmvHandle *FMMV, int dir, Box *box, int reduced) { int p = FMMV->pL; int len0 = (p+1)*(p+1); int len0m = len0/2; int len0p = len0 - len0m; int len2 = (2*p+1)*FMMV->s_eps; int s_exp2 = FMMV->s_exp/2; SIMD_ALIGN _FLOAT_ x1[2*(FMM_P_MAX+1)*(FMM_P_MAX+2)]; SIMD_ALIGN _FLOAT_ x2[2*(FMM_P_MAX+1)*(FMM_P_MAX+2)+3]; SIMD_ALIGN _FLOAT_ xx[2*(FMM_P_MAX+1)*(FMM_P_MAX+2)]; SIMD_ALIGN _FLOAT_ y1[2*4*(FMM_P_MAX+1)*FMM_S_EPS_MAX]; SIMD_ALIGN _FLOAT_ y2[2*4*(FMM_P_MAX+1)*FMM_S_EPS_MAX]; SIMD_ALIGN _FLOAT_ y3[2*2*(FMM_P_MAX+1)*FMM_S_EPS_MAX]; SIMD_ALIGN _FLOAT_ z1[2*FMM_S_EXP_MAX]; Box* child; _FLOAT_ *X1[8] = {zeros, zeros, zeros, zeros, zeros, zeros, zeros, zeros}; _FLOAT_ *X2[8] = {zeros, zeros, zeros, zeros, zeros, zeros, zeros, zeros}; _FLOAT_ **L_p[8] = {0,0,0,0,0,0,0,0}; int i, k, k1, k2, missing, f; int q[8]; if (!isTarget(box)) return; k = 0; for (i=0; i<8; i++) { child = box->child[i]; if (isTarget(child)) { L_p[i] = &(child->L); f = 0; if (reduced) { switch (dir) { case 0: /* UD */ if (child->X2[XU]) {X1[i] = child->X2[XU]; f=1;} if (child->X2[XD]) {X2[i] = child->X2[XD]; f=1;} break; case 1: /* NS */ if (child->X2[XN]) {X1[i] = child->X2[XN]; f=1;} if (child->X2[XS]) {X2[i] = child->X2[XS]; f=1;} break; case 2: /* EW */ if (child->X2[XE]) {X1[i] = child->X2[XE]; f=1;} if (child->X2[XW]) {X2[i] = child->X2[XW]; f=1;} break; } } else { switch (dir) { case 0: /* UD */ if (child->X[XU]) {X1[i] = child->X[XU]; f=1;} if (child->X[XD]) {X2[i] = child->X[XD]; f=1;} break; case 1: /* NS */ if (child->X[XN]) {X1[i] = child->X[XN]; f=1;} if (child->X[XS]) {X2[i] = child->X[XS]; f=1;} break; case 2: /* EW */ if (child->X[XE]) {X1[i] = child->X[XE]; f=1;} if (child->X[XW]) {X2[i] = child->X[XW]; f=1;} break; } } if (f) { q[k] = i; k++; } else { missing = i; } } else missing=i; } if (k==0) return; for (i=k; i<8; i++) q[i] = missing; for (i=0; i<(k&1?(k>>1)+1:k>>1); i++) { k1 = (X1[q[2*i]]!=zeros)||(X1[q[2*i+1]]!=zeros); k2 = (X2[q[2*i]]!=zeros)||(X2[q[2*i+1]]!=zeros); if (k1&&k2) { P_X_2rrii2riri_simd2(s_exp2, X1[q[2*i]], X1[q[2*i+1]], z1); F_X2L_simd2(FMMV, z1, y2); perm_simd2(len2, FMMV->P_FV, y2, y1); neg_simd2(FMMV->len_neg_V, FMMV->neg_V, y1); P_X_2rrii2riri_simd2(s_exp2, X2[q[2*i]], X2[q[2*i+1]], z1); F_X2L_simd2(FMMV, z1, y2); perm_simd2(len2, FMMV->P_FV, y2, y3); neg_simd2(FMMV->len_neg_V, FMMV->neg_V, y3); VEC_COPY(2*len2, y1, y2); VEC_ADD(2*len2, y3, y1, y1); VEC_SUB(2*len2, y2, y3, y2); CXL_plus_simd2(FMMV, y1, x1, reduced); CXL_minus_simd2(FMMV, y2, x2, reduced); perm_inv_simd2(len0p, FMMV->P_LRT_plus, x1, xx); perm_inv_simd2(len0m, FMMV->P_LRT_minus, x2, xx); } else if (k1) { P_X_2rrii2riri_simd2(s_exp2, X1[q[2*i]], X1[q[2*i+1]], z1); F_X2L_simd2(FMMV, z1, y1); perm_simd2(len2, FMMV->P_FV, y1, y2); neg_simd2(FMMV->len_neg_V, FMMV->neg_V, y2); CXL_simd2(FMMV, y2, x1, reduced); perm_inv_simd2(len0, FMMV->P_LRT, x1, xx); } else if (k2) { P_X_2rrii2riri_simd2(s_exp2, X2[q[2*i]], X2[q[2*i+1]], z1); F_X2L_simd2(FMMV, z1, y1); perm_simd2(len2, FMMV->P_FV, y1, y2); neg_simd2(FMMV->len_neg_V, FMMV->neg_V, y2); CXL_simd2(FMMV, y2, x1, reduced); perm_inv_simd2(len0, FMMV->P_LRT, x1, xx); Ry_pi_simd2(p, xx); } if (k1||k2) { scale_X_simd2(p, xx, box->level+1); switch (dir) { case 0: /* UD */ P_rrii2riri2_simd2(FMMV, p, xx, L_p[q[2*i]], L_p[q[2*i+1]], x1); break; case 1: /* NS */ Ry_simd2(p, FMMV->Ry_minus_pi2, xx, x1); Rz_pi2_rrii_simd2(p, x1, xx); P_rrii2riri2_simd2(FMMV, p, xx, L_p[q[2*i]], L_p[q[2*i+1]], x1); break; case 2: /* EW */ Ry_simd2(p, FMMV->Ry_pi2, xx, x1); P_rrii2riri2_simd2(FMMV, p, x1, L_p[q[2*i]], L_p[q[2*i+1]], xx); break; } } } }