Skip to content

datjandra/chatgpt-python-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

ChatGPT Python Games

License

Contents

  1. Short description
  2. Prompt engineering
  3. Video
  4. Running the game
  5. Example game session
  6. License

Short description

What's the problem?

Making games is hard and require lots of coding and testing.

How can technology help?

Use generative AI like ChatGPT to write all or most of the code. For more complex games, use ChatGPT to create an outline and game template. You will have to create the graphics but you can use generative AI like DALL-E for assistance. You also need more code to fill in the details, but you can prompt ChatGPT to write the code for you.

Prompt engineering

Start with simple ChatGPT prompts, then progressively add more features. Prompts such as the following were entered in order to create a game like the one in this repo.

python simple dungeon crawler with monsters and exit
python dungeon crawler monster with simple pathfinding
python role playing battle system
python role playing battle system with random monsters
python role playing battle system with skills
python role playing battle system with skills and difficulties

Video

Watch the video

Running the game

  1. Install Python 3.
  2. In command line, enter "python game.py".
  3. Play the game.

Example game

C:\projects\chatgpt-python-game>python game.py
P....
....E
.....
.....
....M
Move (n/s/e/w): s
.....
P...E
.....
...M.
.....
Move (n/s/e/w): e
.....
.P..E
..M..
.....
.....
Move (n/s/e/w): e
You have encountered a Orc
Player HP: 100
Orc HP: 80
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: double attack
Player used double attack and dealt 15 damage to Orc
Monster dealt 7 damage to player.
Player HP: 93
Orc HP: 65
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: slash
Player used slash and dealt 10 damage to Orc
Monster dealt 7 damage to player.
Player HP: 86
Orc HP: 55
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: stab
Player used stab and dealt 5 damage to Orc
Monster dealt 7 damage to player.
Player HP: 79
Orc HP: 50
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: slash
Player failed to use slash
Monster dealt 7 damage to player.
Player HP: 72
Orc HP: 50
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: stab
Player used stab and dealt 5 damage to Orc
Monster dealt 7 damage to player.
Player HP: 65
Orc HP: 45
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: double attack
Player used double attack and dealt 15 damage to Orc
Monster dealt 7 damage to player.
Player HP: 58
Orc HP: 30
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: slash
Player used slash and dealt 10 damage to Orc
Monster dealt 7 damage to player.
Player HP: 51
Orc HP: 20
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: slash
Player used slash and dealt 10 damage to Orc
Monster dealt 7 damage to player.
Player HP: 44
Orc HP: 10
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: slash
Player failed to use slash
Monster dealt 7 damage to player.
Player HP: 37
Orc HP: 10
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: stab
Player used stab and dealt 5 damage to Orc
Monster dealt 7 damage to player.
Player HP: 30
Orc HP: 5
Choose an action (attack/skill/run): skill
Available skills:
slash ( 15 damage, difficulty 0.8 )
stab ( 10 damage, difficulty 0.9 )
double attack ( 20 damage, difficulty 0.6 )
Choose a skill: stab
Player used stab and dealt 5 damage to Orc
Monster dealt 7 damage to player.
Monster was defeated.
.....
..P.E
.....
.....
..M..
Move (n/s/e/w): e
.....
...PE
.....
...M.
.....
Move (n/s/e/w): e
You win!

License

This project is licensed under the Apache 2 License - see the LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages