示例#1
0
void		Map::setBotsMap()
{
  std::pair<int, int>	p;

  srand(time(NULL));
  for (int i = 0; i < getNbBots(); ++i)
    {
      while (checkIfCharacter(p = getTmpMap()[rand() % getTmpMap().size()], P1) == 0
	     || checkIfCharacter(p, P2) == 0 || checkIfCharacter(p, BOT) == 0)
	;
      setBox(std::make_pair(p.first, p.second), BOT);
      popTmpMap(p);
      createL(p);
    }
}
示例#2
0
文件: process.c 项目: wavs/ocre
/**
 * This function executes the extraction process.
 *
 * @param infos Informations about the launch process.
 */
void processAll(t_launch_infos *infos)
{
  t_binary_image *pic;
  SDL_Surface *image;
  t_cc_list *cc_list;
  
  pic = NULL;
  image = NULL;
  image = SDL_LoadBMP(infos->inFile);
  if (image != NULL)
    { 
      if (infos->verbose)
	printf("\n >> Image %s loaded.\n", infos->inFile);
      pic = bitmap_to_binaryimage(image,infos->inFile);
      if (pic != NULL)
	{ 
	  if (infos->verbose)
	    printf(" >> Binarization done.\n");
	  cc_list = findCC(pic->matrix);
	  if (cc_list != NULL)
	    {
	      checkIfCharacter(cc_list, pic->height, pic->width);

	      if (infos->verbose)
		printf(" >> Extraction of %d characters done.\n", cc_list->nbcc);

	      updateCC(cc_list);
	      exportCC(cc_list, pic);
	      
	      /*traceCC(image, cc_list); */

	      if (SDL_SaveBMP(image, infos->outFile) < 0)
		fprintf(stderr," > SDL BMP saving error <\n");
	      else
		if (infos->verbose)
		  printf(" >> Image %s saved.\n\n", infos->outFile);
	      /* free_listCC(cc_list) */
	      free_pic(pic);
	    }
	}
      SDL_FreeSurface(image);
    }
  else
    {
      fprintf(stderr, " > SDL BMP Loader error <\n");
      wfree(infos);
      exit(EXIT_FAILURE);
    }
}