Cactusdan's blog

Next Steps for Hunger Games Simulator

hungergames.py

Several years ago I used BrantSteele's Hunger Games Simulator and had a lot of fun with it. I thought implementing it at a basic level would be pretty easy and would have a fun result. Armed with rudimentary python knowledge and a lot of free time, I made hungergames.py in a few days. I'd spend the next few weeks or months tweaking, refining it, and adding to it, and once I was happy with the result it became one of the first things I put on github.

That project stands out to me because it's the first project I can remember other people really having fun with (rather than just saying "oh it's so cool that you made that" or something.) It's still my most starred github repo, with 2 stars instead of 0. And honestly it's a lot of fun to mess with. Despite that, there were things I really didn't like about it.

I felt I could do much better, but I didn't want to just improve the program that I'd written. I didn't want a copy of brantsteele either. I wanted a simulation where everything has some reason for happening. Where tributes inhabit a play area and perform actions in relation to their surroundings. It helped that at that point I was much better at programming.

hungergames-js

I wanted my new hunger games simulator to be playable online, so I planned from the start to put it on my website. I wanted it to have absolutely 0 dependencies other than a web browser with javascript to play it. The code is split up into multiple files, imported with ES6 modules. All DOM manipulation is done in pure javascript. Bootstrap 5 is used for layout (so I guess I failed the "no dependencies" thing xd)

The result is playable online here. The code can be found on my github.

The most important change I made is removing pure randomness from the game. While randomness does mostly control what happens, things happen with probabilities that change depending on the circumstances of the tribute. For example, a tribute will be far more likely to forage if they need to eat and have no food. They'll also be much less likely to engage in combat if they don't have a weapon. Traps are placed at the start and disappear after being triggered, rather than just showing up randomly whenever someone moves. Basically, I feel it's a much more convincing and fun simulation. But it still has issues.

Mostly these issues are UI/UX related. Doing all of my DOM manipulation in javascript means fixing these will be a horrible giant PITA. I think a change of codebase is in order again.

So the way I see this project going forward is that the current hungergames-js project will no longer receive updates. Then I have 2 options I could see myself doing.

  1. Pick a new framework, likely vue or htmx, and port my work over to that. From there making changes should be a whole lot easier.

  2. Make a new project in godot. This way I could easily make the simulation real time, and introduce fancy graphics effects and stuff. I could also still publish the result online.