Inspiration

I'm a huge science fiction fan -- so much so that I started and ran a science fiction magazine for five years, and I'm still very engaged in the science fiction community.

Back in October I had the idea to start making a series of short games to explain hard science fiction concepts in a fun way. Right after I started the game, I saw that AWS was having a Game Builder Challenge, so I decided to write my first hard science fiction game as a part of the hackathon! I've always loved the concept of Dyson spheres (enveloping a star to use all available energy), so that's where I started.

I originally thought that development would only take 10-20 hours, but the scope of the game ballooned, and ultimately I ended up spending closer to 70 hours developing the game (the entirety of which were spent after my wife and kids went to sleep at night, which is my excuse if you encounter a bug). Effort estimates are one of the most difficult parts of software engineering!

What it does

Dyson Swarm is an incremental (clicker) game about dismantling the solar system in order to completely envelop the sun in space habitats. You start as a simple game developer, and progress through stages, building up resources as you go along.

At the end, you've created a solar-system-spanning civilization of quadrillions of people.

How we built it

The game is built using client-side Javascript, and runs entirely in the browser. Since all the game code is served through static HTML/Javascript elements, the cheapest and easiest way to host such a game is with a static site S3 bucket fronted by the Cloudfront CDN -- this allows fast serving of the files all around the world, and cloudfront can do the TLS termination so that you don't need to deal with custom certificates or servers.

The site also collects some high-level metrics about how many people are playing the game (anonymized), and how far they're getting (what stage of the game they've completed). These metrics are stored in an RDS postgres database, and get there via a serverless API built using API Gateway and Lambda. I'm using an RDS instance, since I already had one available, but you could just as easily use serverless RDS for this.

I deployed the S3 bucket and Cloudfront distribution through the AWS console, and created a Python-based AWS CDK stack for the serverless metrics lambda.

I used AWS Q Developer mostly to replicate repeating patterns in my code, to great effect. For instance, I told it things like "add 2 percent inflation to all repeatable buttons (other than the marketer button), in the same pattern as the ad purchase button inflation." and it saved a ton of time!

Challenges we ran into

Initially I let Q Developer go wild on the code, which caused some subtle bugs. I had to find the sweet spot of giving it specific chunks of work that I knew it could do well.

Accomplishments that we're proud of

I've never actually completed a real game before! I've made toy games in the past, but this is the first game I've made that people actually played and had fun. I'm very proud that the game provoked these kinds of comments from my writer's Discord:

"as someone who does not really consume hard science fiction whatsoever, I felt delightfully bewildered by everything that was happening, and I enjoyed the gameplay, it made me feel like I was playing cookie clicker yet somehow also being productive and learning things"

"I was definitely supposed to be working on something today... now I have no memory of what, there is nothing left in my head but Accruing Mass"

What we learned

I learned how Q Developer works, how best to use the /dev feature, and I learned a lot about serving static pages from S3 buckets with Cloudfront TLS termination (How to do Cloudfront cache invalidations, etc).

I was able to refine my AWS CDK knowledge as well, when building the serverless metrics API.

What's next for Dyson Swarm

I'd like to refine the endgame, I think it could be made much more satisfying. I'm also going to make this the first in a series of games that introduce people to hard science fiction concepts.

Built With

Share this project:

Updates