Lab 3

Getting Started

There is some started code located on the 242 website

The Problem

Perlin noise is a technique to generate textures (and landscapes) using gradient noise. The textures will be "random" but pixel values change in a gradient manor. Ken Perlin won an Academy Award for his algorithm.

The dcurses library gives us the ability to draw colors to the screen and Perlin noise gives us texture information! We will display a Perlin noise image in the terminal using the 24 colors of grayscale in the ANSI pallet (colors 232-255).

In order to speed up our computation time we will use threads to calculate different parts of the texture in parallel.

Your README should include an analysis of how the number of threads increases or decreases the runtime. Is there a point where more threads runs slower? List out multiple trials (runs) for different numbers of threads.


The easiest path to getting the most points might be:

  1. Create a vector of Point structs. The vector should contain all the points from (1,1) to the bounds... ie (1,1) (1,2) (2,1)...
  2. Randomly shuffle the vector
  3. Loop through the vector and print out all of the points (Are they in random order?)
  4. Change your loop to generate a Perlin noise value for each point
  5. Print out the noise value as a color (noise*23+232)
  6. Get the current time in milliseconds at the start of main
  7. Get the time after the loop (How much time has elapsed?)
  8. Process a command line argument for the Perlin seed
  9. Convert your code to work with a single thread generating all the noise values (Do you need a join?)
  10. Convert your code to have two threads share the work of generating the noise values (Do you need a mutex?)
  11. Process a command line argument for the number of threads
  12. Does the processing time change with the number of threads? Start a README.txt
  13. Get dcurses.c to compile with your C++ code
  14. Use the example code to have the threads draw to the screen
  15. Get an A

This is not your friend’s work. This is not the internet’s work. This is your work...


Submit your code using the handin script, handin cmsc242 lab3 your_directory_name.
You will need to be in the directory which contains your_directory_name.

The lab is due at 11:59pm Apr. 10th 2020.