Peanut Butter Simulator


I started this project back in the first national lockdown, a period of time where I was off school for around 6 months. The majority of my days were spent waking up, sitting at my computer, then going back to bed, with the occasional visit to the kitchen for peanut butter on toast. This allowed me an incredible amount of time to do things such as program, and this game is one of the things which came out of that.

I programmed Peanut Butter Simulator over the course of about a week during my holiday from start to finish, and worked at it for so long each day it practically turned into a full time job.

Idea for the game

At first my idea was to make an idle game virus-related (inspired by the ongoing global pandemic), where the gamer would evolve and grow their virus to become stronger and more lethal, sort of like the game Plague Inc. I quickly realised however that it probably was not the best time to create a game about killing as many people as possible with a virus while such atrocities where ravishing the plant. Thus Peanut Butter Simulator was born.

Inspired by my worryingly high consumption of peanut butter during those lockdown days, Peanut Butter Simulator would be a light-hearted and humorous idle/clicker game with the basic premise being: click the jar of peanut butter – get money – upgrade peanut butter.

The main inspiration for the game was Egg Inc. A mobile app where start by running a humble chicken farm, until egg technology grows and the world discovers new, powerful eggs which also happen to be worth more, allowing to grow your farm to insane levels. Eggs included in Egg Inc. consist of: Graviton Egg, Terraform Egg, Quantum Egg, etc.

I also wanted to be a clicker game, meaning you have to click on the graphic in the centre of the screen to get money.

How I made the game

Peanut Butter Simulator was created using the Python programming language, and a videogame creation module call Pygame, which I had some prior experience with, but this was to be my biggest game by far.

Feature Breakdown

Here are the features I implemented into the game.

front page

When you first open the game’s .exe file, you will be greeted by this very slapdash welcome screen, where you are prompted to input a username (the use of which will be detailed later).

Basic Peanut Butter

You start the game with the least valuable peanut butter, regular peanut butter. There are 3 main variables which determine how much money you make in the game: Price Each (PE), Batch Size (BS) and Batch Rate (BR). In addition, there is a variable holding Inventory (the amount of jars of Peanut Butters you have produced), and a money variable.

  • Price Each – the amount of money you can sell each individual peanut butter for
  • Batch Size – the number of jars of peanut butter you get for each click of the jar or when the batch rate ticks
  • Batch Rate – passive peanut butter gain, you gain BS every BR. This rate is visually represented by the green progress bar below the jar.

To gain inventory, click the jar or wait to passively gain a batch. To gain money from your inventory, click the red button at the bottom of the window, where it displays the amount of money you will gain (calculated with PE * Inventory). Money is then displayed above the sell button.

The three main variables for the making money can be upgraded with the three buttons above the money reading.

The cost and increase for each time you upgrade is calculated as follows:

Price: Calculated buy multiplying the last price by 4, apart from every 3rd upgrade, which is * 5

Increase: calculated by running a Fibonacci algorithm on the starting value.

There was very little mathematical testing on how these formulas work together to make the game not take days to complete and equally not spiral off too quickly thus making the game take too little time to complete. I found while creating this game that this goldilocks zone where the numbers do not blow up is quite a hard thing to create, and I admittedly did not spend very long fine tuning it, something I should definitely do if I were to go back to it.

Upgrading peanut butter

The amount of money needed to upgrade your peanut butter to the next level is displayed below the main peanut butter name, in this case, being £100k. Once you have enough money to upgrade to the next level an upgrade button will appear in the top right of the jar.

Clicks / second panel

This fun little feature shows how many times you are clicking the jar every second, your record for how many times you have clicked the jar, and the total times you have clicked the jar.

Tune player
Media Player

A random little extra I added to the project near the end. This feature plays some of my favourite video game and film music from over the years so my friends could bop out to a bit of Skyrim’s Dragonborn while playing Peanut Butter Sim. Comes with a pause and play button, a skip track button and a volume slider.

Peanut Butter Simulator Lore

A little I icon next to the name of the peanut butter leads to a screen with a bunch of text on, depicting the back story of the universe in which you are running your peanut butter business. The idea was to create one of these stories for each of the peanut butters in the game, creating a rich story, but I only ever did the first few.

Global Leader Board

Another feature in the game is the global leader board. So my mates could compare each other’s progress in the game, I connected the game up to a server I ran off my PC, which collected and distributed all the users money data, displaying it to everyone playing the game in a ranking, using the username system described earlier. Unfortunately I cannot show the leader board screen as that would require setting up the server again which I’m not doing right now.

Game Save

When you exit the game, a very simple save game feature is ran, where a dictionary is dumped into a text file including the level of all your upgrades, your money etc. The eval() function is then ran when the game is started again to restore the game to it’s previous state. This is a very insecure way of doing this and my friends very quickly figured out they could easily edit the text file to give themselves as much money as they wanted.

.py to .exe

Finally, I used a piece of software to bundle my code and modules up into a nice little .exe file and created an installer so I could stick my game on my google drive and distribute to friends.