Einstieg erstes kleines Programm
Beschreibung:
Wir erstellen hier erstmal ein kleines Programm zum einstieg.
Los gehts:
In unserem Programmordner erstellen wir ein neues Verzeichnis für unser Programm.
Wir wollen ein Tetris Spiel kreieren. Also nennen wir das Verzeichnis Tetris
mkdir /home/<benutzername>/gpt-engineer/tetris
In diesem Verzeichnis erstellen wir eine Datei in der wir unsere Beschreibung so gut es geht rein packen.
Denn aus der Beschreibung baut uns die KI das Programm.
Am besten man schreibt die prompts in Englisch. ChatGTP versteht auch Deutsch aber in Englisch versteht es meist besser.
Wir nutzen hier den texteditor, weil es sich darin besser schreiben lässt. Aber es kann natürlich auch Nano verwendet werden
touch /home/<benutzername>/gpt-engineer/tetris/prompt
open /home/<benutzername>/gpt-engineer/tetris/prompt
Inhalt
Ein kleines Multiplayer tetris spiel. Speichern
create an tetris game that could play on an single computer in single player an multiplayer splitscreen.
To control the blocks the first player use W to rotate and A S D to move the block and the second player
use the keys I to rotate the block and J K L to move the block.
at end game the winner can enter his name to save in the highscore.
please encrypt the highscore file with base64
The mainmenu items are singleplayer, multiplayer, highscore, exit
The pgramming language is python
Ausführen
Dazu gehen wir wieder in unsere Programmverzeichnis zurück
cd /home/<benutzername>/gpt-engineer/
Nun den Befehl ausführen.
Das API KEY script brauchen wir nur einmal in der Terminalsitzung ausführen. Wird das Terminal geschlossen müssen wir das natürlich nochmals machen
source apikey.sh
ALs Paramter wird das Projektverzeichnis übergeben, hier unser Tetris
gpt-engineer tetris
Nun bekommen wir ein paar fragen:
Areas that need clarification:
1. Are there any specific requirements for the Tetris game, such as the number of levels or scoring system?
2. How should the multiplayer splitscreen be implemented? Should both players be able to see each other's game boards?
3. How should the highscore file be encrypted with base64? Should it be encrypted when saving or when reading the file?
4. Should the highscore file be a separate file or integrated within the game program?
5. Are there any specific design requirements for the main menu, such as the layout or appearance?
6. Are there any specific libraries or frameworks that should be used for developing the game in Python?
(answer in text, or "c" to move on)
unsere Beispiel Antworten. Immer eine Antwort einegeben er frag nacheinander ab.
1. 15 Levels
2. Both Player can see because is one monitor
3. The file should encrypted when save and decrypted when reading to show the values
4. yes
5. no
6. please use no specific frameworks
Nun wird code generiert...
Zum Schluss fragt er usn ob der Code läuft, das wissen wir noch nicht. Deswegen öffnen wir in einer zweiten schell unser programmordner uns lassen das Programm starten um nachher die Frage zu beantworten.
Die Frage sieht übrigends so aus:
id the generated code run at all? y/n/u(ncertain):
Die Projektstruktur
Das Verzeichnis sieht so aus
~/gpt-engineer/tetris$ ls
archive memory prompt workspace
In workspace ist unser code, dort gehen wir ein
cd ~/gpt-engineer/tetris/workspace
Der Inhalt
all_output.txt highscore.py player.py run.sh
block.py main.py README.md tetris_game.py
Mit der run.sh können wir das Programm starten.
Dieses muss aber noch ausführbar gemacht werden, denn das hat gpt nicht für uns gemacht
chmod +x run.py
Nun starten
./run.sh
Wie wir sehen hat das nicht ganz geklappt
Also beantworten wir die Frage mit nein.
Nun werden wir gefragt was nicht geht.
If you have time, please explain what was not working (ok to leave blank)
Unsere Antwort
Only black Windows with an red block in the left op edge, no menuü or other things.
Nun die nächste Frage ob es okay das sie die promts speichern? Da hier jetzt keine Persönlichen Daten drin sind sag ich ja
Is it ok if we store your prompts to learn? (y/n)
y
Wir führen das script nochmal aus zum generieren.
Wir bekommen weitere Fragen gestellt.
