An open API service indexing awesome lists of open source software.

https://github.com/tanner-tyra/unfair-hangman


https://github.com/tanner-tyra/unfair-hangman

chatgpt-api flask html python

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Unfair Hangman

A playful twist on the classic Hangman game — featuring **AI-generated words**, a **web interface**, and a **desktop wrapper**.

## Description

Unfair Hangman takes the traditional Hangman experience and adds a few surprises:

- Words are **randomly generated in multiple languages** (English, Spanish, Latin, Old Norse, Hawaiian, and more).
- Accents and special characters are removed so anyone can play with a standard keyboard format.
- Wrong guesses may **reset your progress**, keeping the game interesting.
- A **clever AI** responds to incorrect guesses with witty messages.
- Is the game **actually over** if you lose?
- Play it in a **browser** or through a **desktop window** thanks to Tkinter + PyWebView.

## Features

- **AI-generated words** in dozens of languages
- **Accent stripping and normalization** for challenging gameplay
- **Witty AI responses** for wrong guesses
- **Web-based interface** built with Flask
- **Desktop wrapper** using Tkinter + PyWebView
- **Dynamic hangman drawing** that updates as you play

## Tech Stack

- **Python 3.11+**
- **Flask** – Web server and API
- **OpenAI GPT API** – Word generation and witty feedback
- **Tkinter + PyWebView** – Desktop app wrapper
- **HTML/CSS/JavaScript** – Frontend

## How It Works

1. **Word Generation:**
- On server start, a random word is selected in a random language via OpenAI GPT.
- Accents and special characters are removed for a clean gameplay experience.

2. **Gameplay Logic:**
- Players guess one letter at a time.
- Correct guesses reveal letters; incorrect guesses:
- Reduce attempts left
- Reset current guesses (optional, part of the game’s charm)
- Trigger a **playful AI response**
- The game lets you continue guessing even after attempts run out, so the experience stays engaging.

3. **Desktop Launch:**
- Tkinter + PyWebView opens a window pointing to the Flask web server.
- The desktop version behaves like the browser version, offering a smooth standalone experience.

4. **Game End:**
- **Win:** All letters are guessed
- **Lose:** Attempts run out, but the game still lets you try — keeping it fun and unpredictable.

## Installation

1. Clone the repository:
```bash
git clone https://github.com/yourusername/unfair-hangman.git
cd unfair-hangman
2. Install dependencies:
```
pip install flask openai pywebview
3. Set your OpenAI API key in main.py
```
openai.api_key = "your_api_key_here"
4. Run the game