c++ virtual "Galton Board" simulates normal distribution

a "ball" is dropped at the top of the board, hits a series of pegs and randomly moves left or right upon striking each peg. The ball moves down 10 rows of pegs, and the number of balls for each final position is displayed, as well as histograms scaled to console window size.

the program

simulation of the 'board'

the 'board' is composed of an 2d array of pointers to pointers of 'pegs' objects. a 'ball' object then descends rows of increasing numbers of pegs with 50-50 odds to go either left or right upon striking each peg. the total number of 'balls' that strike each 'peg' is displayed and updated.

pointer array code snippet

showing data

histogram!

After the board is filled and all balls dropped, a histogram displays the relative distribution of balls that landed in each column, and scales to console window size

variable size histogram