Skip to content

Ahmad1765/Add3Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

# **Add3Game: The Cognitive Arithmetic Challenge** 🎯

---

## **Executive Overview**

Add3Game is a minimalist yet neurologically engaging brain-training application that transforms simple arithmetic into a captivating real-time cognitive workout. Unlike conventional number games, Add3Game leverages **modular arithmetic** and **digit-wise transformation** to challenge players' mental processing speed, pattern recognition, and working memory. The game presents a randomized 4-digit number and requires the user to instantly compute and input a transformed version where each digit is incremented by 3 (with wrap-around from 9 to 0). This seemingly simple rule creates a **non-linear mental mapping** that exercises neural pathways associated with number sense and rapid calculation.

Designed with elegance and accessibility in mind, Add3Game operates directly in the terminal with zero dependencies, making it universally runnable across platforms. Its potential extends beyond entertainment—it serves as a foundational tool for cognitive research, educational reinforcement, and even作为 a benchmark for testing human-computer interaction latency in simple reaction-time tasks.

---

## **Key Features**

- **⚡ Real-Time Cognitive Challenge**: Each round generates a fresh random 4-digit number, demanding immediate mental transformation.
- **🔄 Modular Arithmetic Engine**: Uses `(digit + 3) % 10` rule with seamless wrap-around, ensuring mathematically consistent transformations.
- **🎨 Clean Terminal UI with ANSI Color**: The random number is displayed in vivid red (`\033[91m`), enhancing visual focus without complexity.
- **⏱️ Controlled Pace**: 1-second pause between rounds maintains flow while preventing cognitive overload.
- **🛠️ Zero-Dependency Architecture**: Pure Python standard library—no external packages required.
- **🔁 Infinite Play Loop**: Continuous generation provides endless practice sessions.
- **📊 Instant Feedback**: Clear success/failure messaging with answer reveal on incorrect attempts.
- **🌍 Cross-Platform Compatibility**: Runs on any system with Python 3.x and a terminal.

---

## **Target Users & Value Proposition**

### **Primary Users**
- **Students & Educators**: Reinforces modular arithmetic and mental calculation skills in an engaging format.
- **Cognitive Training Enthusiasts**: Like Lumena or Peak users seeking simple, effective brain games.
- **Developers & Researchers**: As a minimal testbed for studying reaction times, pattern recognition, or as a component in larger psychometric experiments.
- **Casual Gamers**: Quick, no-installation puzzle for short breaks.

### **Value Delivered**
- **🧠 Cognitive Enhancement**: Regular play improves mental agility, number sense, and working memory capacity.
- **⏱️ Time-Efficient Training**: Each round takes ~3 seconds—perfect for micro-learning sessions.
- **📈 Progress Tracking Potential**: The game's simplicity makes it easy to log and analyze performance metrics (accuracy, response time) in future versions.
- **🆓 Completely Free & Open**: No ads, no subscriptions, no barriers.

---

## **Technical Architecture**

### **System Design**
Add3Game follows a **procedural paradigm** with a clear linear flow:

1. **Number Generation**: `random.randint(1000, 9999)` produces a 4-digit integer.
2. **Digit Transformation**: Core logic in `adjust_digit()` and `adjust_number()` applies modular addition.
3. **Input Handling**: Synchronous `input()` call blocks until user enters a 4-digit integer.
4. **Validation**: `check_input()` compares transformed target against user input.
5. **Feedback Loop**: Immediate console output followed by `time.sleep(1)`.

### **Code Structure**

Add3Game.py ├── generate_random_number() → int ├── get_user_input() → int ├── adjust_digit(value) → int (modular +3) ├── adjust_number(original) → int (digit-wise transformation) ├── check_input(original, user_input) → bool └── main() → void (infinite game loop)


### **Dependencies**
- Python Standard Library Only:
  - `random` – for number generation
  - `time` – for pacing
  - Built-in `input()`/`print()` – for I/O

### **Design Patterns**
- **Single Responsibility**: Each function handles one discrete operation.
- **Pure Functions**: `adjust_digit()` and `adjust_number()` are deterministic and side-effect-free, enabling easy testing.
- **Infinite Loop with Exit Condition**: Currently runs indefinitely; could be extended with a maximum round limit or grace period.

---

## **Installation & Usage Guide**

### **Prerequisites**
- Python 3.6 or higher installed.

### **Installation**
1. Clone or download the repository:
   ```bash
   git clone https://github.com/yourusername/Add3Game.git
   cd Add3Game
  1. No installation required—just run the script.

Running the Game

python Add3Game.py

Gameplay

  1. A red 4-digit number appears (e.g., 4821).
  2. Compute the transformed number: add 3 to each digit, wrapping at 9.
    • Example: 4821(4+3)%10=7, (8+3)%10=1, (2+3)%10=5, (1+3)%10=47154
  3. Enter your 4-digit answer and press Enter.
  4. Receive immediate feedback.
  5. After 1 second, a new number appears.

Note: Press Ctrl+C to exit.


Usage Examples

Example Round

\033[91m4821\033[0m
Enter a 4-digit number with each digit increased by 3333: 7154
Congratulations! Your input is correct.

Incorrect Answer Example

\033[91m7390\033[0m
Enter a 4-digit number with each digit increased by 3333: 1234
Sorry, your input is not correct.
The adjusted number is: 0623

Note: Leading zeros are preserved in logic but cast to integer (e.g., 0623623).

Batch Play Ideas

  • Speed Rounds: Track how many correct answers in 60 seconds.
  • Accuracy Challenge: Play until first mistake; aim for 50+ correct.
  • Memory Extension: Remember the original number while computing the transformation.

Future Potential & Roadmap

Short-Term (v1.1)

  • Configurable Increment: Allow users to set the addition value (default 3).
  • Round Counter: Track and display total rounds played.
  • High Score System: Persist best streak/accuracy to a local file.
  • Error Handling: Validate input is 4-digit; reprompt on invalid entry.

Mid-Term (v2.0)

  • Difficulty Levels:
    • Easy: 3-digit numbers
    • Medium: 4-digit
    • Hard: 5-digit or variable increment per digit
  • Timed Mode: Countdown clock with points per correct answer.
  • Stats Dashboard: Track average response time, accuracy trends, and improvement over time.
  • Leaderboards: Local or networked comparison with other players.

Long-Term (v3.0+)

  • Web/API Version: Flask/FastAPI backend with frontend for browser play.
  • Mobile App: React Native wrapper for on-the-go training.
  • Scientific Integration: Export logs to CSV/JSON for psychometric analysis.
  • Multiplayer Mode: Real-time competition between players.
  • Accessibility Features: Audio output, high-contrast modes, haptic feedback.
  • AI Adaptation: Dynamically adjust difficulty based on performance using a simple Elo system.

Commercial Potential

  • B2B Cognitive Training: License to schools, rehabilitation centers, or corporate wellness programs.
  • Embedded Game: Integrate as a mini-game in larger mental fitness platforms.
  • Research Instrument: Provide validated data collection tools for neuroscience/psychology studies.

Contributing

We welcome contributions that enhance Add3Game's functionality, usability, or educational value. Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch:
    git checkout -b feature/AmazingFeature
  3. Follow coding style: Keep functions small, pure, and well-documented. Add docstrings.
  4. Test your changes: Ensure the game runs without errors and consider adding unit tests for core logic.
  5. Submit a Pull Request with a clear description of the change and its rationale.

Areas needing contribution:

  • Input validation improvements
  • Configurable game parameters (via CLI args or config file)
  • Unit tests for adjust_number() and check_input()
  • Documentation enhancements
  • Packaging for pip install

License

Distributed under the MIT License. See LICENSE for more information.

MIT License Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: [...]

About

Add3Game: Python CLI game where you adjust each digit of a random 4-digit number by adding 3 with modulo wrap-around.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages