Fix process info
This commit is contained in:
parent
9287e2de10
commit
d35beaea81
@ -67,7 +67,7 @@ class Simulate2Layers:
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
dim,
|
dim,
|
||||||
eps,
|
eps,
|
||||||
res=10,
|
res=4,
|
||||||
draw='pygame',
|
draw='pygame',
|
||||||
state_to_color_cb=None,
|
state_to_color_cb=None,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
@ -110,7 +110,8 @@ class Simulate2Layers:
|
|||||||
time_ds_end = time.time()
|
time_ds_end = time.time()
|
||||||
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
|
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
|
||||||
draw_duration=(time_ds_end - time_ca_end),
|
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)
|
self._sleep_to_keep_rate(time.time() - time_ca_start, evolutions_per_second)
|
||||||
try:
|
try:
|
||||||
self.__draw_engine._pygame.quit()
|
self.__draw_engine._pygame.quit()
|
||||||
@ -160,11 +161,9 @@ class Simulate2Layers:
|
|||||||
def __draw_cell_surface(self, surface_pos, cell_color):
|
def __draw_cell_surface(self, surface_pos, cell_color):
|
||||||
return self.__draw_engine.fill_surface_with_color((surface_pos, self.__cell_size), 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.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((0, 5), f'Step: {evolution_step:>{runlendig}} FPS: {int(1/(evolve_duration+draw_duration))}')
|
||||||
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))
|
|
||||||
|
|
||||||
def _is_not_user_terminated(self):
|
def _is_not_user_terminated(self):
|
||||||
return self.__draw_engine.is_active()
|
return self.__draw_engine.is_active()
|
||||||
@ -173,7 +172,8 @@ class Simulate4Layers:
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
dim,
|
dim,
|
||||||
eps,
|
eps,
|
||||||
res=10,
|
coupling=[],
|
||||||
|
res=4,
|
||||||
draw='pygame',
|
draw='pygame',
|
||||||
state_to_color_cb=None,
|
state_to_color_cb=None,
|
||||||
*args, **kwargs):
|
*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)
|
:param state_to_color_cb: A callback to define the draw color of CA states (default: red for states != 0)
|
||||||
"""
|
"""
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._cellular_automaton = NeuropercolationCoupled(dim,eps)
|
self._cellular_automaton = NeuropercolationCoupled(dim,eps,coupling)
|
||||||
self.__cell_size = [res,res]
|
self.__cell_size = [res,res]
|
||||||
self.__gridside = dim*res
|
self.__gridside = dim*res
|
||||||
self.__samegap = 10
|
self.__samegap = 10
|
||||||
@ -216,7 +216,8 @@ class Simulate4Layers:
|
|||||||
time_ds_end = time.time()
|
time_ds_end = time.time()
|
||||||
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
|
self.print_process_info(evolve_duration=(time_ca_end - time_ca_start),
|
||||||
draw_duration=(time_ds_end - time_ca_end),
|
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)
|
self._sleep_to_keep_rate(time.time() - time_ca_start, evolutions_per_second)
|
||||||
try:
|
try:
|
||||||
self.__draw_engine._pygame.quit()
|
self.__draw_engine._pygame.quit()
|
||||||
@ -267,11 +268,9 @@ class Simulate4Layers:
|
|||||||
def __draw_cell_surface(self, surface_pos, cell_color):
|
def __draw_cell_surface(self, surface_pos, cell_color):
|
||||||
return self.__draw_engine.fill_surface_with_color((surface_pos, self.__cell_size), 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.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((0, 5), f'Step: {evolution_step:>{runlendig}} FPS: {int(1/(evolve_duration+draw_duration))}')
|
||||||
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))
|
|
||||||
|
|
||||||
def _is_not_user_terminated(self):
|
def _is_not_user_terminated(self):
|
||||||
return self.__draw_engine.is_active()
|
return self.__draw_engine.is_active()
|
||||||
|
Loading…
Reference in New Issue
Block a user