Skip to content

Kheemwel/ai-rps-duel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AI Rock-Paper-Scissors Duel ๐Ÿค–โš”๏ธ

I made this fun little project to test out Groq and learn how to use AI function calling in a real app. It's basically Rock-Paper-Scissors but with a twist: the moves actually do things like dealing damage or healing, and you're fighting a pretty smart AI! ๐Ÿ–๏ธ๐Ÿ”ฅ

Features ๐ŸŒŸ๐ŸŒˆ

  • โญ Smart AI: Powered by Groq, the AI actually thinks about its moves based on the game state.
  • ๐Ÿ”ฅ Combat System: Moves aren't just for winning roundsโ€”Rock blocks damage, Paper heals you, and Scissors deals heavy damage!
  • ๐Ÿง  AI Reasoning: You can see exactly why the AI made its choice after every turn.
  • ๐Ÿ“œ Battle History: Automatically saves your games so you can look back at your epic wins (or sad losses).
  • ๐Ÿš€ Exportable Logs: Download your battle history as a clean Text file or a JSON file.
  • ๐ŸŽจ Beautiful UI: Built with DaisyUI for a clean, modern look with dark mode support.

Tech Stack ๐Ÿ’ป๐Ÿ› ๏ธ

  • Svelte 5: Using the new Runes system for super smooth state management.
  • SvelteKit: The framework keeping everything snappy.
  • Groq SDK: The "brain" behind the AI opponent.
  • Tailwind CSS & DaisyUI: For the pretty colors and layout.
  • TypeScript: To keep the code clean and bug-free.

Project Structure ๐Ÿ“‚๐Ÿ—๏ธ

  • src/lib/game.svelte.ts: This is where all the game logic and rules live.
  • src/routes/game: The main screen where you actually battle the AI.
  • src/routes/history: A list of all your past matches.
  • src/routes/api/ai: The secret sauce that talks to Groq.
  • static/: All the icons and images used in the game.

Gameplay ๐ŸŽฎ๐Ÿ•น๏ธ

It's easy to play, but hard to master! Both you and the AI start with 10 HP.

  • Rock ๐Ÿชจ: Blocks any incoming damage for that turn.
  • Paper ๐Ÿ“„: Heals you for 1 HP, but be carefulโ€”if the opponent plays Scissors, you take damage instead!
  • Scissors โœ‚๏ธ: Deals 2 damage to your opponent.
  • Goal: Bring the AI's HP down to 0 before it does the same to you!

How to Install ๐Ÿš€๐Ÿ› ๏ธ

  1. Clone the project: Grab the code from GitHub.
  2. Install dependencies: Run npm install in your terminal.
  3. Set up your API Key: Create a file named .env in the root folder and add your Groq key like this:
    GROQ_API_KEY=your_key_here
  4. Start the game: Run npm run dev and open the link in your browser!

Have fun battling the AI! ๐Ÿ˜Šโœจ

About

I made this fun little project to test out Groq and learn how to use AI function calling in a real app. It's basically Rock-Paper-Scissors but with a twist: the moves actually do things like dealing damage or healing, and you're fighting a pretty smart AI! ๐Ÿ–๏ธ๐Ÿ”ฅ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors