chatGPT creates Arduboy Game

:flushed:

I don’t think we did exponents when we did the algebra unit.

Asked Chat GPT:
Take a deep breath and think clearly through each step. I want you to code an arduboy game for me. The game should present you with 6 objects to chose from on the screen. Only one of them is the correct choice. Each round of the game has the same 6 objects, but which one is the winning selection changes.

Only problem was round is a reserved word in Arduino it didn’t know about. Otherwise compiles and actually works as described with some weird UX problems like just not simply knowing full white screen is losing and full black is winning. But as a frame work to build off of, it’s amazing. I did it as a joke but it was actually pretty much what I was going to write out anyways I started using it and it’s still the basis of my code.




#include <Arduboy2.h>
Arduboy2 arduboy;

// Game variables
int correctChoice;  // Index of the correct choice (0-5)
int selectedChoice; // Index of the player's selected choice (0-5)
int round = 1;      // Current round

void setup() {
  arduboy.begin();
  arduboy.clear();
  randomSeed(analogRead(0));
}

void loop() {
  if (!arduboy.nextFrame()) return;

  arduboy.pollButtons();

  if (arduboy.justPressed(A_BUTTON)) {
    // Check if the selected choice is correct
    if (selectedChoice == correctChoice) {
      arduboy.fillScreen(BLACK); // You won!
    } else {
      arduboy.fillScreen(WHITE); // You lost!
    }

    arduboy.display();
    arduboy.delayShort(1000);

    // Start a new round
    round++;
    if (round > 6) {
      round = 1; // Reset rounds after 6
    }
    correctChoice = random(6); // Randomly choose the correct object
    selectedChoice = -1;      // Reset player's choice
    arduboy.clear();
  }

  // Draw the objects on the screen
  for (int i = 0; i < 6; i++) {
    arduboy.drawRect(i * 20 + 5, 20, 15, 15, (i == selectedChoice) ? WHITE : BLACK);
  }

  arduboy.setCursor(10, 40);
  arduboy.print(F("Round: "));
  arduboy.print(round);

  arduboy.display();

  if (arduboy.justPressed(LEFT_BUTTON) && selectedChoice > 0) {
    selectedChoice--;
  }

  if (arduboy.justPressed(RIGHT_BUTTON) && selectedChoice < 5) {
    selectedChoice++;
  }
}

This was using chatgpt 3.5. I talked to a guy that works and openAi and he suggested what if they took the arduboy forums and trained a version of chatgpt 4 on it. And I’m starting to think that could be pretty amazing.

2 Likes

Honestly ive still been using GPT4 for help with coding this 3D mech game (posted in another thread) just because its allowed me to test different approaches much faster than i could on my own (not to mention my programming experience is limited so its helped me to learn/remember a lot of different things that otherwise wouldnt occur to me)… but based on my experience using 3.5 (on OpenAIs site and with github copilot) its much more likely to either make a complete mess of things or give answers that are downright incorrect… GPT4 on the other hand, has significantly helped about 75-80% of the time (and it seems like most of the little bits it gets wrong are easily fixable), and if something doesnt work quite right you can tell it the intended vs observed behavior and its really good at making corrections (whereas 3.5 seems to just repeat the same incorrect information). Granted i had to develop each part iteratively and past a certain point in development things became a bit too long (due to limited tokens for prompt input and somewhat limited scope of its attention) but if it was actually trained on arduboy-specific data then it would be remarkably effective

I haven’t tried gpt4 directly, just bing and bing wont give me code so… and gpt4 costs like, money and stuff so…

But I agree with you.

Where it’s been most useful is treating it as a shortcut to looking up basic code examples. Like, off the top of my head I don’t know how to format a two dimensional array and step through it easily. So asking gpt to write that part of it for me was great.

I’m finding it especially useful when I want to create some kind of iterative code where it would be annoying to copy and paste something 6 times. So I tell gpt to handle 6 elements.

In this example, I didn’t have to go through and do the math to figure out how to evenly divide the screen up with 6 elements.

Later on I asked it to draw the cursor with a vertical sinusoidal movement and it got it on the first try.

I’m curious to try GPT4 then, but yeah - like I said that’s still a general model. I talked with the guy at OpenAI he said what they do as a service they train a model specifically on a dataset and can tweak the model with different weights. Effectively that’s what they did at a large scale for bing.

But imagine that, come to the website and you just kind of tell it what kind of game you want. Virtual @pharap don’t want to replace you. I actually kind of wonder what people on the community think about that?

Because Arduboy is in a unique situation that it’s open source and virtually all of it’s content is covered under a license that to some degree would allow this? The problem is the attribution.

Does having an open source license allow for scraping and training for AI data purposes?

What do people on the community think about their code being used to train AI? By the way I’m not really thinking of actually doing this - I don’t think I could remotely come close to affording it (assuming it’s like $MM). Just curious about the technology.

2 Likes

Virutal Pharap :joy:. At this point I think we all refer to @pharap as the Arduboy programmer lol. The A.I. idea could be pretty cool, but I’d then struggle to see the point of the rest of the forum. Personally I prefer it the way it is right now, and if anything, you can always ask ChatGPT elsewhere if you really need too.

2 Likes

Yeahh, i was using 3.5 at first since it was free, and just tried using github’s Copilot (which uses OpenAIs 3.5 Codex model)… both can still definitely be helpful figuring out separate parts but are much more likely to introduce incorrect information and/or parts of code… and when i tried using Copilot (which runs in the VSCode GUI and has the entirety of my code next to it) i couldnt get it to maintain separate variables for my player angle and view angle (since they rotate opposite), it kept changing everything to angle… i usually cant afford to pay for stuff lol, copilot just had a free trial and GPT4 has been so much more useful i might pay for a month every now and then.

This definitely seems to be where both models seem to be most useful as a supplemental tool for programming (and learning how to program)… but sometimes GPT3.5 will only give you one approach, 4 is a bit more varied.

Honestly ive been thinking about this, considering ChatGPT has already been trained on data they scraped off of github (some of it Arduboy related)… any help ive gotten from it ive tried to adapt and make my own as much as possible rather than just copy and paste (since that can be plagiarism, violate licenses, etc) but if i ever do put anything out I’ll want to put a disclaimer with it just to say ‘hey if any of this looks like it might be yours let me know so i can at least give you credit’ lol.

Anyway, a model trained specifically on Arduboy data would be awesome (and maybe we can figure out a way to do it one of these days with some of these lightweight LLM’s coming out now) but i agree with @Ard_Flamingo, definitely prefer a more active forum (and all the info in it) and using it more as a supplemental tool.

Now that OpenAI has released their ‘GPTs’ feature, I wonder if anyone will create one for Aduboy game development.
I may take a stab at it, but I don’t really know what I’m doing :joy:

It can help you build your own home made too!

1 Like

Looks really complex … but I note this one has a volume switch or two. That’s cool!

image

That clears everything up.

1 Like

Remind me, do I connect OKFT to AGND and SPEEEEY to BATHUONG, or SPEENTG to ST PCCEHHO and OKFT to SPEEEEY?

3 Likes

It depends on whether you have an SH1106 or an SSD1306. Likewise are you using the alternate wiring?

I read that as BATHDONG but didn’t want to comment for obvious reasons.

This bit is a little Dali-esque.

Screenshot 2023-11-24 at 10.56.35 am

1 Like

ChatGPT is actually surprisingly good with this! This is what I got with the prompt “how do you make a diy arduboy”

Creating a DIY Arduboy involves a combination of hardware and software. The Arduboy is an open-source handheld gaming console based on Arduino. Here are the general steps to create a DIY Arduboy with images:

Hardware:

  1. Materials:
  • Arduino Pro Micro or similar (ATmega32U4-based).
  • OLED Display (e.g., SSD1306-based, 128x64 pixels).
  • Pushbuttons (typically 4 or 6 for input).
  • Speaker or buzzer for sound.
  • Battery (LiPo or other suitable power source).
  • Prototyping board or custom PCB.
  • Wires, soldering iron, and other electronic components.
  1. Schematic:
  • Design a schematic for connecting the Arduino, OLED display, buttons, and speaker. You may find existing Arduboy schematics online as a reference.
  1. Assembly:
  • Connect the components on the prototyping board or custom PCB according to the schematic.
  • Solder the connections carefully, ensuring there are no short circuits.

Software:

  1. Install Arduino IDE:
  • Download and install the Arduino IDE from the official website.
  1. Install Arduboy Library:
  • In the Arduino IDE, go to Sketch -> Include Library -> Manage Libraries.
  • Search for “Arduboy” and install the Arduboy library.
  1. Programming:
  • Write or find games and applications for the Arduboy. You can use C++ and the Arduboy library for this.
  • Example games and codes can be found in the Arduboy community’s repositories on GitHub.
  1. Image Conversion:
  • Convert any images you want to display on the OLED screen into a format compatible with the Arduboy. The Arduboy typically uses monochrome bitmap images.
  • Tools like GIMP or online converters can help you convert images to the required format.
  1. Sound:
  • If your DIY Arduboy includes sound, implement sound effects in your games using the Arduboy library.
  1. Upload Code:
  • Connect your DIY Arduboy to your computer using a USB cable.
  • Select the appropriate board and port in the Arduino IDE.
  • Upload your compiled code to the Arduino.

Testing:

  1. Power On:
  • Power up your DIY Arduboy and test its functionality.
  1. Debugging:
  • If something isn’t working, check your connections, soldering, and code for errors.
  • The Arduboy community forums and resources are excellent for troubleshooting.
  1. Refinement:
  • Refine your design based on your testing and make any necessary adjustments.

Note:

Before starting the project, it’s essential to thoroughly understand the specifications of the components you are using and have a good grasp of programming in C++ with Arduino. Also, check the licensing of any games or code you use to ensure compliance with open-source standards.

That’s pretty cool, it actually knows that it’s best to use an ATmega32u4 and an SSD1306!

1 Like

Yeah, its done a nice job really.

If we can raise $2M to train a model on the community I bet it would be pretty amazing

2 Likes

Persistence of (Random Access) Memory.


That’s almost certainly because they’ve scraped the site with crawlers.

Good luck to whoever decides to only have four buttons.

The AI does at least get points for knowing to say C++ and not C.

Between that and the talk of licences perhaps it actually has ‘learnt’ something useful from all those rants of mine?

‘Knows’ is questionable.

It’s basically just ended up regurgitating high-frequency information whilst establishing some ‘notion’ of the relationships between the terms, which is somehow encoded within the ‘neurons’ of the network.

(I’ll stop there before I start raving on about the Chinese room experiment and Markov chains.)

1 Like

Someone in the FlipperZero community made one for helping people dev apps. I’m trying to figure out how that one works and maybe applying the same principles to a new ArduBoy GPT.

https://chat.openai.com/g/g-EwFUWU7YB-flipper-zero-app-builder

https://www.reddit.com/r/flipperzero/comments/17zz4jf/flipper_zero_gpt_answer_all_you_need/

https://chat.openai.com/g/g-5jOvxU3D2

ArduBoy Ace
A custom GPT to help create ArduBoy games.

I’ll keep poking at this a bit and will use it to make a game this weekend as a test. Once it’s good-ish, I’ll make a new post.

1 Like

It’s very interesting, I hope you aren’t creating skynet and in the future robots treat people like retro video game carts. >.>

Let me know how you get on over there I know some people that work there that are interested in Arduboy.

1 Like