A Java application that uses Genetic Algorithm to evolve and find a randomly generated 32-bit binary passcode. This is an educational AI project demonstrating core concepts of evolutionary algorithms through an interactive JavaFX GUI.
Warning
JavaFX Requirement Warning: This project is built using JavaFX (SDK Version 22 / 24). Because JavaFX is no longer bundled with the standard JDK, you must have JavaFX installed on your machine and properly configured in your IDE (or via Maven/VM Arguments) to compile and run the application successfully.
This project implements a Genetic Algorithm that simulates the process of evolution to solve the problem of breaking a randomly generated password. Instead of brute-forcing all possible combinations, the algorithm evolves a population of candidate solutions over multiple generations, using selection, crossover, and mutation operations to progressively improve fitness.
Given a randomly generated 32-bit binary passcode, the genetic algorithm attempts to find the exact passcode by:
- Starting with a random population of candidate solutions
- Evaluating fitness (how many bits match the target)
- Selecting the best candidates to reproduce
- Creating offspring through crossover and mutation
- Repeating until the target is found
Splash Screen
Simulation Window (Before Running)
Algorithm Running — Fitness Convergence
Success Report
- Interactive GUI - Built with JavaFX with a sleek terminal-inspired design
- Real-time Visualization - Watch the algorithm evolve across generations
- Configurable Parameters - Adjust population size and mutation rate
- Performance Statistics - Track convergence data and best fitness scores
- Generation Tracking - Monitor progress generation-by-generation
- Elegant UI Design - Green-on-black terminal aesthetic with smooth animations
AI-Project1/
├── src/main/java/com/example/aiproject1/
│ ├── Main.java # Launch screen with UI styling
│ ├── GeneticAlgorithmApp.java # Main application controller
│ ├── GeneticAlgorithm.java # Core GA implementation
│ ├── Chromosome.java # Individual solution representation
│ └── StatisticsWindow.java # Performance tracking window
├── src/main/resources/ # UI assets (background images)
├── pom.xml # Maven configuration
├── convergence_data.csv # Algorithm performance data
└── report.pdf # Detailed project report
- Java 22 or higher
- Maven 3.9+
- JavaFX SDK 22
git clone https://github.com/WasFia3/Breaking-a-Password-Using-Genetic-Algorithm.git
cd Breaking-a-Password-Using-Genetic-Algorithm/AI-Project1Using Maven:
mvn clean installmvn javafx:runOr compile and run directly:
mvn clean compile
mvn javafx:run- Population - A collection of candidate solutions (chromosomes)
- Chromosome - A 32-bit binary string representing a candidate passcode
- Fitness - Number of bits that match the target passcode (0-32)
- Selection - Tournament selection: randomly pick 5 individuals, select the best
- Crossover - Combine two parent chromosomes at a random midpoint
- Mutation - Randomly flip bits with a given probability
1. Generate random target passcode (32 bits)
2. Initialize random population
3. For each generation (max 200):
a. Calculate fitness for each individual
b. If any individual has fitness = 32 → SUCCESS!
c. Create next generation via:
- Tournament selection
- Crossover
- Mutation
4. Output results and statistics
- Population Size - Number of candidate solutions (default: 100+)
- Mutation Rate - Probability of flipping each bit (default: 0.01)
- Generation Limit - Maximum generations to evolve (default: 200)
Represents a single candidate solution:
genes- 32-bit binary arrayfitness- Fitness scorecalculateFitness()- Compare with targetmutate()- Flip bits randomlycrossover()- Combine with another chromosome
Implements the core GA logic:
run()- Main algorithm loopevolve()- Create next generationtournamentSelection()- Select fit individualsgetBestFitness()- Get best score this generation
GUI application controller:
- Sets up the simulation interface
- Manages user interactions
- Displays real-time results
- Handles statistics window
Splash screen and application launcher:
- Beautiful animated buttons
- Glow effects on hover
- Launch into main application
The algorithm tracks:
- Generation Count - Current evolution step
- Best Fitness - Highest match score in population
- Convergence Data - Saved to
convergence_data.csv - Success Rate - Whether target was found within limit
Typical results show convergence within 50-100 generations depending on parameters.
This project demonstrates:
- Core concepts of genetic algorithms
- How natural selection drives evolution
- Balance between exploration and exploitation
- Java object-oriented design
- JavaFX GUI development
- Maven project management
Perfect for learning about:
- Evolutionary computation
- AI and optimization algorithms
- Java and GUI frameworks
- Algorithm visualization
The application logs convergence data to track:
- How quickly the population evolves
- Fitness progression per generation
- Parameter impact on convergence speed
Check convergence_data.csv and report.pdf for detailed analysis.
- Language - Java 22
- GUI Framework - JavaFX 22
- Build Tool - Maven 3.11.0
- IDE Compatible - IntelliJ IDEA, Eclipse, VS Code
- Check this YouTube video to understand the concept before implementing (https://www.youtube.com/watch?v=-kpcAa-qKwY&t=51s)
- See
report.pdffor detailed implementation notes - Check
convergence_data.csvfor algorithm performance data




