ChatGPT - AI explains code in understandable english

This is fun.
https://chat.openai.com/
Here’s what I pasted from my blaster prop and the response it gave:

  void Loop() override {
    PropBase::Loop();
    PollNextAction();
    sound_library_.Poll(wav_player);
    if (wav_player && !wav_player->isPlaying()) wav_player.Free();

    STATE_MACHINE_BEGIN();
    while (true) {
      if (auto_firing_) {
        tmp = GetWavPlayerPlaying(&SFX_auto);
        // Set the length for WavLen<>
        if (tmp) {
          tmp->UpdateSaberBaseSoundInfo();
        } else {
          SaberBase::ClearSoundInfo();
        }
        if (millis() - auto_time_ > 1000 * tmp->length()) {
          shots_fired_++;
          auto_time_ = millis();
          STDOUT << "AUTOFIRING - Remaining shots = " << GetBulletCount() << "\n";
          CheckEmpty();
          if (empty_) {
            SaberBase::DoEndLockup();
            SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
            auto_firing_ = false;
            return;
          }
        }
      }
    YIELD();
    }
    STATE_MACHINE_END();
  }  void Loop() override {
    PropBase::Loop();
    PollNextAction();
    sound_library_.Poll(wav_player);
    if (wav_player && !wav_player->isPlaying()) wav_player.Free();

    STATE_MACHINE_BEGIN();
    while (true) {
      if (auto_firing_) {
        tmp = GetWavPlayerPlaying(&SFX_auto);
        // Set the length for WavLen<>
        if (tmp) {
          tmp->UpdateSaberBaseSoundInfo();
        } else {
          SaberBase::ClearSoundInfo();
        }
        if (millis() - auto_time_ > 1000 * tmp->length()) {
          shots_fired_++;
          auto_time_ = millis();
          STDOUT << "AUTOFIRING - Remaining shots = " << GetBulletCount() << "\n";
          CheckEmpty();
          if (empty_) {
            SaberBase::DoEndLockup();
            SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
            auto_firing_ = false;
            return;
          }
        }
      }
    YIELD();
    }
    STATE_MACHINE_END();
  }

“This code is part of a loop function that is responsible for managing the state of an automatic firing mode in a device, such as a lightsaber soundboard. The loop function checks if automatic firing is currently enabled, and if so, it plays a sound effect for each shot fired and updates the number of remaining shots. It also checks if the device has run out of shots, and if so, it disables the automatic firing mode and performs any necessary cleanup. The code uses a StateMachine object to manage the state transitions and wait for the appropriate time to take a new action. It also uses a wav_player object to play sound effects and a sound_library_ object to manage the available sound effects.”

1 Like

Anyone else terrified by the implications for civilisation that AI tech brings?

2 Likes

Sounds like a great tool for figuring out what code is doing.
(Just beware that it may sound equally convincing when it’s wrong…)

2 Likes

Wow! I’m actually a bit surprised that it recognized this was likely from a lightsaber soundboard

You mean besides being out of a job? Lol

As a writer, yeah. I already know it’s actively stealing my content.

1 Like

And don’t get the artists started here lately either.

Curious, Mech, what do you write?

I write manuals and work as a journalist in the DJ tech industry.

1 Like

Fascinating. I went to school for journalism. I work in education now. Womp womp.

My mother was a teacher and the only piece of career advice she ever gave me was “don’t become a teacher”.

Yeah, smart lady. You can’t beat the schedule, but that’s about the end of it.