Skip to content

riplatt/Jigsaw-Genius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Eternity II Jigsaw Genius

React Vite TailwindCSS License: MIT

A sophisticated web application for solving the infamous Eternity II puzzle using a non-backtracking statistical solver with machine learning optimization. The app employs intelligent piece placement strategies and real-time performance analysis to tackle this notoriously difficult 16ร—16 edge-matching puzzle.

โœจ Features

  • ๐Ÿงฉ Advanced Solving Algorithm: Non-backtracking statistical solver with weighted machine learning
  • ๐Ÿ“Š Real-time Analytics: Live performance tracking with detailed statistics
  • ๐ŸŽฏ Machine Learning Optimization: Adaptive piece selection based on historical performance
  • ๐Ÿ’พ State Persistence: Automatic saving and loading of solver progress
  • ๐Ÿ“ˆ CSV Import/Export: Backup and restore solver data with detailed statistics
  • ๐ŸŽจ Interactive Visualization: Animated 16ร—16 puzzle board with color-coded edges
  • โš™๏ธ Configurable Parameters: Adjustable learning rates and calibration settings
  • ๐Ÿ“ฑ Responsive Design: Works seamlessly on desktop and mobile devices

๐Ÿ–ผ๏ธ Screenshots

[Add screenshots of the application interface here]

๐Ÿ—๏ธ Tech Stack

  • Frontend: React 18 + Vite
  • Styling: Tailwind CSS + Custom UI Components
  • Animation: Framer Motion
  • UI Components: Radix UI (shadcn/ui pattern)
  • State Management: React Context API + localStorage
  • Icons: Lucide React
  • Build Tool: Vite with hot module replacement

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 16.x or higher
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone https://github.com/riplatt/Jigsaw-Genius.git
    cd e2-jigsaw-genius
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Start the development server

    npm run dev
    # or
    yarn dev
  4. Open your browser Navigate to http://localhost:5173 to view the application.

Building for Production

npm run build
npm run preview

๐ŸŽฎ Usage

Basic Operation

  1. Start Solving: Click the "Start" button to begin the solving process
  2. Monitor Progress: Watch the real-time board updates and statistics
  3. Pause/Resume: Use the "Pause" button to stop and resume solving
  4. Reset: Clear all progress and start fresh with the "Reset" button

Machine Learning Controls

  • Placement Strategy: Choose between Original Strategy or Optimized Strategy (25% faster with Diagonal Restriction)
  • Learning Rate (k): Adjust how aggressively the solver favors high-scoring pieces (0.01-1.0)
  • Calibration Mode: Enable/disable the 1000-run calibration period
  • Performance Tracking: Monitor total runs, best scores, and completion rates

Data Management

  • CSV Export: Download comprehensive solver data including piece statistics
  • CSV Import: Restore previous solving sessions and continue training
  • Automatic Persistence: All progress is automatically saved to browser storage

๐Ÿง  Algorithm Details

Solving Strategy

The solver uses a non-backtracking statistical approach with the following key components:

  1. Configurable Placement Strategies: Choose between placement algorithms:
    • Original Strategy: Standard placement order
    • Optimized Strategy: 25% faster using Diagonal Restriction (Hints โ†’ Orthogonal-Adjacent โ†’ Diagonal Restriction โ†’ Checkerboard โ†’ Surrounded)
  2. Edge Validation: Ensures pieces fit by matching edge colors and border constraints
  3. Machine Learning Weighting: Uses exponential weighting based on historical performance

Machine Learning Implementation

// Weight calculation for piece selection
weight = exp(k * (localAvgScore - globalAvgScore))
  • Calibration Phase: First 1000 runs establish baseline performance
  • Adaptive Selection: Pieces with better historical performance get higher selection probability
  • Continuous Learning: Statistics update after each solving attempt

Puzzle Constraints

  • Board Size: 16ร—16 (256 total pieces)
  • Fixed Hints: 5 pre-placed pieces at specific positions
  • Edge Colors: 23 different edge colors (0-22, where 0 = border)
  • Rotations: Each piece can be rotated in 90ยฐ increments

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ puzzle/
โ”‚   โ”‚   โ”œโ”€โ”€ SolverContext.jsx     # Main solver logic and state
โ”‚   โ”‚   โ”œโ”€โ”€ PuzzleBoard.jsx       # Visual board component
โ”‚   โ”‚   โ”œโ”€โ”€ SolverControls.jsx    # Control panel
โ”‚   โ”‚   โ””โ”€โ”€ HintAnalysis.jsx      # ML performance analysis
โ”‚   โ”œโ”€โ”€ ui/                       # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ button.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ slider.jsx
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ Layout.jsx                # Main application layout
โ”œโ”€โ”€ pages/
โ”‚   โ””โ”€โ”€ Solver.jsx                # Main solver page
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ solver.js                 # Configuration constants
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ index.js                  # Utility functions
โ””โ”€โ”€ main.jsx                      # Application entry point

โš™๏ธ Configuration

Solver Parameters

Located in src/config/solver.js:

export const SOLVER_CONFIG = {
  BOARD_SIZE: 16,
  TOTAL_PIECES: 256,
  CALIBRATION_RUNS: 1000,
  SOLVER_INTERVAL: 333, // milliseconds
  // ... other configuration options
};

Customizable Settings

  • Solving Speed: Adjust SOLVER_INTERVAL for faster/slower solving
  • Calibration Period: Modify CALIBRATION_RUNS for different training lengths
  • Animation Settings: Configure duration and delays for visual effects

๐Ÿ“„ CSV Data Format

Export Format

The CSV export includes the following data:

Column Description
HintPosition Position of the hint piece
Direction Adjacent direction (north, east, south, west)
PieceId ID of the puzzle piece
Rotation Rotation angle (0, 90, 180, 270)
AvgScore Average score for this piece/rotation
Count Number of times this combination was used
BestScore Best score achieved with this combination
SelectionPercentage ML-calculated selection probability

Metadata Section

Additional solver state information:

  • Total runs, best score, average score
  • Completed solutions count
  • Current run information
  • ML parameters (weighting constant, calibration setting, placement strategy)

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and commit them: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Submit a pull request

Development Guidelines

  • Follow React best practices and hooks patterns
  • Use TypeScript for new components (optional)
  • Maintain Tailwind CSS class organization
  • Add comments for complex algorithm logic
  • Test your changes thoroughly

Code Style

  • Use ES6+ features and functional components
  • Follow the existing code structure and naming conventions
  • Keep components focused and maintainable
  • Use React.memo for performance optimization where appropriate

๐Ÿ› Known Issues

  • Large datasets (>10,000 runs) may impact browser performance
  • CSV import requires exact format matching
  • Mobile performance may be limited for extended solving sessions

๐Ÿ”ฎ Future Enhancements

  • Web Workers for parallel solving
  • Advanced ML algorithms (neural networks)
  • Pattern recognition for common configurations
  • Backtracking option for dead-end recovery
  • Multiple solving strategy comparison
  • 3D visualization mode
  • Tournament mode for strategy comparison

๐Ÿ“ˆ Performance Tips

  1. Regular Exports: Save your progress frequently using CSV export
  2. Browser Resources: Close other tabs for better performance during long runs
  3. Learning Rate: Start with lower values (0.1-0.3) for more stable learning
  4. Calibration: Allow the full 1000-run calibration for optimal ML performance

๐Ÿ™ Acknowledgments

  • Eternity II Puzzle creators for the original challenge
  • React and Vite teams for excellent development tools
  • Tailwind CSS for the utility-first styling approach
  • Radix UI for accessible component primitives

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“ž Contact


Made with โค๏ธ for puzzle enthusiasts and algorithm researchers

About

Web application for solving the infamous **Eternity II puzzle** using a non-backtracking statistical solver with machine learning optimization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors