Пример #1
0
int		get_info(char *map, t_map *info)
{
  FILE		*fd;
  int		c;
  Uint32	len;

  len = 0;
  c = 0;
  init_strt(info);
  if ((fd = fopen(map, "r")) == NULL)
    return (-1);
  while (c != EOF && (c = fgetc(fd)) != EOF)
    {
      if (c == '\n' && (c = fgetc(fd)) != EOF)
	{
	  if (len > info->x)
	    info->x = len;
	  info->y++;
	  len = 0;
	}
      else
	len++;
    }
  if (store_map(info->x, info->y, info, fd) == -1)
    return (-1);
  //fclose(fd);
  return (1);
}
int main(int argc, char* argv[]) {

	store_map();
	init_position(0);
	display();

	printf("prediction\n");
	prediction(1);// we move from one meter to the right
	display();
	printf("estimation\n");
	estimation(wall,wall);
	normalization();
	display();
	  
	printf("prediction\n");
	prediction(1);// we move from one meter to the right
	display();
	printf("estimation\n");
	estimation(wall,wall);
	normalization();
	display();
	
	printf("prediction\n");
	prediction(1);// we move from one meter to the right
	display();
	printf("estimation\n");
	estimation(wall,wall);
	normalization();
	display();
	
	printf("prediction\n");
	prediction(1);// we move from one meter to the right
	display();
	printf("estimation\n");
	estimation(wall,wall);
	normalization();
	display();
	
	printf("prediction\n");
	prediction(1);// we move from one meter to the right
	display();
	printf("estimation\n");
	estimation(wall,wall);
	normalization();
	display();
	
	return 0;

}// main
Пример #3
0
void process_groups_row (void) {
  char *p, *q;
  int len, i, c, tags_len;
  static char tags[256];
  struct lev_search_text_short_entry *LS;
  struct lev_search_text_long_entry *LL;

  if (I[gr_id] > 0) {
    store_map (I[gr_id], I[gr_access]);
  }

  if (!I[gr_id] || !fits(I[gr_id]) || I[gr_is_event]) {
    return;
  }

  p = tags;

  if (I[gr_type] > 0) {
    p += make_tag (p, 'T', I[gr_type]);
  }
  if (I[gr_subtype] > 0) {
    p += make_tag (p, 'S', I[gr_subtype]);
  }
  if (I[gr_country_id] > 0) {
    p += make_tag (p, 'C', I[gr_country_id]);
  }
  if (I[gr_city_id] > 0) {
    p += make_tag (p, 'c', I[gr_city_id]);
  }

  tags_len = p - tags;
  if (tags_len > 0) {
    *p = ' ';
    tags_len++;
  }

  len = tags_len + L[gr_name] + L[gr_description] + 1;

  if (len > 8192) {
    return;
  }

  if (len < 256) {
    LS = write_alloc (21+len);
    LS->type = LEV_SEARCH_TEXT_SHORT + len;
    LS->rate = 0;
    LS->rate2 = I[gr_num];
    LS->obj_id = I[gr_id];
    q = LS->text;
  } else {
    LL = write_alloc (23+len);
    LL->type = LEV_SEARCH_TEXT_LONG;
    LL->rate = 0;
    LL->rate2 = I[gr_num];
    LL->obj_id = I[gr_id];
    LL->text_len = len;
    q = LL->text;
  }

  if (tags_len) {
    memcpy (q, tags, tags_len);
    q += tags_len;
  }

  p = S[gr_name];
  for (i = L[gr_name]; i > 0; i--) {
    c = (unsigned char) *p++;
    if (c < ' ') { c = ' '; }
    *q++ = c;
  }

  *q++ = '\t';

  p = S[gr_description];
  for (i = L[gr_description]; i > 0; i--) {
    c = (unsigned char) *p++;
    if (c < ' ') { c = ' '; }
    *q++ = c;
  }

  *q++ = 0;

  adj_rec++;
}