This project is a web-based game application built with Python (Flask) and JavaScript. It features an interactive game based on a mathematical formula and a comprehensive data analysis dashboard to run simulations and visualize the results.
- Interactive Gameplay: Play the game step-by-step or let it run to completion automatically.
- Custom Start Number: Users can input their own starting number or use the default value.
- Real-time Visualization: A line chart (using Chart.js) dynamically plots the number's value at each step on a logarithmic scale.
- Game History: The right-hand panel displays a ranked history of the top 20 successful game results (fewest steps to win) and any failed games. This data persists in the browser's local storage.
- Clear History: A button is available to clear all historical data.
- Bulk Simulations: Run 100 or 1000 games at once with a single click.
- Custom Simulation Parameters: Specify a custom initial number for the bulk runs.
- Statistical Summary: A detailed table shows key metrics from the simulation results, including:
- Total games played
- Win/Loss rates
- Average, minimum, and maximum steps for winning games
- Variance of win steps
- Data Visualization:
- Histogram: Shows the distribution of the number of steps required for a win.
- Pie Chart: Visualizes the overall win vs. loss ratio.
- Persistent Data: All simulation data is stored in the browser's local storage, allowing you to accumulate results over multiple sessions.
.
├── app.py # The Flask backend server that handles game logic and serves pages.
├── index.html # The main game interface.
├── analysis.html # The data analysis and visualization dashboard.
├── requirements.txt # A list of Python dependencies required for the project.
└── start.sh # An automated script to set up and run the application on macOS/Linux.
This project is designed to be easy to run. The start.sh script automates the entire process.
- Python 3 installed on your system.
- A command-line interface (Terminal on macOS/Linux).
- Unzip the
CASIO_Game.zipfile. - Open your terminal and navigate into the unzipped project folder.
cd path/to/CASIO_Game - Run the startup script.
This script will automatically:
./start.sh
- Create a Python virtual environment (
venv). - Install all the required dependencies from
requirements.txt. - Start the Flask web server.
- Open the game in your default web browser at
http://127.0.0.1:8080.
- Create a Python virtual environment (
To stop the server, simply close the terminal window.
If you are on Windows or prefer to run the project manually, follow these steps:
-
Open your terminal or Command Prompt and navigate to the project folder.
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\\Scripts\\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the dependencies:
pip install -r requirements.txt
-
Run the application:
python app.py
-
Open your web browser and go to the following URL: http://127.0.0.1:8080