A Celestial Simulator For The Kids Written In Python

Paul Kenjora At Google
2 min readMay 2, 2022

My daughter wanted to try coding this week, specifically she wanted to build a game. As an engineer, I was thrilled at the power she was about to discover. As a father, I was horrified by the number of hours my eight year old might spend in front of a screen. Was it too early to bring this into her life… there is still so much to do in softball, tennis, swimming, soccer, riding a bike, reading books, or just going outside.

Two solar systems colliding in our celestial simulator.

As an engineer I understand that even with modern IDEs, the process of developing software, especially games is long and tedious. How do you explain to a kid that they’re signing up for hours in front of the computer to get the simplest game mechanic working? Or do you let them try and learn its hours of work on their own? Maybe thats a lesson for a later day, for this one I just wanted her to have some fun while we looked at code.

The Compromise

We talked about it and decided to try a less time consuming but just as creative project… an existing planet simulator. This is something simple that uses the popular PyGame engine, draws graphics, and can be modified in a few minutes. Plus it looks really cool when it runs, like a game.

The Play

Running the simulator written by Enos, thank you by the way, was a great call. We had something running in seconds and her first take was… “Whoa, cool!” That bought us enough interest to mess with the code a bit. Of course we added multiple suns and planets that would end up drawing spectacular solar system collisions!

What worked well was talking about the code and it makes the planets move instead of trying to design the code. What was tough was the pace, minor changes to the system would disrupt the flow. All in all we spent an hour talking about the planets and how the program works. The talking with each other part was a win!

The Work

Being an engineer is a blessing and a curse. While running the simulation we quickly ran into some lag. After my daughter went to bed I spent the evening playing around with the code resulting in three changes:

  1. More speed means more planets!
  2. Configurable simulation files so we can save the coolest collisions.
  3. Moons! Because defining an orbiting body shouldn’t be that hard.

I checked our Celestial Simulator into GitHub with screenshots! I’ll reach out to Enos and offer to merge the repositories. My hope is sometime in the future my daughter and I re-visit this project with my daughter driving more. Maybe an upcoming science project? If there are any astronomy buffs out there we’d love to collaborate.

--

--