Proof of Concept

Published by

on

Construction

I asked ChatGPT to act as a game developer and develop a game based on the game description that had been generated then updated:

In “Scale Savant,” players engage in a musical skill-building game where they identify and arrange syllables representing pitches in piano note sequences using tonic sol-fa. The game presents pitch sequences of 3 notes in the key of C in audio form to the player, who will click on syllable objects to recreate the sequence in the correct order. Version 1.0 just focuses on recognizing thirds, so the syllables to choose from are “do,” “mi,” and “so.” Players win by correctly identifying 20 pitch sequences and lose once they have been incorrect 3 times. To help with learning, the correct answer is displayed upon loss. The game will be made using C# and the Unity Game Engine.

ChatGPT Discourse

ChatGPT gave me a nice introductory text for the game, so I asked it to make a basic interface for the game, and it gave me this:

Basic Interface Features

  1. Title Screen: The game will start with a title screen that displays the game’s logo and an option to begin the game.
  2. Game Screen: Once the player starts the game, they will be taken to the main game screen, which includes the following elements:
    • a. Pitch Sequence: A graphical representation of the pitch sequence will be shown using piano notes. This will be presented in audio form to the player.
    • b. Syllable Objects: Below the pitch sequence, there will be three syllable objects: “do,” “mi,” and “so.” These will be clickable buttons that players can use to recreate the pitch sequence.
    • c. Correct Counter: A counter indicating the number of correct pitch sequences identified by the player out of 20 will be displayed on the top-right corner.
    • d. Incorrect Counter: Another counter showing the number of incorrect attempts made by the player will be displayed on the top-right corner.
    • e. Help Button: An optional “Help” button can be provided, allowing players to seek assistance by showing the correct answer in case they get stuck.
  3. Win Screen: Once the player correctly identifies 20 pitch sequences, they will be taken to a win screen congratulating them on their musical prowess and offering the option to play again.
  4. Loss Screen: If the player makes three incorrect attempts, they will be taken to a loss screen, displaying a message of encouragement and the correct answer. The screen will also provide the option to try again.
  5. Reset Button: On the game screen, a “Reset” button will be available, allowing the player to start the game from the beginning at any time.

So then, I asked ChatGPT to provide an implementation of 2b-d. Below is the control flow of the implementation.

Basic Control Flow

  1. Initialization:
    • When the game starts (Start function):
      • The audio source is initialized.
      • The counters for correct and incorrect answers are displayed.
  2. Gameplay:
    • The game plays a pitch sequence (PlayPitchSequence function):
      • If there are more sequences available (i.e., the current sequence index is within the range of available pitch sequences):
        • The audio clip for the current sequence is played.
        • The sequence is marked as not checked yet.
    • The player listens and then selects a syllable (CheckSyllable function):
      • If the sequence hasn’t been checked yet and there are more sequences available:
        • The chosen syllable is compared with the correct one for the current sequence.
        • If the player’s choice is correct, the correct counter is incremented. If it’s wrong, the incorrect counter is incremented.
        • The sequence is then marked as checked.
        • The game waits for 1.5 seconds before proceeding (possibly to allow for feedback or a pause between sequences).
  3. Transition:
    • After a guess or after the delay, the game moves to the next sequence (MoveToNextSequence function):
      • The index for the current sequence is incremented.
      • The game checks if the win or loss conditions are met:
        • If the player has guessed correctly 20 times, the win screen is displayed.
        • If the player has guessed incorrectly 3 times, the loss screen is displayed.
        • After either of these conditions is met, all syllable buttons are disabled to prevent further input.
      • If neither win nor loss conditions are met, the counters are updated, and the next pitch sequence is played.
  4. Feedback and Display:
    • The game displays the current count of correct and incorrect guesses (UpdateCounters function).
    • If the game ends (either win or loss), all syllable buttons are disabled (DisableSyllableButtons function) to prevent further input.

Script Critique

The implementation in the script initially only allowed for one note in a sequence because the counters would be updated after each accuracy check. I queried ChatGPT on the amount of notes in a sequence, and it correctly said 3. I tried pointing out that the counters shouldn’t increment until each syllable in a sequence has been checked, and ChatGPT tried to remedy this need by adding a flag to set true after a syllable has been checked, which did not work out to associate a sequence with multiple notes.

After further discussion, including ChatGPT providing example input of the array representing the correct selections, I came to understand the ineffectiveness of the flag and brought up the need for a counter to make sure 3 syllables have been checked before proceeding to another sequence. ChatGPT introduced the counter with the effect of guarding against moving to the next sequence before 3 syllables were checked. However, since the subsequent calls to PlayPitchSequence after the initial call came from the code that was now unreachable, nothing would happen after the first note.

Finally, I clarified that the player should have selected as much syllables as notes in the sequence before accuracy is assessed, and I asked for the implementation to be rewritten with that in mind. The result was better. This is an indication to consider use of more precise language for my aims of correction and that certain levels of logical changes to implementation benefit from requests to rewrite.

Further Discussion

I asked ChatGPT to explain some of the Unity-specific code I didn’t know, namely PlayOneShot from the AudioSource component, which plays a sound once through without looping. I asked about whether audio clips could be concatenated and got options for creating new clips by combining others. I also asked for clarification in the control flow. I followed up on parts of the provided implementation ChatGPT made suggestion for, which yielded event handlers for the syllable buttons and instructions for using Audio Mixer to create sequences.

Development

I attached the generated script to an empty GameObject in Unity that acts as a controller for the game. I also followed the instructions for setting up user interface elements. I made the syllable buttons and the counters for the main game screen, and I also made win and loss screens but did not do anything with them yet. I used an image from a previous asset for the background.

For audio, I used a piano app on my phone and recorded the notes C4, E4 and G4 on my computer. I made an audio file combining the notes from lowest to highest using Audiotonic – Audacity rebuilt for Windows 10. Then I set the size of the public variable array of AudioClips to 20 and the array for correct syllables to 60. I filled the former with the audio file and the latter with “do”, “mi” and “so” 20 times. This was quite tedious to do, but it was the placeholder for the sequencing while I had a focus on the player action and progression logic. My next post focuses more on the sequencing.

Assessment

Result

The GIF below does not have the sound of the notes, but it displays what interaction with the syllable buttons looks like.

From this build for the game, it can be seen that the main game screen was not set to scale with the resolution in a pleasant way, making the correct counter increment harder to see. In the GIF below, the incorrect counter increments even though the buttons seem to be clicked in the right order.

It looks like here and this last GIF below, there’s a problem because the buttons can still be clicked when the audio clip is playing.

Improvements That Can be Made

  • resolution scaling
  • non-interactable buttons during playback
  • selection cache to display
    • can be cleared if a mistake is made

Leave a comment

Previous Post
Next Post