def color_init(num_robots_): # get array of colors same size as num of robots robo_colors = Color_((0, 0, 0)) # single color object, with array to be used for list of colors robo_colors = add_colors(robo_colors) # add 9 colors connected in a loop colors = [None] * num_robots_ color_ = robo_colors.color_list[0] for i in range(num_robots_): # for all bots colors[i] = color_.color_ # set color color_ = color_.next_ return colors
def add_colors(robo_color): # append colors to array to use for large numbers of robot trees robo_color.add_color(Color_(Colors.grey)) robo_color.add_color(Color_(Colors.dark_red)) robo_color.add_color(Color_(Colors.turquoise)) robo_color.add_color(Color_(Colors.purple)) robo_color.add_color(Color_(Colors.light_orange)) robo_color.add_color(Color_(Colors.pink)) robo_color.add_color(Color_(Colors.light_red)) robo_color.add_color(Color_(Colors.light_blue)) for i in range(len(robo_color.color_list) - 1): robo_color.color_list[i].next_ = robo_color.color_list[i + 1] # connect them in order robo_color.color_list[len(robo_color.color_list) - 1].next_ = robo_color.color_list[0] # connect the last to the first return robo_color