Kerbal Space Program: Let Python Put You Into Orbit.
Some of my favorite hobbies are the ones that involve playing games and picking up practical skills, and it’s even better when I can enjoy both at the same time. One of my favorite games to learn with and pass the time is Kerbal Space Program, and a computer language that I have been learning recently is Python; It should be no surprise that I immediately looked for a way to integrate the two and lucky for me there was a mod that could interpret the Python language and use it to conduct your space missions for you: learn to code and launch rockets? YES PLEASE.
The mod that allows you to do this is called kRPC and it is reminiscent of an older mod for KSP called kOS (Kerbal operating System), but what makes kRPC superior to kOS is that instead of using its own unique language it comes with client libraries for many popular languages including C#, C++, Java, Lua and Python. Clients, made by others, are also available for Ruby and Haskell.
I found and followed a fantastic tutorial by TAPE Gaming which helps you with setting up Python on your operating system and configuring Kerbal Space Program in order to properly run the kRPC mod.
It is quite an easy tutorial and he will have you setup and starting to code within minutes! THERE IS A QUICK DISCLAIMER: As of the time of this article, there is a newer version of kRPC than what is used in the video, so instead of reverting your KSP version to 1.4.4, you will revert it to 1.5.1 and use kRPC version 0.4.8 which can be found here.
Once you have gotten everything setup with the above video and you are willing to dedicate more time to it, you can watch part two and part three which will really go a bit more in depth and have you getting a vessel into orbit, completely by code!
I highly encourage you to give it a shot and to even check out more tutorials that are available in both text and video format. Here is a video of my first successful launch after having completed the tutorials. In all of my years launching rockets in KSP and bringing them into orbit, it has never felt as good as it did when my code finally pulled through and did the work for me.
As you can see, there is always room for improvement, but the rocket launches, maintains a heading, performs a gravity turn, and finally reaches orbit at the designated periapsis and apoapsis. I look forward to exploring this new method of learning Python and can’t wait to see what comes next, perhaps I’ll try for a Mun (moon) landing next! You know the saying: One small step for kerbal…
Best of luck and Ad Astra!