Exemple #1
0
void cacti_setup() {
  const char *technology = SescConf->getCharPtr("","technology");
  fprintf(stderr,"technology = [%s]\n",technology);
  tech = SescConf->getInt(technology,"tech");
  fprintf(stderr, "tech : %9.0fnm\n" , tech);
  tech /= 1000;

#ifdef ESESC_ESESCTHERM
  sescTherm = new ThermTrace(0); // No input trace, just read conf
#endif

  const char *proc    = SescConf->getCharPtr("","cpusimu",0);
  const char *l1Cache = SescConf->getCharPtr(proc,"DL1");
  
  const char *l1CacheSpace = strstr(l1Cache," ");
  char *l1Section = strdup(l1Cache);
  if (l1CacheSpace)
    l1Section[l1CacheSpace - l1Cache] = 0;

  res_memport = SescConf->getInt(l1Section,"numPorts");

  xcacti_flp xflp;
  double l1Energy = getEnergy(l1Section, &xflp);

  double WattchL1Energy = SescConf->getDouble("","wattchDataCacheEnergy");

 #ifdef L2INCLUDED
  const char *l2Cache = SescConf->getCharPtr(proc,"DL1");

  const char *l2CacheSpace = strstr(l2Cache," ");
  char *l2Section = strdup(l2Cache);
  if (l2CacheSpace)
    l2Section[l2CacheSpace - l2Cache] = 0;

  res_memport = SescConf->getInt(l2Section,"numPorts");

  double l2Energy = getEnergy(l2Section, &xflp);

  double WattchL2Energy = SescConf->getDouble("","wattchDataCacheEnergy");
  if (WattchL2Energy) {
    cacti2wattchFactor = WattchL2Energy/l1Energy;
    fprintf(stderr,"wattch2cacti Factor %g\n", cacti2wattchFactor);
  }else{
    fprintf(stderr,"-----WARNING: No wattch correction factor\n");
  }
#endif

  if (WattchL1Energy) {
   // wattch2cactiFactor = WattchL1Energy/l1Energy;
   cacti2wattchFactor = WattchL1Energy/l1Energy;
   // fprintf(stderr,"wattch2cacti Factor %g\n", wattch2cactiFactor);
    fprintf(stderr,"cacti2wattch Factor %g\n", cacti2wattchFactor);
  }else{
    fprintf(stderr,"-----WARNING: No wattch correction factor\n");
  }

  processorCore();

  iterate();
}
SupportRenumbering makeBandedSimulatedAnnealing(const std::vector<SNPSupport>& supports, SupportRenumbering start, int iterations, double temperature, double temperatureMultiplier)
{
	SupportRenumbering best = start;
	double bestEnergy = getEnergy(renumberSupports(supports, best));
	SupportRenumbering current = best;
	double currentEnergy = bestEnergy;

    std::mt19937 mt {(size_t)std::chrono::system_clock::now().time_since_epoch().count()};
	std::uniform_real_distribution<double> changeCurrent {0, 1};

	for (int i = 0; i < iterations; i++)
	{
		SupportRenumbering newRenumbering = getNeighbor(current, supports);
		assert(newRenumbering.checkValidity());
		double newEnergy = getEnergy(renumberSupports(supports, newRenumbering));
		if (newEnergy < bestEnergy)
		{
			best = newRenumbering;
			bestEnergy = newEnergy;
			std::cerr << "iteration " << i << " new best " << bestEnergy << "\n";
		}
		if (changeCurrent(mt) < std::min(1.0, exp((currentEnergy-newEnergy)/temperature)))
		{
			current = newRenumbering;
			currentEnergy = newEnergy;
		}
		temperature *= temperatureMultiplier;
	}
	return best;
}
Exemple #3
0
Droid& Droid::operator << (size_t & o)
{
  if (getEnergy() < 100)
    {
      while (getEnergy() < 100)
        {
          this->Energy += 1;
          o--;
        }
    }
  return (*this);
}
Exemple #4
0
/**
 * Turns of the burner and logs the energyUsed.
 */
void Burner::turnOff(){
	LoggerPtr log(Logger::getLogger("Burner"));	
	LOG4CXX_DEBUG(log, "Burner("<< burnerID << ") OFF (Energy Used:" << getEnergy() << ")");
				
	modelOn_ = false;
	wattsPerTick_ = 0;
}
Exemple #5
0
double getEnergy(const char *section, xcacti_flp *xflp) {
  // set the input
  int cache_size = SescConf->getInt(section,"size") ;
  int block_size = SescConf->getInt(section,"bsize") ;
  int assoc = SescConf->getInt(section,"assoc") ;
  int read_ports = SescConf->getInt(section,"numPorts");
  int readwrite_ports = 1;
  int subbanks = 1;
  int bits = 32;

  if(SescConf->checkInt(section,"subBanks"))
    subbanks = SescConf->getInt(section,"subBanks");

  if(SescConf->checkInt(section,"bits"))
    bits = SescConf->getInt(section,"bits");

  printf("Module [%s]...\n", section);

  return getEnergy(cache_size
                   ,block_size
                   ,assoc
                   ,read_ports
                   ,readwrite_ports
                   ,subbanks
                   ,1
                   ,bits
                   ,xflp);

}
Exemple #6
0
void Entity::save(QDataStream &s, int version)
{
    s << mNeuralNetwork;
    s << mX;
    s << mY;
    s << mAge;
    s << mGeneration;
    s << getHealth();
    s << getEnergy();
    s << getHydration();
    s << getValueStore1();
    s << getValueStore2();
    s << getValueStore3();
    s << getValueStore4();

    s << getActionMoveLeft();
    s << getActionMoveRight();
    s << getActionMoveUp();
    s << getActionMoveDown();
    s << getActionAttackLeft();
    s << getActionAttackRight();
    s << getActionAttackUp();
    s << getActionAttackDown();
    s << getActionEatV();
    s << getActionEatM();
    s << getActionDrink();
    s << getActionSplit();
    s << getActionResult();
}
 double
 ParticleLine::IPUP( int const whichComponent ) const
 {
   if( 1 == whichComponent )
   {
     return getXMomentum();
   }
   else if( 2 == whichComponent )
   {
     return getYMomentum();
   }
   else if( 3 == whichComponent )
   {
     return getZMomentum();
   }
   else if( 4 == whichComponent )
   {
     return getEnergy();
   }
   else if( 5 == whichComponent )
   {
     return getMass();
   }
   else
   {
     return BOL::UsefulStuff::notANumber;
   }
 }
int main(int argc, char** argv)
{
	std::vector<SNPSupport> supports = loadSupports(argv[1]);

	std::cerr << "starting score " << getEnergy(supports) << "\n";

	SupportRenumbering numbering = getIdentityRenumbering(supports);

	std::cerr << "row distance banding\n";
	numbering = makeBandedRowDistance(supports, numbering, std::stol(argv[8]), std::stol(argv[9]));
	assert(numbering.checkValidity());

	std::cerr << "barycentric banding\n";
	numbering = makeBandedBarycentric(supports, numbering, std::stol(argv[2]));
	assert(numbering.checkValidity());

	std::cerr << "annealing banding\n";
	numbering = makeBandedSimulatedAnnealing(supports, numbering, std::stoi(argv[7]), std::stod(argv[5]), std::stod(argv[6]));
	assert(numbering.checkValidity());

	std::cerr << "writing output\n";
	SupportRenumbering renumbering = numbering;
	std::vector<SNPSupport> result = renumberSupports(supports, renumbering);
	assert(renumbering.checkValidity());
	writeSupports(result, argv[3]);
	writeRenumbering(renumbering, argv[4]);
}
bool CoopCutMinimizer::writeLabeling_Stefanie(const char* labelingFile, const double elapsedTime) const
{
	//check if there is a solution
	if (!resultsComputed_) return false;

	//create the buffer array
	signed char* buffer = (signed char*) malloc(nodeNumber_ * sizeof(signed char));
	for(int iNode = 0; iNode < nodeNumber_; ++iNode)
		buffer[iNode] = (signed char)labeling_[iNode];

	// write out node labels
	FILE* of = fopen(labelingFile, "wb");
	fwrite(&nodeNumber_, sizeof(int), 1, of);
	fwrite(buffer, sizeof(signed char), nodeNumber_, of);

	// write elapsedTime to the file
	fwrite(&elapsedTime, sizeof(double), 1, of);

	// write energy to a file
	double energy = getEnergy();
	fwrite(&energy, sizeof(double), 1, of);

	fclose(of);
	free(buffer);
  
	return true;
}
Exemple #10
0
void
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::oneStep( unsigned int i1, unsigned int i2 )
{
  ModuloComputer< int> mc( size() );
  std::vector<double> grad ( getFormerGradient() );
  
  double mid;
  unsigned int i = i1; 
  do 
    {
      unsigned int inext = mc.next( i );
      ValueInfo & vi = this->rw( i );
      double val = vi.oldValue;
      mid = AngleComputer::cast( val - myStep*grad[ i ] );
      if ( AngleComputer::less( mid, vi.min ) ) mid = vi.min;
      if ( AngleComputer::less( vi.max, mid ) ) mid = vi.max;
      vi.value = mid;
      // go to next.
      i = inext;
    }
  while ( i != i2 );

  double E1 = getFormerEnergy( i1, i2 );
  double E2 = getEnergy( i1, i2 );
  if ( E1 <= E2 )
    {
      myStep /= 4.0;
    }
  else
    {
      /* doubling step. */
      myStep *= 2.0;
    }
}
int HongLian::JieJiaoJieZao(int playerID)
{
	if(playerID != id || 0 == getEnergy() || !tap){
		return GE_SUCCESS;
	}
	addAction(ACTION_ATTACK_MAGIC, JIE_JIAO_JIE_ZAO);
	return GE_SUCCESS;
}
	AlphaReal SingleStumpLearner::run( int colIdx )
	{
		const int numClasses = _pTrainingData->getNumClasses();
		const int numColumns = _pTrainingData->getNumAttributes();
		
		// set the smoothing value to avoid numerical problem
		// when theta=0.
		setSmoothingVal( 1.0 / (AlphaReal)_pTrainingData->getNumExamples() * 0.01 );
		
		vector<sRates> mu(numClasses); // The class-wise rates. See BaseLearner::sRates for more info.
		vector<AlphaReal> tmpV(numClasses); // The class-wise votes/abstentions
		
		AlphaReal tmpAlpha;
		
		AlphaReal bestEnergy = numeric_limits<AlphaReal>::max();
		
		StumpAlgorithm<FeatureReal> sAlgo(numClasses);
		sAlgo.initSearchLoop(_pTrainingData);
		
		AlphaReal halfTheta;
		if ( _abstention == ABST_REAL || _abstention == ABST_CLASSWISE )
			halfTheta = _theta/2.0;
		else
			halfTheta = 0;
		
		int numOfDimensions = _maxNumOfDimensions;
		
		
		const pair<vpIterator,vpIterator> dataBeginEnd = 
		static_cast<SortedData*>(_pTrainingData)->getFileteredBeginEnd( colIdx );
		
		
		const vpIterator dataBegin = dataBeginEnd.first;
		const vpIterator dataEnd = dataBeginEnd.second;
		
		// also sets mu, tmpV, and bestHalfEdge
		_threshold = sAlgo.findSingleThresholdWithInit(dataBegin, dataEnd, _pTrainingData, 
													   halfTheta, &mu, &tmpV);
		
		bestEnergy = getEnergy(mu, tmpAlpha, tmpV);
		
		_alpha = tmpAlpha;
		_v = tmpV;
		_selectedColumn = colIdx;
		
		if ( _selectedColumn != -1 )
		{
			stringstream thresholdString;
			thresholdString << _threshold;
			_id = _pTrainingData->getAttributeNameMap().getNameFromIdx(_selectedColumn) + thresholdString.str();	
		} else {
			bestEnergy = numeric_limits<float>::signaling_NaN();
		}
		
		return bestEnergy;
		
	}
Exemple #13
0
double nodeCollection::findInitEnergy(exponentVar& expVar, OctTree* octTree){
	
	std::vector<blackHoleNode*>* vect = &nodeVec;
	double s = 0.0;

	for(unsigned int i = 0; i < nodeVec.size(); i++){
		s += getEnergy((*vect)[i], expVar, octTree);
	}
	return s;
}
Exemple #14
0
	AlphaReal BaseLearner::getEnergy(AlphaReal eps_min, AlphaReal eps_pls, AlphaReal alpha, AlphaReal theta) const
	{
		// if theta == 0
		if ( nor_utils::is_zero(theta) )
			return getEnergy( eps_min, eps_pls );

		return exp(alpha * theta) * ( eps_min * exp(alpha) +  eps_pls * exp(-alpha)
			+  (1 - eps_min - eps_pls) );

	}
Exemple #15
0
/** 
 * @details 
 * This function should be used when the next string in a stream is required to 
 * be an energy value. If a string cannot be extracted from the stream (end of 
 * file) or the string isn't a positive real number, this method records an 
 * error via the logger specifying the sort of failure and throws an exception. 
*/ 
double
njoy::utility::stream::getEnergy( std::istream& is,
				  const std::string& name ){
  bool found;
  const double energy = getEnergy(is, found, name);
  if ( not found ){
    Log::error( "{} argument could not be read from input.", name );
    throw std::exception();
  }
  return energy;
}
Exemple #16
0
NNType Entity::takeEnergy(NNType e)
{
    NNType t = getEnergy();
    if (t > e) {
        setEnergy(t - e);
        return e;
    }
    else {
        setEnergy(0);
        return t;
    }
}
int ShenGuan::p_boot(int &step, int currentPlayerID)
{
	int ret = GE_INVALID_STEP;
	step = SHEN_SHENG_QI_YUE;
	if (currentPlayerID != id || getEnergy() == 0 || crossNum == 0)
		return GE_SUCCESS;
	ret = ShenShengQiYue();
	if(toNextStep(ret)){
		step = STEP_DONE;
	}
	return ret;
}
Exemple #18
0
void iterate()
{
  std::vector<char *> sections;
  std::vector<char *>::iterator it; 

  SescConf->getAllSections(sections) ;

  char line[100] ;
  for(it = sections.begin();it != sections.end(); it++) {
    const char *block = *it;

    if (!SescConf->checkCharPtr(block,"deviceType")) 
      continue;

    const char *name = SescConf->getCharPtr(block,"deviceType") ;

    if(strcasecmp(name,"vbus")==0){
      SescConf->updateRecord(block,"busEnergy",0.0) ; // FIXME: compute BUS energy
    }else if (strcasecmp(name,"niceCache") == 0) {
      // No energy for ideal caches (DRAM bank)
      SescConf->updateRecord(block, "RdHitEnergy"   ,0.0);
      SescConf->updateRecord(block, "RdMissEnergy"  ,0.0);
      SescConf->updateRecord(block, "WrHitEnergy"   ,0.0);
      SescConf->updateRecord(block, "WrMissEnergy"  ,0.0);
      
    }else if(strstr(name,"cache") 
             || strstr(name,"tlb")
             || strstr(name,"mem")
             || strstr(name,"dir") 
             || !strcmp(name,"revLVIDTable") ) {

      xcacti_flp xflp;
      double eng = getEnergy(block, &xflp);

#ifdef SESC_SESCTHERM2
      if (SescConf->checkCharPtr(block,"blockName")) {
        const char *blockName = SescConf->getCharPtr(block,"blockName");
        MSG("%s (block=%s) has blockName %s",name, block, blockName);
        update_layout(blockName, &xflp);
      }
#else
      // write it
      SescConf->updateRecord(block, "RdHitEnergy"   ,eng);
      SescConf->updateRecord(block, "RdMissEnergy"  ,eng * 2); // Rd miss + lineFill
      SescConf->updateRecord(block, "WrHitEnergy"   ,eng);
      SescConf->updateRecord(block, "WrMissEnergy"  ,eng * 2); // Wr miss + lineFill
#endif
    }
  }
}
Exemple #19
0
SupportRenumbering makeBandedAlternating(const std::vector<SNPSupport>& supports, SupportRenumbering initialRenumbering, size_t iterations, RowFunction rowOrderer)
{
	std::vector<MovedSupport> locations;
	
	{
		std::vector<SNPSupport> renumbered = renumberSupports(supports, initialRenumbering);
		for (auto x : renumbered)
		{
			locations.emplace_back(x);
		}
	}

	std::vector<MovedSupport> best { locations };
	double bestEnergy = getEnergy(best);

	for (size_t i = 0; i < iterations; i++)
	{
		//sort/transpose twice so result won't be transposed
		locations = rowOrderer(locations);
		locations = transpose(locations);
		locations = rowOrderer(locations);
		locations = transpose(locations);

		assert(getSupportRenumbering(locations).checkValidity());
		double newEnergy = getEnergy(locations);
		if (newEnergy < bestEnergy)
		{
			std::cerr << "iteration " << i << " new best " << newEnergy << "\n";
			best = locations;
			bestEnergy = newEnergy;
			assert(getSupportRenumbering(best).checkValidity());
		}
	}
	SupportRenumbering result = getSupportRenumbering(best);
	return initialRenumbering.merge(result);
}
int HongLian::p_after_magic(int &step, int playerID)
{
	int ret = GE_INVALID_STEP;
	if(playerID != id || !tap || getEnergy() < 1 ){
		return GE_SUCCESS;
	}
	//若成功则继续往下走,失败则返回,step会保留,下次再进来就不会重走
	//一般超时也会继续下一步
	step = JIE_JIAO_JIE_ZAO;
	ret = JieJiaoJieZao(playerID);
	if(toNextStep(ret)|| ret == GE_URGENT){
		step = STEP_DONE;
	}			
	return ret;
}
Exemple #21
0
int HardwareState::getValue(int module, bool i2c){
	switch (module){
	case HW_ENERGY_MODULE:
		return getEnergy(i2c);
	case HW_PAYLOAD_MODULE:
		return getPayload(i2c);
	case HW_SBAND_MODULE:
		return getSband(i2c);
	case HW_SOLARP_MODULE:
		return getSolarPanels(i2c);
	case HW_TEMP_MODULE:
		return getTemperature(i2c);
	case HW_TERMAL_CTRL_MODULE:
		return getThermalControl(i2c);
	}
}
void VehicleObjectImplementation::fillAttributeList(AttributeListMessage* alm, CreatureObject* object){

	alm->insertAttribute("armorrating", "@obj_attr_n:armor_pierce_none"); //None

	StringBuffer kin;
	kin << Math::getPrecision(getKinetic(),1) << "%";
	alm->insertAttribute("cat_armor_special_protection.armor_eff_kinetic", kin.toString());

	StringBuffer ene;
	ene << Math::getPrecision(getEnergy(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_energy", ene.toString());

	StringBuffer bla;
	bla << Math::getPrecision(getBlast(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_blast", bla.toString());

	StringBuffer stu;
	stu << Math::getPrecision(getStun(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_stun", stu.toString());

	StringBuffer lig;
	lig << Math::getPrecision(getLightSaber(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_restraint", lig.toString());

	StringBuffer hea;
	hea << Math::getPrecision(getHeat(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_heat", hea.toString());

	StringBuffer col;
	col << Math::getPrecision(getCold(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_cold", col.toString());

	StringBuffer aci;
	aci << Math::getPrecision(getAcid(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_acid", aci.toString());

	StringBuffer ele;
	ele << Math::getPrecision(getElectricity(),1) << "%";
	alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_electrical", ele.toString());

	ManagedReference<CreatureObject* > linkedCreature = this->linkedCreature.get();
	if( linkedCreature == NULL )
		return;

	alm->insertAttribute("@obj_attr_n:owner", linkedCreature->getFirstName());

}
Exemple #23
0
	Math::Vec2 Enemy::determineReaction(GameObject* _currentEnemy)
	{
		float vectorWeight = 1;
		float optimalSizeRation = 0.75;
		Math::Vec2 directionVector(_currentEnemy->getPosition()-getPosition());
		directionVector = directionVector / directionVector.length();
		float sizeRatio;
		sizeRatio = _currentEnemy->getEnergy()/getEnergy();
		if(sizeRatio > 1){
			//if(g_rand.)
			vectorWeight *= -1 * vectorWeight*vectorWeight*5.0f;
		}else
		{
			float sizeRatioRatioDiff = abs(optimalSizeRation-_currentEnemy->getRadius()/getRadius());
			vectorWeight *= (1/(sizeRatioRatioDiff*sizeRatioRatioDiff));
		}
		return vectorWeight *directionVector;
	}
/// starts a simulation round
/// \param nMcSteps the number of Monte Carlo steps
/// \param temperature the temperature at which the simulation is performed
/// \param step iteration number for statistics
/// returns the number of energy samples taken
int Simulation2D::simulate ( int nMcSteps, double temperature, int step){

  // get a pointer to the chain to simulate (first chain on the lattice)
  Chain2D * chain= lattice->chains[0];
 
 // set the temperature
  setTemperature(temperature);

  // set the fraction of global moves (point rotations)
  double pGlobal= 0.1;

  // keep the accumalitive statistics for the 
  // and number of native contacts (sumCn) 
  double sumCn=0;

  // calculate the the fraction of sampling
  int modSampling = nMcSteps / MAX_SAMPLES;
  int sample=0;

  // perform monte carlo moves
  for(int i=0;i<nMcSteps;i++){
    chain->localMove();
    if(drand48() < pGlobal){
      chain->globalMove();
    }
    //sample
    // update the number of native contacts
    sumCn +=  getNativeContacts();

    // store energy as often as 'modSampling' allows
    if(((i % modSampling) == 0) && sample < MAX_SAMPLES){
          energyTable[step][sample] = getEnergy();
      sample++;
    }
  }
  // store statistics
  temperatureTable[step]= temperature;
  // get fraction of native contacts
  nativeContactsTable[step]= sumCn/(nMcSteps * getTotalNativeContacts());

  // return the number of samples taken
  return sample;
}
/*
 * Does an action against a target, allows the user to choose which ability is used
 */
void Protagonist::doAction(Character *target) {
	string inputAbilityName;
	set<string> abilityNames = getAbilityNames();

	do {
		cout << "Choose an attack (current energy is " << getEnergy() << ")\n";
		printAbilities();
		cin >> inputAbilityName;
	} while (!isStringInSetIgnoreCase(inputAbilityName, abilityNames));

	Ability inputAbility = getAbilityFromName(inputAbilityName);

	cout << getName() << " used " << inputAbilityName << "\n";

	double multiplier = getMultiplier(inputAbility.getType(),
			target->getType());

	inputAbility.doAbility(this, target, multiplier);

}
Exemple #26
0
void Entity::postUpdate()
{

    setHydration(getHydration() - (20 * getHeatLevel()));
    if (getHydration() <= 100) {
        takeEnergy(2.0 * (1.0 + 100.0 / age()));
    }
    else {
        takeEnergy(1.0 * (1.0 + 100.0 / age()));
    }


    if (getEnergy() <= 0.1) {
        takeHealth(2);
    }
    if (getHydration() <= 0.1) {
        takeHealth(2);
    }

}
Exemple #27
0
AlphaReal ConstantLearner::run()
{

   const int numClasses = _pTrainingData->getNumClasses();
   //const int numColumns = _pTrainingData->getNumColumns();

   // set the smoothing value to avoid numerical problem
   // when theta=0.
   setSmoothingVal( 1.0 / (AlphaReal)_pTrainingData->getNumExamples() * 0.01 );

   vector<sRates> mu(numClasses); // The class-wise rates. See BaseLearner::sRates for more info.
   vector<AlphaReal> tmpV(numClasses); // The class-wise votes/abstentions

   ConstantAlgorithm cAlgo;
   cAlgo.findConstant(_pTrainingData,&mu,&tmpV);
   
   _v = tmpV;

   return getEnergy(mu, _alpha, _v);
}
int LingFu::LingLiBengJie()
{
	int ret;
	using_LingLiBengJie = false;
	if(getEnergy() < 1){
		return GE_SUCCESS;
	}
	//满足发动条件,询问客户端是否发动
	CommandRequest cmd_req;
	Coder::askForSkill(id, LING_LI_BENG_JIE, cmd_req);
	//有限等待,由UserTask调用tryNotify唤醒
	if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req))
	{
		void* reply;
		if (GE_SUCCESS == (ret = engine->getReply(id, reply)))
		{
			Respond* respond = (Respond*) reply;
			//发动
			if(respond->args(0) == 1){
				network::SkillMsg skill;
				Coder::skillNotice(id, -1, LING_LI_BENG_JIE, skill);
				engine->sendMessage(-1, MSG_SKILL, skill);
				GameInfo update_info;
				if(crystal>0){
					setCrystal(--crystal);
				}
				else{
					setGem(--gem);
				}
				Coder::energyNotice(id, gem, crystal, update_info);
				engine->sendMessage(-1, MSG_GAME, update_info);
				using_LingLiBengJie = true;
			}
		}
		return ret;
	}
	else{
		//超时啥都不用做
		return GE_TIMEOUT;
	}
}
int HongLian::v_magic_skill(Action *action)
{
	int actionID = action->action_id();
	int cardID;
	int playerID = action->src_id();
	//int dstID;
	CardEntity* card;
	//PlayerEntity* dst;
	

	if(playerID != id){
		return GE_INVALID_PLAYERID;
	}
	switch(actionID)
	{
	case XING_HONG_SHI_ZI:
		//未选中两张||没能量||没血印
		if(action->card_ids_size() != 2 || getEnergy() < 1 || 0 == token[0])
		{
			return GE_INVALID_ACTION;
		}
		//非法术牌
		for(int i = 0;i<action->card_ids_size();i++)
		{
			cardID = action->card_ids(i);
			card = getCardByID(cardID);
			if(TYPE_MAGIC != card->getType() || GE_SUCCESS != checkOneHandCard(cardID))
			{
				return GE_INVALID_ACTION;
			}
		}
		break;
	default:
		return GE_INVALID_ACTION;
	}
	return GE_SUCCESS;
}
int ShengNv::v_magic_skill(Action *action)
{
	int actionID = action->action_id();
	int cardID;
	int playerID = action->src_id();
	CardEntity* card;

	if(playerID != id){
		return GE_INVALID_PLAYERID;
	}
	switch(actionID)
	{
	case ZHI_LIAO_SHU:
		cardID = action->card_ids(0);
		card = getCardByID(cardID);
		//不是自己的手牌                          || 不是对应的法术牌                
		if(GE_SUCCESS != checkOneHandCard(cardID) || !card->checkSpeciality(actionID)){
			return GE_INVALID_ACTION;
		}
		break;
	case ZHI_YU_ZHI_GUANG:
		cardID = action->card_ids(0);
		card = getCardByID(cardID);
		if(GE_SUCCESS != checkOneHandCard(cardID) || !card->checkSpeciality(actionID) || action->dst_ids_size() < 1 || action->dst_ids_size() > 3){
			return GE_INVALID_ACTION;
		}
		break;
	case SHENG_LIAO:
		if(getEnergy() < 1 || used_ShengLiao){
			return GE_INVALID_ACTION;
		}
		break;
	default:
		return GE_INVALID_ACTION;
	}
	return GE_SUCCESS;
}