Exemplo n.º 1
0
main() {
	char c[20];
	while (putstr("Word: "), getline(c,20)) entree(c,&tree);
	putstr("Here are the sorted words:\n");
	walk(tree,1);
	}
Exemplo n.º 2
0
enum Error HuntAction::doAction(void) {
  io << "DO HUNT\n";
  
  // Let Benoit do its job !
  Pin<36> sortie("PE4");//PE4, green
  sortie.setMode(PinMode::OUTPUT);
  Pin<38> entree("PE6");//PE6, yellow
  entree.setMode(PinMode::INPUT);
  /*Pin<38> entree2("PE6");
  entree.setMode(PinMode::INPUT);
  while(1) {
    io << entree.getValue() << " " << entree2.getValue() << "\n";
    }*/


  trajectoryManager().lookAt(_mamouth);
  while(!trajectoryManager().isEnded()) {
    if(robot().getValue()) {
      return SKATING;
    }
  }
  
  Vect<2, s32> look = _mamouth;
  for (int i=0; i<_number && nb_balls > 0; i++, nb_balls--) {
    //io << "sending " << i << " soon\n";
    
    // trajectoryManager().gotoDistance(20);
    // while(!trajectoryManager().isEnded()) {}
    // Vect<2, s32> look = _mamouth;
    // look[0] -= OFFSET*_number/2;
    // //int look = 85-(OFFSET*_number/2)/10;
    // trajectoryManager().lookAt(look);
    // //trajectoryManager().gotoAngle(look);
    // while(!trajectoryManager().isEnded()) {
    //   if (robot().getValue()) {
    // 	trajectoryManager().gotoDistance(-50);
    // 	while(!trajectoryManager().isEnded()) {
    // 	  robot().unlock();
    // 	}
    //   }
    // }
    
    look.coord(0) += _mamouth.coord(0) + i * 12;
    trajectoryManager().lookAt(look);
    while(!trajectoryManager().isEnded()) {
      if(robot().getValue()) {
	return SKATING;
      }
    }
    
    io << "start sending" << i<<"\n";
    sortie.setValue(true);
    s16 anti_bounce = 0;
    while(anti_bounce < ANTI_BOUNCE_LIMIT) {
      if(entree.getValue() == true) {
	//attendre que la carte lanceballe commence
	anti_bounce++;
      }
      else {
	anti_bounce = 0;
      }
    }
    sortie.setValue(false);
    
    anti_bounce = 0;
    while(anti_bounce < ANTI_BOUNCE_LIMIT) {
      if(entree.getValue() == false) {
	//attendre que la carte lanceballe finisse
	anti_bounce++;
      }
      else {
	anti_bounce = 0;
      }
    }
    look[0]+=OFFSET;
    look += OFFSET/10;
  }
  //io << "finished\n";
  trajectoryManager().gotoDistance(-150);
  while(trajectoryManager().isEnded()){
    if (robot().getValue()) {
      robot().unlock();
    }
    if (check_for_collision(60)) {
      return IMPOSSIBLE;
    }
  };
  _static_priority = 0;

  return SUCCESS;
}
Exemplo n.º 3
0
void MainFrame::SurClicOuvrir(wxRibbonButtonBarEvent& event)
{
	//On demande à l'utilisateur s'il souhaite enregistrer avant.
	int confirmation;
	confirmation = wxMessageBox("Souhaitez vous enregistrer avant d'ouvrir un nouveau fichier?", "Confirmation",wxYES_NO | wxCANCEL,this); //On demande d'abord si l'utilisateur veut enregistrer son trabail en cours
	if (confirmation == wxYES)
	{
		Enregistrer(); 
	}
	else if (confirmation == wxCANCEL)
	{
		return;
	}
	
	//On efface toutes les matrices
	m_conteneurVariables.Vider();
	
	//Lecture du fichier
	tinyxml2::XMLDocument fichier;
	tinyxml2::XMLNode *racine;
	tinyxml2::XMLNode *noeudMatrice;
	tinyxml2::XMLElement* curseur;
	wxFileDialog dialogueOuverture(this, _("Ouvrez un fichier XML"), "", "","XML files (*.XML)|*.XML", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
	int lignes, colonnes, i,j;
	char nom;
	float valeur;
	
	if (dialogueOuverture.ShowModal() ==  wxID_CANCEL)
	{
		return;
	}
	wxFileInputStream entree(dialogueOuverture.GetPath());
	if (!entree.IsOk())
	{
		wxLogError("Impossible d'ouvrir le fichier. '%s'", dialogueOuverture.GetPath());
		return;
	}
	//Si le fichier s'est bien ouvert et l'utilisateur n'a pas enregistrer :
	
	fichier.LoadFile(dialogueOuverture.GetPath()); //on charge le fichier
	racine = fichier.FirstChild(); 
	racine = racine->NextSibling(); //On passe la déclaration
	for(noeudMatrice = racine->FirstChild(); noeudMatrice != NULL; noeudMatrice = noeudMatrice->NextSibling()) // Pour chaque <matrice></matrice>
	{
		curseur = noeudMatrice->FirstChildElement();
		nom = curseur->GetText()[0]; 
		curseur = curseur->NextSiblingElement();
		lignes = atoi(curseur->GetText());
		curseur = curseur->NextSiblingElement();
		colonnes = atoi(curseur->GetText());
		m_conteneurVariables.AjouterVariable(nom, lignes, colonnes); //On ajoutee une matrice au conteneur avec le nom et le nombre de lignes/colonnes stocké dans le fichier.
		//On se sert de deux boucles pour inscrire toutes les valeurs dans le fichier :
		for(i=0; i<lignes;i++)
		{
			for(j=0;j<colonnes;j++)
			{
				curseur=curseur->NextSiblingElement();
				valeur = atof(curseur->GetText());
				m_conteneurVariables.Variable(nom).FixerValeur(i,j,valeur);
			}
		}
	}
	
	m_conteneurVariables.MAJGUI(m_arbreVariables); //Lorsque le fichier est fini on met à jour l'arbre.
}