void step(std::vector<double>& square, int ogwidth, int width, double scale, std::mt19937& rng) { if ( (width*width) <= 4) { return; } int center = width / 2; // Add Diamonds for (int i = center; i < ogwidth; i += width-1) { for (int j = center; j < ogwidth; j += width-1) { square[CoordsToIdx(i, j, ogwidth)] = averagecorners(square, CoordsToIdx(i - center, j - center, ogwidth), CoordsToIdx(i + center, j - center, ogwidth), CoordsToIdx(i - center, j + center, ogwidth), CoordsToIdx(i + center, j + center, ogwidth) ) + noise(square, scale, rng); } } // Add Squares for (int i = center; i < ogwidth; i += width-1) { for (int j = center; j < ogwidth; j += width-1) { calculateSquare(square, i - center, j, center, ogwidth, scale, rng); calculateSquare(square, i + center, j, center, ogwidth, scale, rng); calculateSquare(square, i, j - center, center, ogwidth, scale, rng); calculateSquare(square, i, j + center, center, ogwidth, scale, rng); } } step(square, ogwidth, (width/2)+1, scale*0.5, rng); }
// main returns an integer and takes no parameters int main() { //Declare an interger for storing user input int userInputInt = 0; //Prompt the user to enter a positive, non-zero integer value. cout << "Etner a positive, non-zero value:" << endl; //Store value cin >> userInputInt; //Pass to function calculateSquare(userInputInt); //Pause so the user can hit enter to close the program system("PAUSE"); //Return zero to send back to the OS return 0; }