Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made visual rendering steps optional for major runtime enhancements #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Tamrell
Copy link

@Tamrell Tamrell commented Sep 14, 2021

I am currently following the course "Evolutionary Computing" at the VU Amsterdam, using snakeviz (a python profiler) I noticed that even when using the suggested code:

headless = True
if headless:
    os.environ["SDL_VIDEODRIVER"] = "dummy"

the majority (90% + ) of the runtime is caused by the drawing/rendering on what seems to be a "dummy" screen/gpu.

I added in a flag (visualmode) for the environment class that disables purely the (non-functional) drawing components for a noticeable speed enhancement.

Hopefully this can still be accepted during this edition of the course so the other groups can also spend more time on analysis rather than running experiments :)

Regards,
Angelo

Copy link

@OlegBEZb OlegBEZb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love you, dude

pygame.draw.line(self.screen, (0, 0, 0), [40, 40],[140, 40], 2)
pygame.draw.line(self.screen, (0, 0, 0), [40, 45],[140, 45], 5)
pygame.draw.line(self.screen, (150,24,25), [40, 45],[140 - vbar, 45], 5)
pygame.draw.line(self.screen, (0, 0, 0), [40, 49],[140, 49], 2)

# enemy life bar
vbar = int(100 *( 1-(self.enemy.life/float(self.enemy.max_life)) ))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my also be moved under the condition

self.tilemap.draw(self.screen)

if self.visualmode == "yes":
self.tilemap.draw(self.screen)

# player life bar
vbar = int(100 *( 1-(self.player.life/float(self.player.max_life)) ))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anywhere else. may be moved under the condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants