View Single Post
Re: Show off your finest piece of code!
Old
  (#6)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Show off your finest piece of code! - 30-12-2004

@sfx : that code would be pretty small when using shift ops "<<"

to make some temporary conclusion : some people seem to like rows of if statements and other ppls best piece of code is that with very few comments

and ha, my AStar "Taskmanager" idea has found it's way over pierre to cube bot - nice !

some piece of nice code is attached ... my AStarMachine with a plugininterface for almost everything needed here, fast, reliable, never had to touch that code since optimizing

another nice thing is my n-dimensional vector class using SSE, that's a mess ... but well, not my finest piece of code

but percepting entities in joebot xp is :

Code:
void CPerceptionBot::perceptEntities(void){
PROFILE("CPerceptionBot::perceptEntities");
if(!m_pBot)
return;
if(m_fNextPerceptEntities > g_pGame->getTime() ){
return;
}
m_fNextPerceptEntities = g_pGame->getTime() + .18f;
CEntity Entity = 0;
list<CIEntity*>::iterator iter_entities,
begin_entities = g_pGame->m_LIEntities.begin(),
end_entities = g_pGame->m_LIEntities.end();
CPerceipt *pAllocPerc = /*new CPerceipt*/0; // an instance of a perceipt
Vector VOrigin = m_pBot->getOrigin();
while(Entity = UTIL_FindEntityInSphere(Entity,VOrigin,_ENT_PERC_RADIUS)){ // loop thru entities around here
iter_entities = begin_entities;
while(iter_entities != end_entities){
// check this entity
 
if( (*iter_entities)->compare(Entity) ){
	if(m_pBot->views((*iter_entities)->getOrigin(Entity))){
	 pAllocPerc = new CPerceipt; // create a new perceipt
	 (*iter_entities)->assign(Entity,pAllocPerc);
	 pAllocPerc->m_fDistance = (VOrigin-pAllocPerc->m_VOrigin).length(); // todo : more elegant
	 m_LNewPerceptions.push_back(pAllocPerc);
	 break; // there arent double classname IEntities !? am I right ?
	}
}
iter_entities ++;
}
}
}
€dit: where are all the empty lines gone to ?
Attached Files
File Type: h AStarMachine.h (4.8 KB, 322 views)


  
Reply With Quote