← PROJECTS
Bamboo Master thumbnail
Bamboo Master logo

Bamboo Master

Avoid flying arrows

Personal2024Source ↗
JavaScript
p5.js
Webpack

This project was built for the "Data Structures" inquiry project, a subject in the 2nd-year Web Programming major track at Korea Digital Media High School.

1. Overview

The inquiry project activity involved picking a book, reading it, and then building a project related to its themes. I read The Selfish Gene and wanted to build a project exploring the nature of genes and the process and outcome of inheritance.

The Selfish Gene is about the primacy and precedence of the gene. The author, Richard Dawkins, argues that genes behave in a way that isn't altruistic and exists solely to be passed on to the next generation. I wanted to use a genetic algorithm, since it captures these same characteristics.

I thought about what kind of project could combine an artificial neural network with a genetic algorithm, and I got the idea from a friend nearby who often played Bamboo Master, a classic Korean arcade game — which led me to plan a project where an artificial neural network learns to play Bamboo Master and passes its "genes" on to the next generation.

2. What I Did

The plan was to implement Bamboo Master in JavaScript, apply an artificial neural network so it could clear the game, and have that neural network's traits passed on to the next generation through a genetic algorithm.

As planned, I first built Bamboo Master itself. You can find the details in the blog post below.

Building Bamboo Master

At first I didn't even consider a neural network — I thought I could just create entities that randomly pressed the arrow keys (←, ↑, ↓, →) and have them inherit traits. So I started by researching genetic algorithms.

What is a genetic algorithm?

But even the logic for randomly pressing arrow keys wasn't well defined, and even when an entity endlessly mashed random arrow keys, the input was detected but the character wouldn't move. After a lot of back and forth, I gave up on raw key input and decided to bring in a neural network instead.

What is an artificial neural network?

I built entities with a neural network and implemented the process of passing those networks on through inheritance.

Applying the genetic algorithm

3. Retrospective

I understood the basic mechanism of a genetic algorithm, but I didn't know what factors to consider when actually writing the flow in code — this project got me a lot closer to understanding how to apply one in practice. Studying artificial neural networks even a little also taught me about their structure. I usually spend most of my time on frontend and backend development, so I'd kept my distance from these kinds of algorithms, but I'm glad this gave me the chance to get closer to them and try something new.

I also ran into a lot of difficulties along the way, and each time a friend helped me work through them — it felt good knowing I had people around me who could help.

ASSETS