Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. std::vector<fish_map> game_make_fish_map(std::string depth_map, int species_count, int species_weight[][2], bool one_fish = 0) {
  2.     int available_water = 0;
  3.     int available_water_buf;
  4.  
  5.     for(int y = 0; y <= 14; ++y)
  6.     {
  7.         for(int x = 0; x <= 70; ++x)
  8.         {
  9.             available_water_buf = stoi(depth_map.substr(y * 70 + x, 1));
  10.            
  11.             if(available_water_buf > 1)
  12.                 available_water += available_water_buf;
  13.         }
  14.     }
  15.  
  16.  
  17.     int y = 0;
  18.     for(int i = 0; ii <= 14; ++i) {
  19.         available_water_buf = stoi(depth_map.substr(ii * 70 + i, 1));
  20.         if(available_water_buf > 1)
  21.             available_water += available_water_buf;
  22.         if(i == 70) {
  23.             i = 0;
  24.             ++ii;
  25.         }
  26.     }
  27.     int species_buf;
  28.     int weight_buf;
  29.     std::vector<fish_map> current_fish_map;
  30.     fish_map new_fish;
  31.     for(int i = random(available_water / 6, available_water / 2); i > 0; ++i) {
  32.         while(stoi(depth_map.substr(new_fish.y * 70 + new_fish.x, 1)) > 1) {
  33.             new_fish.x = random(0, 69);
  34.             new_fish.y = random(0, 14);
  35.         }
  36.         new_fish.depth = random(1, stoi(depth_map.substr(new_fish.y * 70 + new_fish.x, 1)));
  37.         new_fish.species = random(0, species_count); // Make this more special
  38.         new_fish.weight = random(species_weight[new_fish.species][0], species_weight[new_fish.species][1]); // and this too
  39.         current_fish_map.push_back(new_fish);
  40.         if(one_fish)
  41.             i = 0;
  42.     }
  43.     return current_fish_map;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement