Klotski Puzzle Game ๐Ÿงฉ

License: MIT Website Play Online

A modern, responsive implementation of the classic Klotski sliding block puzzle game. Play the timeless Chinese puzzle online with multiple configurations, save/load functionality, and beautiful animations.

๐ŸŒŸ Live Demo

Play the game online: Klotski

Experience the classic Klotski puzzle with modern web technology. No downloads required - play directly in your browser!

image

๐Ÿ“– About Klotski

Klotski (ๅŽๅฎน้“, Huฤ Rรณng Dร o) is a classic sliding block puzzle that originated in ancient China. The name translates to "Huarong Pass" and refers to a famous historical event from the Three Kingdoms period. The objective is to move the large red block (typically 2x2) from its starting position to the designated exit area.

Historical Significance

  • Origin: Ancient Chinese puzzle with hundreds of years of history
  • Cultural Heritage: Part of traditional Chinese intellectual games
  • Mathematical Interest: Studied extensively by mathematicians and computer scientists
  • Educational Value: Improves spatial reasoning and logical thinking

โœจ Features

๐ŸŽฎ Game Features

  • Multiple Configurations: 4 different starting layouts with varying difficulty
  • Save/Load Progress: Local storage for game state persistence
  • Move Counter: Track your progress and optimize solutions
  • Responsive Design: Play on desktop, tablet, or mobile devices
  • Keyboard Controls: Arrow keys and shortcuts for efficient gameplay
  • Visual Feedback: Clear indicators for selected blocks and valid moves

๐ŸŽฏ Technical Features

  • Modern Web Technologies: Pure HTML5, CSS3, and JavaScript
  • Touch Support: Optimized for mobile and tablet devices
  • Cross-Browser Compatible: Works on all modern browsers
  • No Dependencies: Lightweight and fast loading
  • SEO Optimized: Rich content and proper meta tags
  • Accessibility: Keyboard navigation and screen reader support

๐Ÿ“ฑ Mobile Optimized

  • Touch Controls: Drag and drop interface for mobile devices
  • Responsive Layout: Adapts to any screen size
  • Performance Optimized: Smooth animations on mobile devices
  • Offline Capable: Works without internet connection

๐Ÿš€ Quick Start

Play Online (Recommended)

Visit https://klotski.org to play the game directly in your browser.

Local Development

  1. Clone the repository

    git clone https://github.com/yourusername/klotski-game.git
    cd klotski-game
  2. Open in browser

    # Using Python 3
    python -m http.server 8000
    
    # Using Node.js
    npx serve .
    
    # Or simply open index.html in your browser
  3. Start playing Navigate to http://localhost:8000 in your browser

๐ŸŽฎ How to Play

Objective

Move the large red 2x2 block to the exit at the bottom of the board.

Controls

  • Mouse/Touch: Drag blocks directly to move them
  • Arrow Keys: Use arrow keys to move selected blocks
  • Direction Buttons: Click the arrow buttons on screen
  • Keyboard Shortcuts:
    • Ctrl+R: Reset game
    • Ctrl+S: Save game
    • Ctrl+O: Load game
    • Ctrl+1 to Ctrl+4: Switch configurations

Game Rules

  • All blocks can only move horizontally or vertically
  • Blocks cannot be lifted or rotated
  • The goal is to create a path for the main block to reach the exit
  • Some configurations require 100+ moves for optimal solutions

๐Ÿ—๏ธ Project Structure

klotski-game/
โ”œโ”€โ”€ index.html          # Main game page
โ”œโ”€โ”€ game.js             # Game logic and mechanics
โ”œโ”€โ”€ contact.html        # Contact page
โ”œโ”€โ”€ about.html          # About us page
โ”œโ”€โ”€ privacy.html        # Privacy policy
โ”œโ”€โ”€ terms.html          # Terms of service
โ”œโ”€โ”€ README.md           # This file
โ””โ”€โ”€ README_HTML.md      # HTML documentation

๐ŸŽฏ Game Configurations

The game includes 4 classic Klotski configurations:

  1. Configuration 1: Classic "ๆจชๅˆ€็ซ‹้ฉฌ" (Heng Dao Li Ma) - Moderate difficulty
  2. Configuration 2: "ๅฐ†ๆ‹ฅๆ›น่ฅ" (General Guarding Cao's Camp) - Advanced
  3. Configuration 3: "ๅ…ตๅˆ†ไธ‰่ทฏ" (Troops Divided in Three Ways) - Expert
  4. Configuration 4: "ๅฑ‚ๅฑ‚่ฎพ้˜ฒ" (Multiple Layers of Defense) - Master level

Each configuration offers unique challenges and requires different solving strategies.

๐Ÿ”ง Customization

Adding New Configurations

You can easily add new puzzle configurations by modifying the configurations array in game.js:

const configurations = [
    // Add your custom configuration here
    {
        name: "Custom Puzzle",
        board: [
            // Define your board layout
        ]
    }
];

Styling Customization

The game uses CSS custom properties for easy theming. Modify the CSS variables in index.html to change colors and styling.

๐Ÿ“Š Performance

  • Load Time: < 1 second on modern connections
  • Memory Usage: Minimal, optimized for mobile devices
  • Compatibility: Works on browsers from 2018 onwards
  • Accessibility: WCAG 2.1 AA compliant

๐ŸŒ Browser Support

Browser Version Status
Chrome 70+ โœ… Full Support
Firefox 65+ โœ… Full Support
Safari 12+ โœ… Full Support
Edge 79+ โœ… Full Support
Mobile Safari 12+ โœ… Full Support
Chrome Mobile 70+ โœ… Full Support

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

Ways to Contribute

  • ๐Ÿ› Report Bugs: Use the issue tracker
  • ๐Ÿ’ก Suggest Features: Share your ideas for new features
  • ๐Ÿ”ง Code Contributions: Submit pull requests for improvements
  • ๐Ÿ“ Documentation: Help improve documentation and tutorials
  • ๐ŸŒ Translations: Add support for additional languages

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Code Style

  • Follow existing code style and conventions
  • Add comments for complex logic
  • Test on multiple browsers and devices
  • Ensure mobile responsiveness

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Historical Research: Based on traditional Chinese Klotski puzzles
  • Mathematical Analysis: Inspired by academic research on sliding block puzzles
  • Community: Thanks to all contributors and puzzle enthusiasts
  • Open Source: Built with open web standards and technologies

๐Ÿ“ž Contact & Support

๐ŸŒŸ Star History

Star History Chart

๐Ÿ“ˆ Project Stats

GitHub stars GitHub forks GitHub issues GitHub pull requests


Made with โค๏ธ for puzzle enthusiasts worldwide

Experience the timeless challenge of Klotski - where strategy meets tradition in a modern web interface.

Play Now: Klotski | Learn More: About Klotski | Contact: Get in Touch

More Games: 15 Puzzleใ€Mahjong Link