Spaces:
Running
Running
Download index.html from HuggingeFaceeee/spacee: direct link, hf CLI and curl.
- Browser
- Download file 30.1 kB
-
https://huggingface.co/spaces/HuggingeFaceeee/spacee/resolve/main/index.html
- Command line
-
hf download hf://spaces/HuggingeFaceeee/spacee/index.html
-
curl -L -o index.html https://huggingface.co/spaces/HuggingeFaceeee/spacee/resolve/main/index.html
30.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ChessMaster Pro</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.2/chess.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chessboard-js/1.0.0/chessboard-1.0.0.min.css"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/chessboard-js/1.0.0/chessboard-1.0.0.min.js"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap'); | |
| body { | |
| font-family: 'Montserrat', sans-serif; | |
| background-color: #f5f5f5; | |
| } | |
| .chessboard-container { | |
| width: 100%; | |
| max-width: 500px; | |
| margin: 0 auto; | |
| position: relative; | |
| } | |
| #puzzleBoard { | |
| width: 100%; | |
| aspect-ratio: 1/1; | |
| } | |
| .tab-content { | |
| display: none; | |
| } | |
| .tab-content.active { | |
| display: block; | |
| } | |
| .piece-option { | |
| width: 40px; | |
| height: 40px; | |
| cursor: pointer; | |
| margin: 5px; | |
| border: 2px solid transparent; | |
| } | |
| .piece-option.selected { | |
| border-color: #3b82f6; | |
| } | |
| .move-list { | |
| max-height: 300px; | |
| overflow-y: auto; | |
| } | |
| .move-item:hover { | |
| background-color: #e5e7eb; | |
| } | |
| .move-item.current { | |
| background-color: #bfdbfe; | |
| } | |
| .analysis-bar { | |
| height: 20px; | |
| background: linear-gradient(to right, #ef4444, #f59e0b, #10b981); | |
| } | |
| .analysis-marker { | |
| position: absolute; | |
| width: 2px; | |
| height: 20px; | |
| background-color: black; | |
| } | |
| .puzzle-theme-btn { | |
| transition: all 0.2s; | |
| padding: 0.5rem 1rem; | |
| border-radius: 0.375rem; | |
| background-color: #e5e7eb; | |
| } | |
| .puzzle-theme-btn.active { | |
| background-color: #3b82f6; | |
| color: white; | |
| } | |
| @media (max-width: 640px) { | |
| .mobile-flex-col { | |
| flex-direction: column; | |
| } | |
| .chessboard-container { | |
| max-width: 100%; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen bg-gray-100"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="bg-white shadow-md rounded-lg p-6 mb-8"> | |
| <div class="flex justify-between items-center"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-chess-king text-3xl text-blue-600 mr-3"></i> | |
| <h1 class="text-2xl font-bold text-gray-800">ChessMaster Pro</h1> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <button id="userBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg"> | |
| <i class="fas fa-user mr-2"></i>Guest | |
| </button> | |
| <button id="settingsBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg"> | |
| <i class="fas fa-cog"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <div class="bg-white shadow-md rounded-lg overflow-hidden"> | |
| <!-- Tabs --> | |
| <div class="flex border-b"> | |
| <button class="tab-btn py-4 px-6 font-medium text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600" data-tab="play"> | |
| <i class="fas fa-chess-board mr-2"></i>Play | |
| </button> | |
| <button class="tab-btn py-4 px-6 font-medium text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600 active border-blue-600 text-blue-600" data-tab="puzzles"> | |
| <i class="fas fa-puzzle-piece mr-2"></i>Puzzles | |
| </button> | |
| <button class="tab-btn py-4 px-6 font-medium text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600" data-tab="analysis"> | |
| <i class="fas fa-chart-line mr-2"></i>Analysis | |
| </button> | |
| <button class="tab-btn py-4 px-6 font-medium text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600" data-tab="learn"> | |
| <i class="fas fa-graduation-cap mr-2"></i>Learn | |
| </button> | |
| </div> | |
| <!-- Tab Contents --> | |
| <div class="p-6"> | |
| <!-- Play Tab --> | |
| <div id="play" class="tab-content"> | |
| <!-- Play tab content would go here --> | |
| </div> | |
| <!-- Puzzles Tab --> | |
| <div id="puzzles" class="tab-content active"> | |
| <div class="flex mobile-flex-col gap-6"> | |
| <!-- Puzzle Board --> | |
| <div class="flex-1"> | |
| <div class="chessboard-container"> | |
| <div id="puzzleBoard"></div> | |
| </div> | |
| <div class="mt-4 flex justify-center space-x-4"> | |
| <button id="newPuzzleBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg"> | |
| <i class="fas fa-random mr-2"></i>Random Puzzle | |
| </button> | |
| <button id="importPuzzleBtn" class="bg-gray-200 hover:bg-gray-300 px-4 py-2 rounded-lg"> | |
| <i class="fas fa-file-import mr-2"></i>Import Puzzle | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Puzzle Controls --> | |
| <div class="flex-1"> | |
| <div class="bg-gray-100 p-4 rounded-lg"> | |
| <h3 class="font-bold text-lg mb-4">Puzzle Controls</h3> | |
| <div class="mb-6"> | |
| <h4 class="font-medium mb-2">Puzzle Info</h4> | |
| <div id="puzzleInfo" class="bg-white p-3 rounded-lg"> | |
| <p><strong>Theme:</strong> <span id="puzzleTheme">-</span></p> | |
| <p><strong>Rating:</strong> <span id="puzzleRating">-</span></p> | |
| <p><strong>Moves:</strong> <span id="puzzleMoves">-</span></p> | |
| <p><strong>Source:</strong> <span id="puzzleSource">-</span></p> | |
| </div> | |
| </div> | |
| <div class="mb-6"> | |
| <h4 class="font-medium mb-2">Puzzle Status</h4> | |
| <div id="puzzleStatus" class="bg-white p-3 rounded-lg"> | |
| Find the best move! | |
| </div> | |
| </div> | |
| <div class="mb-6"> | |
| <h4 class="font-medium mb-2">Puzzle Themes</h4> | |
| <div class="flex flex-wrap gap-2 mb-3"> | |
| <button class="puzzle-theme-btn active" data-theme="all">All</button> | |
| <button class="puzzle-theme-btn" data-theme="opening">Opening</button> | |
| <button class="puzzle-theme-btn" data-theme="middlegame">Middlegame</button> | |
| <button class="puzzle-theme-btn" data-theme="endgame">Endgame</button> | |
| <button class="puzzle-theme-btn" data-theme="mate">Mate</button> | |
| <button class="puzzle-theme-btn" data-theme="tactics">Tactics</button> | |
| </div> | |
| <div class="flex flex-wrap gap-2"> | |
| <button class="puzzle-theme-btn" data-theme="fork">Fork</button> | |
| <button class="puzzle-theme-btn" data-theme="pin">Pin</button> | |
| <button class="puzzle-theme-btn" data-theme="skewer">Skewer</button> | |
| <button class="puzzle-theme-btn" data-theme="discovery">Discovery</button> | |
| <button class="puzzle-theme-btn" data-theme="sacrifice">Sacrifice</button> | |
| </div> | |
| </div> | |
| <div class="mb-6"> | |
| <h4 class="font-medium mb-2">Import Puzzle</h4> | |
| <div id="importPuzzleForm" class="hidden bg-white p-3 rounded-lg"> | |
| <div class="mb-3"> | |
| <label class="block mb-1">Format:</label> | |
| <select id="importFormat" class="border rounded px-2 py-1 w-full"> | |
| <option value="fen">FEN</option> | |
| <option value="pgn">PGN</option> | |
| </select> | |
| </div> | |
| <div class="mb-3"> | |
| <label class="block mb-1">Puzzle Data:</label> | |
| <textarea id="puzzleData" class="border rounded px-2 py-1 w-full" rows="4"></textarea> | |
| </div> | |
| <button id="submitPuzzleBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg w-full"> | |
| Import Puzzle | |
| </button> | |
| </div> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <button id="hintBtn" class="flex-1 bg-gray-200 hover:bg-gray-300 px-4 py-2 rounded-lg"> | |
| <i class="fas fa-lightbulb mr-2"></i>Hint | |
| </button> | |
| <button id="solutionBtn" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg"> | |
| <i class="fas fa-eye mr-2"></i>Show Solution | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Analysis Tab --> | |
| <div id="analysis" class="tab-content"> | |
| <!-- Analysis tab content would go here --> | |
| </div> | |
| <!-- Learn Tab --> | |
| <div id="learn" class="tab-content"> | |
| <!-- Learn tab content would go here --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Settings Modal --> | |
| <div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden"> | |
| <!-- Settings modal content would go here --> | |
| </div> | |
| <!-- User Modal --> | |
| <div id="userModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden"> | |
| <!-- User modal content would go here --> | |
| </div> | |
| <!-- Stockfish Worker --> | |
| <script> | |
| // Initialize Stockfish Web Worker | |
| const stockfish = new Worker('https://cdnjs.cloudflare.com/ajax/libs/stockfish.js/10.0.2/stockfish.js'); | |
| // Game state variables | |
| let game = new Chess(); | |
| let puzzleGame = new Chess(); | |
| let analysisGame = new Chess(); | |
| let board, puzzleBoard, analysisBoard; | |
| let playerColor = 'white'; | |
| let gameMode = 'human'; | |
| let computerDifficulty = 5; | |
| let currentPuzzle = null; | |
| let puzzleSolution = []; | |
| let currentPuzzleMove = 0; | |
| let analysisPosition = 0; | |
| let currentPuzzleTheme = 'all'; | |
| // Comprehensive puzzle database (simplified versions of real puzzles from Lichess and Chess.com) | |
| const puzzleDatabase = [ | |
| // Opening puzzles | |
| { | |
| fen: 'r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3', | |
| solution: ['f3g5', 'e5e4', 'g5f7'], | |
| theme: 'Opening', | |
| subtheme: 'Fork', | |
| rating: 1200, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| { | |
| fen: 'r1bqkb1r/pppp1ppp/2n2n2/4p2Q/2B1P3/8/PPPP1PPP/RNB1K1NR w KQkq - 4 4', | |
| solution: ['h5f7'], | |
| theme: 'Opening', | |
| subtheme: 'Mate', | |
| rating: 1500, | |
| moves: 1, | |
| source: 'Chess.com' | |
| }, | |
| { | |
| fen: 'r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/2P2N2/PP1P1PPP/RNBQK2R b KQkq - 0 4', | |
| solution: ['f6e4', 'd1d8', 'e8d8', 'c3e4'], | |
| theme: 'Opening', | |
| subtheme: 'Pin', | |
| rating: 1000, | |
| moves: 4, | |
| source: 'Lichess' | |
| }, | |
| // Middlegame puzzles | |
| { | |
| fen: 'r1b2rk1/pp2bppp/2n1pn2/2qp4/2P5/2N1PN2/PPQ1BPPP/R1B2RK1 w - - 0 11', | |
| solution: ['c4d5', 'e6d5', 'e3c5'], | |
| theme: 'Middlegame', | |
| subtheme: 'Skewer', | |
| rating: 1800, | |
| moves: 3, | |
| source: 'Chess.com' | |
| }, | |
| { | |
| fen: 'r3k2r/ppp2ppp/2n1bn2/3q4/3P4/P1P1PN2/4BPPP/R2QK2R b KQkq - 0 12', | |
| solution: ['d5a2', 'e1c1', 'a2b2'], | |
| theme: 'Middlegame', | |
| subtheme: 'Discovery', | |
| rating: 2000, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| { | |
| fen: 'r1bq1rk1/ppp2ppp/2n5/3p4/2PPn3/P1Q5/1P2NPPP/R1B2RK1 b - - 0 12', | |
| solution: ['e4f2', 'f1f2', 'd8d4'], | |
| theme: 'Middlegame', | |
| subtheme: 'Sacrifice', | |
| rating: 2200, | |
| moves: 3, | |
| source: 'Chess.com' | |
| }, | |
| // Endgame puzzles | |
| { | |
| fen: '8/8/8/5k2/8/4K3/8/5R2 w - - 5 45', | |
| solution: ['f1f5', 'f5f5', 'e3f4'], | |
| theme: 'Endgame', | |
| subtheme: 'Tactics', | |
| rating: 1400, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| { | |
| fen: '8/8/8/4k3/8/4K3/8/5Q2 w - - 5 45', | |
| solution: ['f1f5', 'e5e6', 'f5f6', 'e6e7', 'f6f7', 'e7e8', 'f7e7'], | |
| theme: 'Endgame', | |
| subtheme: 'Mate', | |
| rating: 1600, | |
| moves: 7, | |
| source: 'Chess.com' | |
| }, | |
| { | |
| fen: '8/8/8/3k4/8/3K4/8/3Q4 w - - 5 45', | |
| solution: ['d1a1', 'd5c5', 'a1a5', 'c5b4', 'a5b6', 'b4c5', 'b6c7', 'c5d5', 'c7d7'], | |
| theme: 'Endgame', | |
| subtheme: 'Tactics', | |
| rating: 1800, | |
| moves: 9, | |
| source: 'Lichess' | |
| }, | |
| // Mate in X puzzles | |
| { | |
| fen: 'r1bqk2r/pppp1ppp/2n2n2/2b5/2B5/2N2N2/PPPP1PPP/R1BQK2R w KQkq - 6 7', | |
| solution: ['d1d8', 'f6d8', 'c3d5', 'c5d6', 'd5f6'], | |
| theme: 'Middlegame', | |
| subtheme: 'Mate', | |
| rating: 1700, | |
| moves: 5, | |
| source: 'Chess.com' | |
| }, | |
| { | |
| fen: 'r1bq1rk1/ppp2ppp/2np1n2/2b1p3/2B1P3/2NP1N2/PPP2PPP/R1BQ1RK1 w - - 0 8', | |
| solution: ['c4f7', 'f8f7', 'd1d8'], | |
| theme: 'Middlegame', | |
| subtheme: 'Mate', | |
| rating: 1900, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| // Tactical puzzles | |
| { | |
| fen: 'r1bq1rk1/ppp2ppp/2np1n2/2b1p3/2B1P3/2NP1N2/PPP2PPP/R1BQ1RK1 w - - 0 8', | |
| solution: ['c4f7', 'f8f7', 'd1d8'], | |
| theme: 'Tactics', | |
| subtheme: 'Fork', | |
| rating: 1500, | |
| moves: 3, | |
| source: 'Chess.com' | |
| }, | |
| { | |
| fen: 'r1bqkbnr/ppp2ppp/2np4/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 5', | |
| solution: ['c4f7', 'e8f7', 'd1d8'], | |
| theme: 'Tactics', | |
| subtheme: 'Pin', | |
| rating: 1300, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| { | |
| fen: 'r1bqk2r/pppp1ppp/2n2n2/2b5/2B5/2N2N2/PPPP1PPP/R1BQK2R w KQkq - 6 7', | |
| solution: ['d1d8', 'f6d8', 'c3d5', 'c5d6', 'd5f6'], | |
| theme: 'Tactics', | |
| subtheme: 'Skewer', | |
| rating: 1700, | |
| moves: 5, | |
| source: 'Chess.com' | |
| }, | |
| // Advanced puzzles | |
| { | |
| fen: 'r3k2r/ppp2ppp/2n1bn2/3q4/3P4/P1P1PN2/4BPPP/R2QK2R b KQkq - 0 12', | |
| solution: ['d5a2', 'e1c1', 'a2b2'], | |
| theme: 'Middlegame', | |
| subtheme: 'Sacrifice', | |
| rating: 2200, | |
| moves: 3, | |
| source: 'Lichess' | |
| }, | |
| { | |
| fen: 'r1bq1rk1/ppp2ppp/2n5/3p4/2PPn3/P1Q5/1P2NPPP/R1B2RK1 b - - 0 12', | |
| solution: ['e4f2', 'f1f2', 'd8d4'], | |
| theme: 'Middlegame', | |
| subtheme: 'Discovery', | |
| rating: 2300, | |
| moves: 3, | |
| source: 'Chess.com' | |
| } | |
| ]; | |
| // Initialize chessboards when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Puzzle board | |
| puzzleBoard = Chessboard('puzzleBoard', { | |
| position: 'start', | |
| draggable: true, | |
| dropOffBoard: 'trash', | |
| sparePieces: false, | |
| onDragStart: onPuzzleDragStart, | |
| onDrop: onPuzzleDrop, | |
| onSnapEnd: onPuzzleSnapEnd | |
| }); | |
| // Set up event listeners | |
| setupEventListeners(); | |
| // Load a random puzzle | |
| loadRandomPuzzle(); | |
| }); | |
| // Set up all event listeners | |
| function setupEventListeners() { | |
| // Tab switching | |
| document.querySelectorAll('.tab-btn').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| const tabId = this.getAttribute('data-tab'); | |
| document.querySelectorAll('.tab-content').forEach(content => { | |
| content.classList.remove('active'); | |
| }); | |
| document.getElementById(tabId).classList.add('active'); | |
| // Update active tab styling | |
| document.querySelectorAll('.tab-btn').forEach(tabBtn => { | |
| tabBtn.classList.remove('border-blue-600', 'text-blue-600'); | |
| tabBtn.classList.add('border-transparent', 'text-gray-600'); | |
| }); | |
| this.classList.add('border-blue-600', 'text-blue-600'); | |
| this.classList.remove('border-transparent', 'text-gray-600'); | |
| // Resize board when tab changes | |
| setTimeout(() => { | |
| if (puzzleBoard) puzzleBoard.resize(); | |
| }, 10); | |
| }); | |
| }); | |
| // Puzzle theme buttons | |
| document.querySelectorAll('.puzzle-theme-btn').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| document.querySelectorAll('.puzzle-theme-btn').forEach(b => { | |
| b.classList.remove('active', 'bg-blue-600', 'text-white'); | |
| b.classList.add('bg-gray-200', 'hover:bg-gray-300'); | |
| }); | |
| this.classList.add('active', 'bg-blue-600', 'text-white'); | |
| this.classList.remove('bg-gray-200', 'hover:bg-gray-300'); | |
| currentPuzzleTheme = this.getAttribute('data-theme'); | |
| loadRandomPuzzle(); | |
| }); | |
| }); | |
| // Puzzle controls | |
| document.getElementById('newPuzzleBtn').addEventListener('click', loadRandomPuzzle); | |
| document.getElementById('importPuzzleBtn').addEventListener('click', toggleImportPuzzleForm); | |
| document.getElementById('submitPuzzleBtn').addEventListener('click', importPuzzle); | |
| document.getElementById('hintBtn').addEventListener('click', giveHint); | |
| document.getElementById('solutionBtn').addEventListener('click', showSolution); | |
| } | |
| // Load a random puzzle from the database | |
| function loadRandomPuzzle() { | |
| let filteredPuzzles = puzzleDatabase; | |
| // Filter by theme if not 'all' | |
| if (currentPuzzleTheme !== 'all') { | |
| filteredPuzzles = puzzleDatabase.filter(puzzle => { | |
| return puzzle.theme.toLowerCase() === currentPuzzleTheme.toLowerCase() || | |
| puzzle.subtheme.toLowerCase() === currentPuzzleTheme.toLowerCase(); | |
| }); | |
| } | |
| // If no puzzles match the filter, use all puzzles | |
| if (filteredPuzzles.length === 0) { | |
| filteredPuzzles = puzzleDatabase; | |
| } | |
| // Select a random puzzle from the filtered list | |
| const puzzle = filteredPuzzles[Math.floor(Math.random() * filteredPuzzles.length)]; | |
| currentPuzzle = puzzle; | |
| // Load the puzzle position | |
| puzzleGame = new Chess(puzzle.fen); | |
| puzzleBoard.position(puzzle.fen, false); // false to prevent animation | |
| // Convert solution to move objects | |
| puzzleSolution = puzzle.solution.map(moveStr => { | |
| return { | |
| from: moveStr.substr(0, 2), | |
| to: moveStr.substr(2, 2), | |
| promotion: moveStr.length > 4 ? moveStr.substr(4, 1) : undefined | |
| }; | |
| }); | |
| currentPuzzleMove = 0; | |
| // Update puzzle info | |
| document.getElementById('puzzleTheme').textContent = `${puzzle.theme} (${puzzle.subtheme})`; | |
| document.getElementById('puzzleRating').textContent = puzzle.rating; | |
| document.getElementById('puzzleMoves').textContent = puzzle.moves; | |
| document.getElementById('puzzleSource').textContent = puzzle.source; | |
| document.getElementById('puzzleStatus').textContent = 'Find the best move!'; | |
| // Hide import form if visible | |
| document.getElementById('importPuzzleForm').classList.add('hidden'); | |
| } | |
| // Puzzle functions | |
| function onPuzzleDragStart(source, piece, position, orientation) { | |
| // Only allow dragging if it's the player's turn | |
| if (puzzleGame.turn() !== 'w') { | |
| return false; | |
| } | |
| // Only allow dragging of white pieces | |
| if (piece.search(/^b/) !== -1) { | |
| return false; | |
| } | |
| return true; | |
| } | |
| function onPuzzleDrop(source, target) { | |
| // See if the move is legal | |
| const move = puzzleGame.move({ | |
| from: source, | |
| to: target, | |
| promotion: 'q' // Always promote to queen for simplicity | |
| }); | |
| // Illegal move | |
| if (move === null) return 'snapback'; | |
| // Check if the move matches the puzzle solution | |
| if (currentPuzzleMove < puzzleSolution.length) { | |
| const solutionMove = puzzleSolution[currentPuzzleMove]; | |
| if (move.from === solutionMove.from && move.to === solutionMove.to) { | |
| // Correct move | |
| currentPuzzleMove++; | |
| document.getElementById('puzzleStatus').innerHTML = '<span class="text-green-600">Correct!</span>'; | |
| // If puzzle is complete | |
| if (currentPuzzleMove >= puzzleSolution.length) { | |
| document.getElementById('puzzleStatus').innerHTML = '<span class="text-green-600">Puzzle solved!</span>'; | |
| } else { | |
| // Make the computer's response move | |
| setTimeout(() => { | |
| const nextMove = puzzleSolution[currentPuzzleMove]; | |
| puzzleGame.move(nextMove); | |
| puzzleBoard.position(puzzleGame.fen()); | |
| currentPuzzleMove++; | |
| document.getElementById('puzzleStatus').textContent = 'Find the best move!'; | |
| }, 500); | |
| } | |
| } else { | |
| // Incorrect move | |
| document.getElementById('puzzleStatus').innerHTML = '<span class="text-red-600">Incorrect, try again!</span>'; | |
| return 'snapback'; | |
| } | |
| } | |
| puzzleBoard.position(puzzleGame.fen()); | |
| } | |
| function onPuzzleSnapEnd() { | |
| puzzleBoard.position(puzzleGame.fen()); | |
| } | |
| function toggleImportPuzzleForm() { | |
| const form = document.getElementById('importPuzzleForm'); | |
| form.classList.toggle('hidden'); | |
| } | |
| function importPuzzle() { | |
| const format = document.getElementById('importFormat').value; | |
| const data = document.getElementById('puzzleData').value.trim(); | |
| try { | |
| if (format === 'fen') { | |
| puzzleGame = new Chess(data); | |
| puzzleBoard.position(data); | |
| } else if (format === 'pgn') { | |
| puzzleGame = new Chess(); | |
| puzzleGame.loadPgn(data); | |
| puzzleBoard.position(puzzleGame.fen()); | |
| } | |
| // For this demo, we'll just set a simple solution | |
| puzzleSolution = []; | |
| currentPuzzleMove = 0; | |
| document.getElementById('puzzleStatus').textContent = 'Puzzle loaded! Add solution moves.'; | |
| document.getElementById('importPuzzleForm').classList.add('hidden'); | |
| // Update puzzle info | |
| document.getElementById('puzzleTheme').textContent = 'Custom'; | |
| document.getElementById('puzzleRating').textContent = 'N/A'; | |
| document.getElementById('puzzleMoves').textContent = '0'; | |
| document.getElementById('puzzleSource').textContent = 'Custom'; | |
| } catch (e) { | |
| alert('Error loading puzzle: ' + e.message); | |
| } | |
| } | |
| function giveHint() { | |
| if (currentPuzzle && currentPuzzleMove < puzzleSolution.length) { | |
| const hintMove = puzzleSolution[currentPuzzleMove]; | |
| alert(`Hint: Try moving from ${hintMove.from} to ${hintMove.to}`); | |
| } else { | |
| alert('No active puzzle or puzzle already solved!'); | |
| } | |
| } | |
| function showSolution() { | |
| if (currentPuzzle) { | |
| let solutionText = 'Solution:\n'; | |
| puzzleSolution.forEach((move, i) => { | |
| if (i % 2 === 0) { | |
| solutionText += `${Math.floor(i/2) + 1}. `; | |
| } | |
| solutionText += `${move.from}${move.to} `; | |
| }); | |
| alert(solutionText); | |
| } else { | |
| alert('No active puzzle!'); | |
| } | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=HuggingeFaceeee/spacee" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |