Skip to content

Releases: JF3800/Human-Vs-Computer-Geussing-Duel

Human Vs Computer: Geussing Duel

Choose a tag to compare

@JF3800 JF3800 released this 27 Jun 15:03

Mind vs Machine: The Guessing Duel

A number guessing game where you go head to head against a computer. You both guess each other's numbers, and whoever does it in fewer tries wins. Sounds simple until you realize the computer uses binary search and will beat you most of the time.


How It Works

You and the computer each pick a secret number. Then you take turns guessing each other's number. The game tells you if each guess is too high or too low.

The computer doesn't guess randomly. It always picks the midpoint of whatever range is still possible, cutting the options in half every single guess. You can watch it happen in real time.

Fewest guesses wins. Ties are possible but beating it is hard.


Getting Started

Requirements: Python 3.x

Install dependencies:

pip install rich

Run the game:

python Game.py

Or just download the binary for your OS from the releases page and run it directly. No Python needed.


Example

Welcome To My Number Geussing Game
What Number do you choose (for the computer to geuss)? 33

Geuss the number: 50
Too Low
Geuss the number: 75
Too High
Geuss the number: 62
Too High
Geuss the number: 56
Too Low
Geuss the number: 60
CORRECT :) | You took 5 tries

Now its computers turn
The Computer Geusses: 50
The Computer Geusses: 25
The Computer Geusses: 37
The Computer Geusses: 31
The Computer Geusses: 34
The Computer Geusses: 32
The Computer Geusses: 33
Computer got it! in 7 tries

YOU WON!!!!

Why the Computer Is Hard to Beat

Binary search is one of the most efficient algorithms out there. For a range of 1 to 100, it finds any number in at most 7 guesses every time. No luck involved, just math.


Built With

  • Python 3
  • rich for terminal colors and formatting
  • random for generating the computer's number