You are browsing as a guest. Sign up (or log in) to start making projects!

1h 32m 8s logged

Ok… The scope gets even bigger. I did A LOT of work this time, in very small but meaningful changes. Tl;dr: I improved the code, made the project look nicer, changed some of the keybinds, and made it much better to use.

  • Various code improvements: The code is generally cleaner now. I took the time to go over the if-statements and such, and then remove unnecessary things. I also split it up into several different files. As of right now, I have one to store the main Board class (board.py), one for the themes (themes.py), and then the main.py file stores the main while loop.
  • Visual changes: I made some visual changes that I think make the project nicer.
    • Instead of the gray bar at the bottom, I put the status line at the top left corner and made it toggleable by a keybind. I think I might put a rectangle behind it to make it look cooler and distinguish it from the white cells in the default theme (at the moment if there are squares there you won’t be able to see the text.
    • I changed the title bar. This was fairly straightforward, only 2 lines of code. I made screenshots of the glider in all the different themes, so now it will pick a random one for the icon at startup.
  • Performance improvements: I wasn’t really sure what to name this category, though the project probably won’t be the most performant thing ever… On a slightly older laptop it took ~10% of the CPU (Ryzen 5 5500U) and 100MB ram. Anyways, the main thing here is that the FPS is now separate from the speed of the simulation. I had to do this because the dragging was very choppy and would skip a lot of cells when the FPS was low. To fix this, I started tracking the delta-time (the amount of time since the clock tick at the end of the main while loop last updated). I was then able to add it to a counter variable every time the while loop ran. By comparing that counter value to my set interval, I am able to control how many times per second the simulation is ran. Thus, I set the FPS to 120, which is pretty smooth and not as resource-intensive as 256 (small difference, but eh). By default, the simulation will run 8 times per second.
  • Keybind changes:
    • The s key toggles the statusline.
    • The n key runs the simulation for one generation.
    • The c key clears the board (did I mention that before?).
    • The + and - keys have been unbound. I felt they weren’t that necessary.
    • Keys 1-7 change the presets from 1 generation/second, and doubling until 64/s. I felt any more than that was unnecessary and it wouldn’t refresh anyways because the FPS is 120. Could let the user change it in the future.

I’ve been telling myself that I am close to finishing the project, but I keep adding new things. I’m sure I’ll find a new feature to add.

0
4

Comments 0

No comments yet. Be the first!