void testApp::resetAgents()
{
    if ( !quote.bReadyToStart )
        return ;

    trailFbo.begin() ;
    ofClear( 0 , 0 , 0, 1 ) ;
    trailFbo.end() ;

    quote.resetQuotePaths( ) ;
    agents.clear() ;

    for ( int i = 0 ; i < a_numAgents ; i++ )
    {
        createNewAgent( ) ;
    }

    bRunAgents = false ;
}
//----------------------------------------------------------------------
void AIController::handleAgentReports( ArenaMap& currentMap, const AgentReports& agentReports, const ObservedEntities& entities, Orders& tentativeOrders )
{
	EnterCriticalSection( &m_agentsCS );
	for( int i = 0; i < agentReports.m_numberAgentReports; ++i )
	{
		Agent*& currentAgent = m_agents[ agentReports.m_agentReports[i].m_entityID ];
		//Indicates this is a new entity
		if( currentAgent == nullptr )
		{
			createNewAgent( currentAgent, agentReports.m_agentReports[i] );
		}
		else
		{
			if( agentReports.m_agentReports[i].m_reportCode == REPORT_WAS_KILLED_IN_COMBAT || 
				agentReports.m_agentReports[i].m_reportCode == REPORT_STARVED_TO_DEATH ||
				agentReports.m_agentReports[i].m_reportCode == REPORT_SUICIDE_SUCCESSFUL )
			{
				handleAgentDied( currentAgent, currentMap, agentReports.m_agentReports[i] );
				m_currentQueenState = DEFEND;
			}
			else
			{
				if( agentReports.m_agentReports[i].m_agentType == ENTITY_TYPE_WORKER && agentReports.m_agentReports[i].m_reportCode == REPORT_TAKE_SUCCESSFUL )
					++m_numWorkersWithFood;

				currentAgent->pos.x = agentReports.m_agentReports[i].m_newPositionX;
				currentAgent->pos.y = agentReports.m_agentReports[i].m_newPositionY;
				currentAgent->specialStatus = agentReports.m_agentReports[i].m_specialStatus;
				if( agentReports.m_agentReports[i].m_reportCode == REPORT_MOVE_SUCCESSFUL )
				{
					if( !currentAgent->currentPath.empty() )
						currentAgent->currentPath.pop_back();
					if( currentAgent->currentPath.empty() )
						currentAgent->waitingForPath = false;
				}
				else if( agentReports.m_agentReports[i].m_reportCode == REPORT_HOLD_SUCCESSFUL )
				{
					if( currentAgent == m_queen && !m_queen->currentPath.empty() && m_queen->currentPath.back() == ORDER_HOLD )
						currentAgent->currentPath.pop_back();
					if( currentAgent->currentPath.empty() )
						currentAgent->waitingForPath = false;
				}
				else if( agentReports.m_agentReports[i].m_reportCode == REPORT_ERROR_BLOCKED_BY_ROCK )
				{
					currentAgent->currentPath.clear();
					m_agentsRequestingPaths.push( currentAgent->entityID );
				}
				else if( currentAgent->entityType == ENTITY_TYPE_QUEEN )
				{
					if( agentReports.m_agentReports[i].m_reportCode == REPORT_QUEEN_WAS_FED )
						currentMap.getMapTile( m_queen->pos.x, m_queen->pos.y ).isClaimed = false;	
					else if( agentReports.m_agentReports[i].m_reportCode == REPORT_CREATE_SUCCESSFUL && m_currentQueenState == DEFEND )
					{
						m_currentQueenState = GATHER_RESOURCES;
					}
					else if( agentReports.m_agentReports[i].m_reportCode == REPORT_QUEEN_WAS_ASSAULTED && m_queen->currentPath.empty() )
					{
						tentativeOrders.AddOrder( m_queen->entityID, ORDER_CREATE_SOLDIER, true );
					}
				}
			}
		}
	}
	LeaveCriticalSection( &m_agentsCS );
}