const void SandPile::timestep(bool midpoint) { lattice = relax(lattice); // 1. add random sand // TODO // std::cout << "\taddSand" << std::endl; if(midpoint){ addSand(nrOfElements/2); } else lattice=addSand(lattice); }
void Chunk::stepByStepCreation(){ switch(stepCreation){ case 1: addLava(); break; case 2: addWater(); break; case 3: addSand(); break; case 4: addStone(); break; case 5: addDirt(); break; case 6: addTree(); break; case 7: // to avoid errors checkSizeChunk(); // checkVisibleBlocks(); saveChunkInFile(); break; default: // start if(!readChunkFromFile()){ // fail to open file, it's time to generate a new one checkSizeChunk(); // fill Chunk with zero }else{ stepCreation = 6; // almost end of the generation } break; } stepCreation++; }
std::vector<int> SandPile::addSand(std::vector<int> & lat) { return addSand(lat,0.001); }