My first projects

The very first projects I coded

Pythonbeginner Projects

Introduction

Between 2016 to 2018 (14-16yo), I had an amazingly supportive Computer Science teacher who introduced me to Python and answered all my questions during breaktime (when we theoretically weren't allowed inside the building). At home, I coded on a small 16GB iPad mini using the Pythonista app (Big thanks to the users cvp and johnb on the Pythonista forum, who helped me consistently and patiently for those two years). Whatever I could think of, I coded it. In the worst fashion possible, as I hadn't heard of objects yet, nor that I could stack lists into matrices. I didn't even know what a matrix was anyways. Sadly most of my projects used Pythonista-specific modules, so even if I hadn't lost them, I couldn't run them anymore. Here's what I did:


FlappyBird Clone with Reinforcement Learning AI

FlappyBird disappeared from the App Store, so I recreated it and added a RL AI. This idea came from YouTube (maybe CodeBullet?). In the end, it worked surprisingly well, it beat me consistently and by a significant margin. Of course, it was a very simple NN with few inputs and just one output, and I didn't understand activation functions and stuff. But it was 2017, I was 15yo and it was before the age of LLMs.

Core Concepts

  • Reinforcement Learning: There was a really easy to use library for a mix of evolutionary and reinforcement learning. This taught me:
    • Less, but well-prepared data is critical for quick learning (I only had an iPad, so training always took minutes, which seemed like an eternity back then).
    • Data normalization: "the dude in the video said something about dividing inputs by their maximum possible value? -> Oh, that worked!"
    • Hyperparameter tuning: "whoopsie, setting layers=100 crashes my IDE and layers=1 doesn't work. Alle guten Dinge sind drei, so let's stick with three. Oh, spawning 9999 birds fails? Let's use less."
    • Success Metric: This one was simple. The time a bird survived was enough.
    • Survival of the fittest: I devised a method to transfer the n fittest birds to the next iteration. And because the guy in the video did it, I also let a few random birds survive.
  • Physics: The bird followed physics to get an intuitive trajectory. Every tap gave them an upwards impulse.
  • Reduction: Having successfully implemented graphics and animations before, they weren't the focus anymore. I just used rectangles.
  • Progressive difficulty, again following a log-curve as described in the Asteroids game.

Search Algorithm Visualization

Having seen visualizations of how algorithms like A* or Dijkstra explore mazes on a grid structure, I coded my own visualization where the user could draw custom mazes. Once it worked for A*, I never implemented Dijkstra, since I had already understood it and was burning for the next project.

Core Concepts

  • Basic search algorithms like A* and Dijkstra.

Falling Meteors Game

This was a basic game where meteors of different sizes would fall from the sky. On the ground, there was one turret and a few houses. The user had to click on the meteors to shoot them, and once all houses were destroyed, it was game over. Large meteors would break into smaller ones once their health depleted, very small ones would disappear after one hit. The graphics were hand-drawn vectors.

Core Concepts

  • Physics: The bullets followed a conservation-of-energy-accurate trajectory under the assumption of no wind resistance. Asteroids just had a speed inversely proportional to their size.
  • Trigonometry: The turret's barrel oriented towards the user taps. Bullets oriented tangentially to their trajectory.
  • Random: Meteors spawned randomly with a random size at random time intervals.
  • Progressive Difficulty: The game would constantly get more and more difficult by increasing meteor size and spawn frequency. I spent hours finetuning the equation that controlled how the difficulty progressed. This was my introduction to log-curves, as they progress quickly at first, then flatten off, but won't hit an asymptote.

Tower Defense Game

I loved Tower Defense Games, so I decided to create my own. I found free graphics online and began coding. Sadly, I never created more than one level as the code got huge quickly. I didn't yet know I could import my own scripts, so everything was written in a single file. Nor did I use objects, I instead used many lists for different properties (e.g. animation state or health), the index representing one entity.

Core Concepts

  • Sprite Animations: I animated sprites by changing their texture every few ms. The texture also depended on the direction the NPC was walking.
  • State Encodings: I learned to encode states in numbers. For example, I auto-generated the maps from a matrix with different numbers representing different tile types.