bug fix! remove srand(time(0))  (it will always give you same number within one generation). Also use rand()/RAND_MAX to generate probability.