def test_get_candidates(self): helium = Element(4, 1, 1, ElementType.HELIUM) hidro1 = Element(1, 1, 1, ElementType.HIDROGEN) hidro2 = Element(1, 1, 1, ElementType.HIDROGEN) hidro3 = Element(1, 1, 1, ElementType.HIDROGEN) elements = [ hidro1, hidro2, hidro3, helium, ] candidates = Helper.get_candidates(elements, ElementType.HELIUM) self.assertListEqual(candidates, [helium]) self.assertNotEqual(candidates, [hidro1])
def life(self): '''Start star life ''' while 1: # select an element to fusion it element_type_candidate = Helper.get_randon_element() same_elements = Helper.get_candidates(self._elements, element_type_candidate) # We need at least two elements to fusion it if len(same_elements) < 2: continue fusion_candidates = Helper.select_candidates(same_elements) self._start_fusion(fusion_candidates) if len(self._elements) == 2: break