seed1.count_ones()) + \ "Blue seed directory: " + head2 + "\n" + \ "Blue seed file: " + tail2 + "\n" + \ "Blue seed size: {} x {}\n".format(seed2.xspan, seed2.yspan) + \ "Blue seed density: {:.4f} ({} ones)\n\n".format(seed2.density(), \ seed2.count_ones()) + \ "Select OK to begin the competition.\n") # for t in range(g_time): g.run(1) # run for 1 step without displaying g.update() # now display # # see who won -- need to make adjustment here so that the # score here matches with mfunc.score_pair() # [count1, count2] = mfunc.count_pops(g) # # s1.num_living = initial number of living cells in s1 # s2.num_living = initial number of living cells in s2 # if (s1.num_living < count1): count1 = count1 - s1.num_living else: count1 = 0 # if (s2.num_living < count2): count2 = count2 - s2.num_living else: count2 = 0 # # Now we are ready to determine the winner.
"Red seed file: " + tail1 + "\n" + \ "Red seed size: {} x {}\n".format(seed1.xspan, seed1.yspan) + \ "Red seed density: {:.4f} ({} ones)\n\n".format(seed1.density(), \ seed1.count_ones()) + \ "Blue seed directory: " + head2 + "\n" + \ "Blue seed file: " + tail2 + "\n" + \ "Blue seed size: {} x {}\n".format(seed2.xspan, seed2.yspan) + \ "Blue seed density: {:.4f} ({} ones)\n\n".format(seed2.density(), \ seed2.count_ones()) + \ "Select OK to begin the competition.\n") # while (int(g.getgen()) < g_time): g.run(1) # run for 1 step without displaying g.update() # now display # [count1, count2] = mfunc.count_pops(g) # see who won if (count1 > count2): result = "Red won! Red: {}. Blue: {}.\n\n".format(count1, count2) elif (count2 > count1): result = "Blue won! Red: {}. Blue: {}.\n\n".format(count1, count2) else: result = "Tie! Red: {}. Blue: {}.\n\n".format(count1, count2) # # Note that s2 is blue, which means it contains twos, not ones. # Thus we use seed2, which is red, for density() and count_ones(). # message = result + \ "Red seed directory: " + head1 + "\n" + \ "Red seed file: " + tail1 + "\n" + \ "Red seed size: {} x {}\n".format(seed1.xspan, seed1.yspan) + \ "Red seed density: {:.4f} ({} ones)\n\n".format(seed1.density(), \