Fix process info

This commit is contained in:
timofej 2023-08-17 13:38:18 +02:00
parent 9287e2de10
commit d35beaea81

View File

@ -67,7 +67,7 @@ class Simulate2Layers:
def __init__(self,
dim,
eps,
res=10,
res=4,
draw='pygame',
state_to_color_cb=None,
*args, **kwargs):
@ -110,7 +110,8 @@ class Simulate2Layers:
time_ds_end = time.time()
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
draw_duration=(time_ds_end - time_ca_end),
evolution_step=self._cellular_automaton.evolution_step)
evolution_step=self._cellular_automaton.evolution_step,
runlendig=len(str(last_evolution_step)))
self._sleep_to_keep_rate(time.time() - time_ca_start, evolutions_per_second)
try:
self.__draw_engine._pygame.quit()
@ -160,11 +161,9 @@ class Simulate2Layers:
def __draw_cell_surface(self, surface_pos, cell_color):
return self.__draw_engine.fill_surface_with_color((surface_pos, self.__cell_size), cell_color)
def print_process_info(self, evolve_duration, draw_duration, evolution_step):
def print_process_info(self, evolve_duration, draw_duration, evolution_step, runlendig):
self.__draw_engine.fill_surface_with_color(((0, 0), (self.__rect.width, 30)))
self.__draw_engine.write_text((10, 5), "CA: " + "{0:.4f}".format(evolve_duration) + "s")
self.__draw_engine.write_text((310, 5), "Display: " + "{0:.4f}".format(draw_duration) + "s")
self.__draw_engine.write_text((660, 5), "Step: " + str(evolution_step))
self.__draw_engine.write_text((0, 5), f'Step: {evolution_step:>{runlendig}} FPS: {int(1/(evolve_duration+draw_duration))}')
def _is_not_user_terminated(self):
return self.__draw_engine.is_active()
@ -173,7 +172,8 @@ class Simulate4Layers:
def __init__(self,
dim,
eps,
res=10,
coupling=[],
res=4,
draw='pygame',
state_to_color_cb=None,
*args, **kwargs):
@ -187,7 +187,7 @@ class Simulate4Layers:
:param state_to_color_cb: A callback to define the draw color of CA states (default: red for states != 0)
"""
super().__init__(*args, **kwargs)
self._cellular_automaton = NeuropercolationCoupled(dim,eps)
self._cellular_automaton = NeuropercolationCoupled(dim,eps,coupling)
self.__cell_size = [res,res]
self.__gridside = dim*res
self.__samegap = 10
@ -216,7 +216,8 @@ class Simulate4Layers:
time_ds_end = time.time()
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
draw_duration=(time_ds_end - time_ca_end),
evolution_step=self._cellular_automaton.evolution_step)
evolution_step=self._cellular_automaton.evolution_step,
runlendig=len(str(last_evolution_step)))
self._sleep_to_keep_rate(time.time() - time_ca_start, evolutions_per_second)
try:
self.__draw_engine._pygame.quit()
@ -267,11 +268,9 @@ class Simulate4Layers:
def __draw_cell_surface(self, surface_pos, cell_color):
return self.__draw_engine.fill_surface_with_color((surface_pos, self.__cell_size), cell_color)
def print_process_info(self, evolve_duration, draw_duration, evolution_step):
def print_process_info(self, evolve_duration, draw_duration, evolution_step, runlendig):
self.__draw_engine.fill_surface_with_color(((0, 0), (self.__rect.width, 30)))
self.__draw_engine.write_text((10, 5), "CA: " + "{0:.4f}".format(evolve_duration) + "s")
self.__draw_engine.write_text((310, 5), "Display: " + "{0:.4f}".format(draw_duration) + "s")
self.__draw_engine.write_text((660, 5), "Step: " + str(evolution_step))
self.__draw_engine.write_text((0, 5), f'Step: {evolution_step:>{runlendig}} FPS: {int(1/(evolve_duration+draw_duration))}')
def _is_not_user_terminated(self):
return self.__draw_engine.is_active()