I wanted to play around with ChatGPT, figure out how it works, where I could make use of it, and what it's (current) limitations are.
Previously, we tried using ChatGPT to generate and then analyse a dataset, which I thought it did impressively well in.
But in that case, it can be guided function by function. What about something more complex, with many moving parts?
To that end, I wanted to see if ChatGPT could code some basic game mechanics, and to document observations.
Since I am familiar with PyGame, I asked ChatGPT to code in that.
Rules are I can give hints to ChatGPT where I think the error is, but I can't edit the code myself.
The prompt used for all of these is for ChatGPT to take on the role of an expert game developer, and particularly one that codes in Python/Pygame.
The jump functionality was initially broken. A few prompts later (x3 attempts), instead of not being able to jump, the character just went through the floor.
Then jumping worked, but only on the ground, and not on the platforms. After 2 attempts, the jumping was fixed.
Unlike a normal 2d platfomrer, the game screen was static. I asked for a scrolling level, which it got right on the first try!
There are stil many things to add, like enemies, the level endpoint and maybe some items, and maybe we can revisit this later.
The code for the mariolike can be found here.
Addendum: So I asked it to implement a scrolling screen, checkpoints and levels. This is when everything starts to go haywire.
The shifting world made the calculations go berserk, and although it was easy for me to fix the issue manually, ChatGPT could not fix it.
Even after about 30 prompts and collaborating to debug the progam by printing x-coordinates (my idea), the solutions seem to get worse and worse.
One take away I think is to focus on more modular code, where each function cannot interact with another except in very specific ways.
Stay tuned ...
The games mentioned were used ias inspiration for game mechanics only. No commercial/copyrighted assets were used.
Will be updating this page ...