Exemplo n.º 1
0
bool dm_generate_map_dla(struct dm_map *map, struct random *r, enum dm_dungeon_type type, coord_t *ul, coord_t *dr) {
    FIX_UNUSED(type);

    /* initialise cellular automata */
    coord_t size = { .x = dr->x - ul->x, .y = dr->y - ul->y, };
    struct dla_map *dlamap = dla_init(&size);

    /* Generate the map */
    dla_generate(dlamap, r, 25, DLA_ORTHOGONAL);

    /* translate the dla_map to the real map */
    coord_t p;
    for(p.y = 0; p.y < size.y; p.y++) {
        for(p.x = 0; p.x < size.x; p.x++) {

            /* tranlate point to dm_map coordinations */
            coord_t c = cd_add(ul, &p);

            /* check if the block is a floor or wall */
            if (dla_get_coord(dlamap, &p) == DLA_FLOOR) {
                /* fill the tile with the specified type */
                dm_get_map_me(&c,map)->tile = ts_get_tile_specific(TILE_ID_CONCRETE_FLOOR);
            }
        }
    }

    /* cleanup and return */
    dla_free(dlamap);
    return true;
}
Exemplo n.º 2
0
std::vector<char> NppInterface::GetCurrentLine(ViewType view) const {
	int curLine = GetCurrentLineNumber(view);
	int bufSize = sendMsgToScintilla(view, SCI_LINELENGTH, curLine) + 1;
	std::vector<char> buf(bufSize);
	int ret = sendMsgToScintilla(view, SCI_GETLINE, curLine, reinterpret_cast<LPARAM>(buf.data()));
	FIX_UNUSED(ret);
	assert(ret == bufSize - 1);
	return buf;
}
int
main (int argc, char **argv)
{  
  FIX_UNUSED (argc);
  FIX_UNUSED (argv);
  test_groups_cmd_parser_init (&args_info);

  PRINT_OPTION(help_help);
  PRINT_OPTION(version_help);
  PRINT_OPTION(opta_help);
  PRINT_OPTION(optA_help);
  PRINT_OPTION(optAmul_help);
  PRINT_OPTION(optb_help);
  PRINT_OPTION(optc_help);
  PRINT_OPTION(optd_help);

  test_groups_cmd_parser_free (&args_info);

  return 0;
}
Exemplo n.º 4
0
bool cave_generate_map(struct dm_map *map, struct random *r, enum dm_dungeon_type type, coord_t *ul, coord_t *dr) {
    FIX_UNUSED(type);

    /* initialise cellular automata */
    coord_t size = { .x = dr->x - ul->x, .y = dr->y - ul->y, };
    struct ca_map *cmap = ca_init(&size);

    /* fill the map randomly with floors */
    coord_t p;
    for (p.y = 0; p.y < size.y; p.y++) {
        for (p.x = 0; p.x < size.x; p.x++) {
            ca_set_coord(cmap, &p, randpick(r, 45) );
        }
    }

    /* Fill the map with large caves */
    for (int  i = 0; i < 4; i++) {
        ca_generation(cmap, 16, 8, 2);
    }

    /* Do a few passes to make them less smooth */
    for (int  i = 0; i < 2; i++) {
        int ri = (random_int32(r) % 4) +2;
        ca_generation(cmap, 5, ri, 1);
    }

    /* translate the ca_map to the real map */
    for(p.y = 0; p.y < size.y; p.y++) {
        for(p.x = 0; p.x < size.x; p.x++) {
            coord_t c = cd_add(ul, &p);

            /* check if the cell is alive or dead */
            if (ca_get_coord(cmap, &p) == CA_ALIVE) {
                /* fill the tile with the specified type */
                if(random_int32(r)%100 < 1) {
                    dm_get_map_me(&c,map)->tile = ts_get_tile_specific(TILE_ID_MAD_CAP_FUNGUS);
                }
                else dm_get_map_me(&c,map)->tile = ts_get_tile_specific(TILE_ID_CONCRETE_FLOOR);
            }
        }
    }

    /* cleanup and return */
    ca_free(cmap);
    return true;
}
int main ()
{
  double tau = 0.001;
  int N = 11;
  char flag = 0, taskf = 0, flag_print = 0;
  int temp = 0, task = 0, print = 0;
  double K = 1., mu = 1., A = 0., B = 10., T = 1.;
  
  FIX_UNUSED (temp);
  printf ("enter task number(A,B,C):\n");
  while (taskf != 'A' && taskf != 'B' && taskf != 'C')
    {
      
      temp = scanf ("%c", &taskf);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
    }
    
  if (taskf == 'A') task = 0;
  if (taskf == 'B') task = 1;
  if (taskf == 'C') task = 2;    
  
  printf ("enter N:\n");
  temp = scanf ("%d", &N);
  if (temp <= 0)
    {
      printf ("incorrect input data\n");
      return -1;
    }
  
  printf ("enter tau:\n");
  temp = scanf ("%lf", &tau); 
  if (temp <= 0)
    {
      printf ("incorrect input data\n");
      return -1;
    }
  
  printf ("change additional parameters? (y, n)\n");
  while (flag != 'y' && flag != 'n')
    {
      temp = scanf ("%c", &flag);
    }  
  
  if (flag == 'y')
    { 
      printf ("enter A:\n");
      temp = scanf ("%lf", &A);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
        
      printf ("enter B:\n");
      temp = scanf ("%lf", &B);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
      
      printf ("enter T:\n");
      temp = scanf ("%lf", &T);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
              
      printf ("enter K:\n");
      temp = scanf ("%lf", &K);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
              
      printf ("enter mu:\n");
      temp = scanf ("%lf", &mu);
      if (temp <= 0)
        {
          printf ("incorrect input data\n");
          return -1;
        }
        
    printf ("print result? (y, n)\n");
    while (flag_print != 'y' && flag_print != 'n')
      {
        temp = scanf ("%c", &flag_print);
      }
      
    if (flag_print == 'y')
      print = 1;
    else
      print = 0;             
    } 
  
  build_solution (tau, A, B, N, K, mu, (int)(T / tau), task, print);
}