Pi - the game!
- 7 Devlogs
- 16 Total hours
A Pico-8 game about guessing the digits of pi one at a time! I'm using it to learn Pico-8 and an algorithm to generate digits of pi on the fly, which should be cool!
A Pico-8 game about guessing the digits of pi one at a time! I'm using it to learn Pico-8 and an algorithm to generate digits of pi on the fly, which should be cool!
It’s done! fixed the last couple issues and added some more sound effects. Finally done!!!
Almost done! Got the delay nearly fully gone with the help of itch user kevinthompson who showed me how coroutines work. I used the coroutines to split up the code that generates a digit of pi after each correct guess over many frames, so it will run at about 50% speed for like a second and then continue on lag free. There was also an edge case there, if the digit hadn’t finished generating and you picked the correct digit, it would say it was wrong! To solve this I made the game just wait for it to finish, and added some static noise to it so you would know it was intentional. Definitely not a perfect solution, but as good as I’ve come up with. I’m also considering adding music to the background, but I haven’t figured it out yet. Kind of annoying for sure…
Changed the game a lot! It feels much more polished now (better menus, etc) and most notably, the initial loading screen is gone! I made it so now the next digit is generated on the fly instead of in advance so you don’t have to wait for minutes on end before being able to play. There is a major issue though, it makes a pause happen when you get the digit correct which is very jarring. Might look into something like co-routines. You can also play it now! Let me know what you think please!
Work is being done on the game! I’ve got the main mechanics working (gameplay loop, digit selection and checking, scoring, a timer per digit, high score) but it’s all rudimentary right now. Next I’m going to make a display to see the digit you need to guess with previous digits and other visual things to make the game look better. Hope it goes well!
Got all the digits working! The issue that was causing it to stop working seemed to be an issue with the 16-bit integer limit, since at a certain point the numbers get too large to have proper precision, so they are off by a bit which causes the numbers to be inaccurate. Now time to actually make the game! Hopefully the easy part.
I figured out how many digits my stupid program can generate… 263 I have no idea why more won’t work…
I’ve gotten the first 200 digits of pi generated in Pico-8! But the 300th is wrong… okay… a bit of background. First, why am I trying to generate pi, why not just precompute it and store it in rom? Gee I wish. A limitation in Pico-8 is that one cart can only have about 8000 tokens total, and each list element counts as a token, so having a sufficiently large amount of tokens, like 10 000 would literally be impossible, so instead I’ll just compute it when the program loads up and store it in RAM. What is interesting though is how I got this done! I used an algorithm by Rabinowitz and Wagon (link to the paper: http://stanleyrabinowitz.com/bibliography/spigot.pdf) where you start with a bunch of 2s, and do various operations on them from right to left involving division and multiplication to get a number who’s 10s digit is the digit of pi for that iteration. My implementation should be working the same, however for a reason I am yet to figure out it stops working between 200 and 300 digits of pi, most likely due to a small error in my implementation that causes it to drift very slowly, only mattering after a couple hundred digits.