Exemple #1
0
static int
get_command(int who, char *s)
{
  int fact;                     /* who controls us now? */
  char *order;

  if (!valid_box(who) || kind(who) == T_deadchar)
    return FALSE;

  fact = player(who);

  if (fact == 0)
    return FALSE;

  order = top_order(fact, who);

/*
 *  If we don't have any orders, then fail.
 */

  if (order == NULL)
    return FALSE;

/*
 *  Update the player's last turn field so we know if he's been
 *  playing or not.
 */

  {
    struct entity_player *p;

    p = p_player(fact);
    p->last_order_turn = sysclock.turn;
  }

  assert(strlen(order) < LEN);  /* maybe not a valid assert */

  strncpy(s, order, LEN - 1);
  s[LEN - 1] = '\0';

  pop_order(fact, who);

  return TRUE;
}
Exemple #2
0
std::list<std::set<T> > scc(Graph<T>& g){
    std::list<std::set<T>> SCCS;

    Graph<T> f;
    reverse(g, f);

    std::map<int, T> topOrder = top_order(f);

    typename std::map<int, T>::reverse_iterator itr;
    for (itr = topOrder.rbegin(); itr != topOrder.rend(); itr++)
    {
    	if ((g.vertices[itr->second])->visited == false)
    	{
    		std::set<T> SCC;
    		SCC = explorecomp(g, itr->second, SCC);
			SCCS.push_front(SCC);
    	}
    }

    return SCCS;
}