From Python fundamentals to AI game bot in just weeks

Gilad Spitzer
9 min readDec 15, 2021

--

The importance of inquisitive learning and student empowerment

*** My previous article comes after this one chronologically and focused on my high school experiences with product development while this one reflects on my initial CS exploration and the feeling of empowerment that it gave me.

My summer after 10th grade was epic! It was my last time at Camp Ramah in California as a camper and so my friends and I made sure to make the most of every moment. The ten of us had been in the same bunk for six summers already and we vowed to make our “Machon” (the eldest age group at Camp Ramah) year the absolute best. We stayed up past curfew every night hanging out and stargazing, went on some awesome hiking trips, and got way too invested in our frisbee golf tournaments. There was never a dull moment.

This incredible summer experience made the transition back to school rather challenging. For the first few weeks of 11th grade, I struggled to acclimate to my new schedule of eight courses on-top of studying for standardized tests and co-curricular commitments. When I completely failed my first computer science quiz on Python’s basic operators and keywords, I realized that I needed to snap out of summer mode.

I was excited to be taking a computer science course for the first time, but had never failed anything in my life and felt extremely deterred. I questioned whether I should continue with the course altogether.

Thankfully, my parents and other mentors convinced me to stick it out.

Looking back, that was one of the best and most important decisions I have made in my entire life; and it taught me a lot more than just the importance of perseverance. Here’s why:

Over the next 20ish weeks, the speed and complexity of the class escalated exponentially, but so did my interest in the material. I was particularly fascinated by the computational thinking mindset that was engrained in the course. I also really enjoyed the time I was spending turning my English solutions into Python executable code that would harness the unfathomable computing power that modern machines have.

I was amused by the seemingly elementary “intro to CS” projects that I completed, ranging from a command line rock, paper, scissors game to a pet age calculator. The idea that I had the tools and knowledge to interact with a computer and programmatically create something from scratch was mind blowing for a 16 year old.

The subsequent projects not only weaved in the various new programmatic concepts (functions, loops, file I/o, recursion, and objects) we had learned but also deepened my understanding of how technology as a whole functions in the modern world. To highlight a few:

  • Our class did a thorough analysis on the efficiency of different sorting methods (bubble, insertion, Python, and selection) that are widely used in modern software.
My research findings on the efficiency of different list sorting methods.
A sample output of the game.
  • Each student built a different board games using Pygame, a Python based GUI (Graphical User Interface) designer. I of course went with Connect4, my childhood favorite.
A glimpse into what my Connect4 game looked like.
  • Combining the Jewish nature of the school with the programmatic aspect of our course, we each created a tool to calculate the various Jewish prayer times of the day. Utilizing location and weather (for sunrise and sunset times) APIs along with the mathematical adjustments illustrated in Jewish law, we developed something that each of us could actually benefit from on a daily basis!
A demo of my Zemanim (Hebrew for “Times”) Project.

Side Note — Through these projects, I realized Python’s interesting learning curve. The language is super readable, “easy” to understand and simple to integrate as long as you have a solid understanding of basic computational concepts. The awesome part (or actual learning curve), however, comes with its extensive open source community. There are endless Python packages that are used for things ranging from web development and machine learning to game creation and mathematical analysis. In essence, it is impossible to “master” Python because of this and it is one of the reasons I love the language so much.

Back to my story…

As the end of the course loomed, we were instructed to prepare for an extensive capstone project. I was super excited to create something awesome with all of the different tools and concepts I had learned.

The ideas of artificial intelligence and machine learning were becoming increasingly popular in society at the time. I knew I wanted to incorporate an AI aspect into my capstone; and besides, after the last few months in this “Intro to Python” class, I felt like I could do anything with computer science.

My project proposal to create a chess game player bot was rightfully questioned for being overly ambitious. The sheer number of potential moves in chess make it quite complicated to develop sufficiently productive player algorithms. Instead, I settled for building three different games (Checkers, Othello, Connect4) with human vs human and human vs AI modes. The AI mode also had 3 difficulty levels for each game. This was my value prop:

Welcome to CGS (short for Capstone Game Suite)!!! Here you will find an amazing experience in which you can relive your childhood by playing fun board games in a virtual environment. Forget the clutter of those clunky cardboard boxes that the board games come in, and create an account on the CGS server to get started! Currently available games include Othello, Connect4, and Traditional Checkers. You can either find a friend to play with and use the default ‘Human’ mode, or you can put your skills to the test and take on the computer by switching into ‘AI’ mode! Beware, it makes its moves quickly and is extremely smart, due to the artificial intelligence practices incorporated into its decision making. Also, the higher the difficulty level that you choose, the longer it will take for the computer to make a move and the more the application will drain your computer’s battery. Bump up to difficulty 3 at your own risk :). Tired of playing for the day, but want to pick up where you left off tomorrow? Have no fear, CGS autosaves your game to your profile when you exit. Just be sure not to switch game modes, as that will toggle a reset of your progress. Your account also saves your game records when playing against a friend or the computer. I hope you enjoy reliving your childhood through these games and that they spark an interest in the wonders of computer science and artificial intelligence/decision making.

During the second semester of my junior year, I had a routine of getting into bed with my computer and working on this capstone project for an hour every night. I would don my Bose headphones and absolutely zone in on my Python code while jamming out to the Grateful Dead. A few weeks into the semester, I had already lost count of the number of accidental all-nighters I had pulled. Let’s just say creating algorithms for intelligent bots of your favorite childhood games in 11th grade is pretty freaking cool, and a lot of fun too. How could I not get carried away?!

In all seriousness, after working as a software developer for an Israeli startup and creating my own non-profit website (more to come on those topics…), I can confidently say that working on this capstone game project taught me so so so much.

A few screenshots from the final iteration of the project.

Programmatically, the most important things I learned were:

  1. How to utilize open source communities to improve development efficiency. My project relied heavily on external packages (as all modern software does). I utilized gspread (a Python wrapper for the Google Sheets API) to maintain a remote database of user data and of course Pygame for the actual UI.
  2. When it came time to integrate the Human vs AI mode for the three games, I did a deep dive on the minimax algorithm and alpha beta pruning. I wanted to become comfortable with these concepts so that I could use their ideas in order to implement my own solution. I spent ample time planning out my algorithms on paper before translating them into Python.
Some pictures of my pseudo-code notebook where I planned out algorithms before integrating them.

In addition to coding related skills, I also got a taste of what product development really means:

  1. As a class, we learned various skills including design patterns (most popularly Model-View-Control) that we could use to structure our projects, best practices for documentation, and different methods of quality assurance testing our code (white and black box, positive and negative).
  2. I also embraced the project’s open ended-ness to improve my soft skills of setting personal deadlines and taking breaks during the project development to reflect and reevaluate goals and priorities.
Click the above image to check out the extensive project website I created.

There are lots of cool things about what this project taught me. Yes, I created some awesome games while expanding my knowledge of CS. Yes, I got great experience with product development and real-world applicable tools. Yes, I taught myself high level AI concepts that most college students don’t even learn. I could go on forever about how incredible this first year experience in Python was, but there is one central point that is above all.

The beauty in all of this was how empowered I felt after only my junior year in high school. With three older siblings who had all graduated prestigious universities and were working in impressive jobs, and in the competitive academic environment in which I grew up, this feeling was no small deal. I had found a skill/language that I was ostensibly good at, loved doing, and could be harnessed to do incredible things! Being only 16 years old and feeling like I could do anything with CS after less than a year of learning it was enough to convince me that this was my path.

To further the message from my last article — this is what education ought to be about: experience and empowerment should trump knowledge and memorization. Imagine what our society would look like if more people were inspired and motivated by their dozens of years of education!

Aren’t I lucky that my parents suggested staying in the class after the first failed quiz? Neither of us would be here right now reading this if it weren’t for them.

In all seriousness, I am so thankful for the 11th grade CS course that has propelled me into incredible subsequent experiences with technology and innovation. My inquisitive learning in addition to the project based style of the course fostered a tremendous amount of empowerment and I hope that whatever field you are in or studying, you can find ways to feel that same empowerment, because it is truly life changing.

--

--

Gilad Spitzer

Entrepreneur, technology enthusiast, and passionate problem solver. Studying CS @ NYU. Experience in software and technology consulting