Wednesday, 9 July 2025

About my experiment to make simple JavaScript games using AI tools

 In case anyone’s thinking that using AI tools to help create games is just a case of typing into ChatGPT “make me a game like Tetris, but better”, it isn’t. (Well, I guess in truth I haven’t actually tried that, but…) The thing with AI is that the quality of output you get is very much dependent on the quality of input you give it. Also, don’t expect that you can get what you’re looking for on the first go – you can try to front-load the first prompt with context and information, but that will still only get you so far.

So why did I want to experiment with using AI to make simple JavaScript games in the first place?

·         I have no interest in actually learning to code JavaScript – I simply don’t have the time. It took me long enough to learn AGS script (which is very similar to C++) which means I can usually follow what’s happening in JS due to similarities in the two languages structures, but I can’t code it. (I did code HTML many years ago, but really even back a couple of decades ago, most people were using a visual editor rather than hand-coding it anyway.)

·         I use AI quite extensively in my day job and have become fascinated by the possibilities. Like most people who have actually spent significant time learning about and using AI, I see it as simply a tool that can be used, and rather than deskilling it can be used to help people in certain professions focus on what their jobs actually should be, rather than spending most of their time on repetitive documentation tasks. I do appreciate that there are specific use cases where use of AI is highly controversial – art generation for instance – and I fully understand that viewpoint.

·         Linked to that, it seems to me that AI has been trained on coding that has been intentionally made publicly available. My goal is to leverage the strengths of AI – which is in producing clean, usable boilerplate code and implementing simple game logic – while avoiding trying to get it to do anything too complex. That’s where a real coder is still (from my understanding, at least) miles ahead of what a GPT can do.

·         Given that, I’m using an AGILE methodology – my process is a very simple three-tiered loop:

o   Think about what I want to achieve on this iteration

o   Create a prompt that explains this to the GPT as clearly as possible

o   Test the results, and go on to the next iteration (unless I feel the game has already reached its target state)

o   This is very small-scale stuff, just me working with AI, so I’m not bothering with even thinking of anything in terms of “sprints” etc.

What’s required from me in this case, since I’m not doing any of the actual coding? Well, first of all, I need the original idea. (My very first project was a simple noughts-and-crosses game, just as proof of concept, but my plan is to create some small but unique games.) Then it’s a case of knowing how to write high-quality AI prompts, and how to give it comprehensive, clear instructions that are not open to AI hallucinations. Along with this, understanding how the game should work at a fundamental level is required – if you’re just remaking noughts and crosses then yeah, no specific knowledge is needed, but if you want to create something unique, you need to first understand yourself exactly how it should work “under the hood” and then how to get that across to the GPT.

In theory, each iteration should take you nearer to the goal. In practice, I have found that whilst this is usually the case if my prompts are very precise, there is still room for the GPT to misinterpret what I’ve asked it to do (the blame for this can be shared between me and the GPT!)

 I’ve set certain limitations for myself – I only want to create something in vanilla JavaScript (with a little HTML / CSS thrown in for the page design), so no libraries allowed, it must be either a single player or player vs AI opponent, and it must run within a Blogger post (so I can put it here along with a short explanation of how the game was designed). I will also be using only the free Chat-GPT model, and (potentially barring some very small modifications to the HTML components) not directly editing the code myself.

My goals with this are simply to have a bit of fun seeing what I can come up with and learn a bit more about the possibilities and limitations of current free GPT models. I also needed something a little different to kick-start my brain – with what time I have available, hand-crafting games in AGS is still my main focus. When all’s said and done, there’s nothing quite like solving a tricky coding problem yourself!

Okay this post ended up being quite a bit longer than I thought it would be and I’ve probably missed out some things that had been in my mind, but anyway… I’ll start posted the results of my experiment soon.

No comments:

Post a Comment