organized main function to loop

if goal state is reached the function stops and prints the number of
generations thus far
if goal state is not reached the function prints that it has not been
reached