| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
| <title>Emoji Quest RL • WebXOS 2026</title> |
| <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet"> |
| <script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script> |
| <style> |
| body { |
| font-family: 'Press Start 2P', cursive; |
| background: #000000; |
| color: #00ffcc; |
| margin: 0; |
| padding: 0; |
| overflow-x: hidden; |
| overflow-y: auto; |
| height: 100vh; |
| display: flex; |
| justify-content: center; |
| align-items: flex-start; |
| } |
| #game { |
| width: 100vw; |
| max-width: 100%; |
| padding: 1.5vh; |
| background: rgba(0, 0, 0, 0.9); |
| box-shadow: 0 0 8px #ff00ff; |
| text-shadow: 1px 1px 2px #ff00ff; |
| box-sizing: border-box; |
| } |
| h1 { |
| font-size: 3.5vw; |
| color: #ff00ff; |
| text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff; |
| margin: 1.5vh 0; |
| animation: glow 1.5s infinite alternate; |
| } |
| #status, #mission { |
| font-size: 2vw; |
| color: #ffff00; |
| text-shadow: 1px 1px 2px #ff00ff; |
| margin: 1vh 0; |
| } |
| .entity, #stats, #skills { |
| margin: 1.5vh 0; |
| padding: 0.8vh; |
| background: rgba(255, 0, 255, 0.1); |
| box-shadow: 0 0 4px #00ffcc; |
| } |
| .bar { |
| width: 35vw; |
| height: 2.5vh; |
| background: #222; |
| display: inline-block; |
| box-shadow: inset 0 0 4px #ff00ff; |
| } |
| .health { height: 100%; background: #ff0066; transition: width 0.3s; } |
| .mana { height: 100%; background: #00ccff; transition: width 0.3s; } |
| .exp { height: 100%; background: #ffff00; transition: width 0.3s; } |
| #combat-log { |
| height: 18vh; |
| overflow-y: auto; |
| padding: 0.8vh; |
| background: rgba(0, 0, 0, 0.5); |
| color: #00ffcc; |
| text-shadow: 0.5px 0.5px 1px #ff00ff; |
| font-size: 1.8vw; |
| } |
| button { |
| background: #ff00ff; |
| color: #00ffcc; |
| padding: 0.8vh 1.5vw; |
| font-family: 'Press Start 2P', cursive; |
| font-size: 1.8vw; |
| margin: 0.4vh; |
| cursor: pointer; |
| box-shadow: 0 0 4px #ff00ff; |
| touch-action: manipulation; |
| } |
| button:hover, button:active { background: #00ffcc; color: #ff00ff; } |
| #skill-buttons { display: flex; flex-wrap: wrap; justify-content: center; } |
| |
| |
| #inn-timer { |
| position: fixed; |
| top: 50%; |
| left: 50%; |
| font-size: 3vw; |
| color: #ff00ff; |
| background: rgba(0, 0, 0, 0.8); |
| padding: 2vh; |
| box-shadow: 0 0 16px #00ffcc; |
| display: none; |
| z-index: 100; |
| text-shadow: 2px 2px 4px #00ccff; |
| min-width: 30vw; |
| text-align: center; |
| border: 2px solid #ff00ff; |
| border-radius: 10px; |
| transform: translate(-50%, -50%); |
| } |
| |
| |
| #export-popup { |
| display: none; |
| position: fixed; |
| top: 50%; |
| left: 50%; |
| width: 50vw; |
| max-width: 400px; |
| min-width: 300px; |
| background: #000000; |
| border: 3px solid #ff00ff; |
| box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff; |
| padding: 2vh; |
| z-index: 2000; |
| animation: neonPulse 1.5s infinite alternate; |
| transform: translate(-50%, -50%); |
| text-align: center; |
| } |
| #export-popup h2 { |
| font-size: 2.2vw; |
| color: #ffff00; |
| text-shadow: 0 0 8px #ff00ff; |
| margin: 0 0 2vh 0; |
| } |
| #export-stats { |
| color: #00ffcc; |
| font-size: 1.5vw; |
| line-height: 1.6; |
| margin: 2vh 0; |
| } |
| .export-buttons { |
| display: flex; |
| flex-direction: column; |
| gap: 1.5vh; |
| margin-top: 2vh; |
| } |
| .export-btn { |
| background: #ff00ff; |
| color: #00ffcc; |
| padding: 1.2vh 0; |
| font-size: 1.8vw; |
| width: 100%; |
| border: none; |
| cursor: pointer; |
| box-shadow: 0 0 8px #ff00ff; |
| } |
| .export-btn:hover { |
| background: #00ffcc; |
| color: #ff00ff; |
| } |
| .close-export { |
| background: #ff0066; |
| color: #ffffff; |
| padding: 0.8vh 2vw; |
| font-size: 1.5vw; |
| margin-top: 1vh; |
| width: 100%; |
| } |
| |
| |
| #game-over-screen { |
| display: none; |
| position: fixed; |
| top: 50%; |
| left: 50%; |
| width: 80vw; |
| max-width: 600px; |
| background: linear-gradient(45deg, #ff00ff, #00ccff); |
| color: #ffffff; |
| text-align: center; |
| padding: 2vh; |
| box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff; |
| animation: popup 0.5s ease-out, pulse 2s infinite alternate; |
| z-index: 1000; |
| border-radius: 10px; |
| transform: translate(-50%, -50%); |
| } |
| #game-over-screen h2 { |
| font-size: 3vw; |
| color: #ffff00; |
| text-shadow: 0 0 8px #ff00ff, 0 0 16px #00ccff; |
| margin: 1.5vh 0; |
| } |
| #game-over-screen p { |
| font-size: 1.5vw; |
| color: #ffffff; |
| text-shadow: 0 0 4px #000000; |
| margin: 0.8vh 0; |
| } |
| |
| |
| #craft-menu { |
| display: none; |
| position: fixed; |
| top: 50%; |
| left: 50%; |
| width: 70vw; |
| max-width: 600px; |
| background: #000000; |
| border: 3px solid #ff00ff; |
| box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff; |
| padding: 2vh; |
| z-index: 1000; |
| animation: neonPulse 1.5s infinite alternate; |
| transform: translate(-50%, -50%); |
| } |
| #craft-menu h2 { |
| font-size: 2.5vw; |
| color: #ffff00; |
| text-shadow: 0 0 8px #ff00ff; |
| margin: 0 0 2vh 0; |
| text-align: center; |
| } |
| #craft-list { |
| list-style: none; |
| padding: 0; |
| margin: 0; |
| } |
| #craft-list li { |
| color: #00ffcc; |
| font-size: 1.5vw; |
| padding: 1vh 1.5vw; |
| margin: 0.5vh 0; |
| background: rgba(255, 0, 255, 0.1); |
| border-left: 5px solid #ff00ff; |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| transition: all 0.3s ease; |
| } |
| #craft-list li:hover { |
| background: rgba(255, 0, 255, 0.3); |
| border-left: 5px solid #00ccff; |
| transform: translateX(5px); |
| } |
| #craft-list li button { |
| background: #ffff00; |
| color: #ff00ff; |
| font-size: 1.2vw; |
| padding: 0.5vh 1vw; |
| box-shadow: 0 0 5px #ffffff; |
| } |
| #craft-list li button:hover { |
| background: #00ccff; |
| color: #ffffff; |
| } |
| |
| @keyframes glow { |
| from { text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff; } |
| to { text-shadow: 3px 3px 0 #00ffcc, 0 0 12px #ffffff; } |
| } |
| @keyframes pulse { |
| from { box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff; } |
| to { box-shadow: 0 0 30px #ff00ff, 0 0 40px #00ccff; } |
| } |
| @keyframes popup { |
| from { transform: translate(-50%, -50%) scale(0); opacity: 0; } |
| to { transform: translate(-50%, -50%) scale(1); opacity: 1; } |
| } |
| @keyframes neonPulse { |
| from { box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff; } |
| to { box-shadow: 0 0 25px #ff00ff, 0 0 35px #00ccff, inset 0 0 15px #ff00ff; } |
| } |
| |
| |
| @media screen and (max-width: 768px) { |
| h1 { font-size: 5vw; } |
| #status, #mission { font-size: 3vw; } |
| #export-popup { width: 70vw; } |
| #export-popup h2 { font-size: 3vw; } |
| #export-stats { font-size: 2.2vw; } |
| .export-btn { font-size: 2.5vw; } |
| .close-export { font-size: 2.2vw; } |
| #craft-list li { font-size: 2.5vw; } |
| button { font-size: 2.5vw; } |
| #inn-timer { font-size: 5vw; } |
| } |
| |
| @media screen and (max-width: 480px) { |
| h1 { font-size: 6vw; } |
| #status, #mission { font-size: 4vw; } |
| #export-popup { width: 85vw; padding: 1.5vh; } |
| #export-popup h2 { font-size: 4vw; } |
| #export-stats { font-size: 3vw; } |
| .export-btn { font-size: 3.5vw; padding: 1.5vh 0; } |
| .close-export { font-size: 3vw; } |
| button { font-size: 3vw; padding: 1vh 3vw; } |
| #skill-buttons { flex-direction: column; align-items: center; } |
| .bar { width: 50vw; } |
| } |
| </style> |
| </head> |
| <body> |
| <div id="game"> |
| <h1>Emoji Quest RL • WebXOS 2026</h1> |
| <div id="status">Tap a command to begin! 🎮</div> |
| <div id="stats"> |
| Player: <span id="hero-emoji">🧙♂️</span> Lvl: <span id="hero-level">1</span> Gold: <span id="hero-gold">0</span> 💰<br> |
| HP: <div class="bar"><div class="health" id="hero-health" style="width: 100%;"></div></div> <span id="hero-hp">100/100</span> ❤️<br> |
| MP: <div class="bar"><div class="mana" id="hero-mana" style="width: 100%;"></div></div> <span id="hero-mp">50/50</span> 🔮<br> |
| EXP: <div class="bar"><div class="exp" id="hero-exp" style="width: 0%;"></div></div> <span id="hero-exp-text">0/50</span> ⭐<br> |
| STR: <span id="hero-str">5</span> 💪 | INT: <span id="hero-int">5</span> 🧠 | VIT: <span id="hero-vit">5</span> 🛡️ | DEF: <span id="hero-def">0</span> 🛡️<br> |
| Points: <span id="skill-points">0</span> 🎯 | Armor: <span id="armor-level">None</span> | Weapon: <span id="weapon-level">None</span> |
| </div> |
| <div id="skills" style="display: none;"> |
| <button onclick="upgradeStat('str')">💪 +STR (1pt)</button> |
| <button onclick="upgradeStat('int')">🧠 +INT (1pt)</button> |
| <button onclick="upgradeStat('vit')">🛡️ +VIT (1pt)</button> |
| </div> |
| <div class="entity">Enemy: <span id="enemy-emoji">👾 Zargoth</span> |
| HP: <div class="bar"><div class="health" id="enemy-health" style="width: 100%;"></div></div> <span id="enemy-hp">60/60</span> ❤️ |
| </div> |
| <div id="mission"></div> |
| <div id="combat-log"></div> |
| <div id="skill-buttons"> |
| <button onclick="playerTurn(1)">⚔️ Attack</button> |
| <button onclick="playerTurn(2)">✨ Spell</button> |
| <button onclick="playerTurn(4)">🏡 Inn</button> |
| <button onclick="openCraftMenu()">🔨 Craft</button> |
| <button onclick="showExportPopup()">💾 Export</button> |
| </div> |
| </div> |
|
|
| |
| <div id="inn-timer"></div> |
|
|
| |
| <div id="export-popup"> |
| <h2>💾 Export Dataset</h2> |
| <div id="export-stats"> |
| <div>📊 Decisions: <span id="export-decision-count">0</span></div> |
| <div>👾 Enemies: <span id="export-enemy-count">0</span></div> |
| <div>💰 Gold: <span id="export-gold">0</span></div> |
| <div>⭐ Level: <span id="export-level">1</span></div> |
| <div>⏱️ Playtime: <span id="export-time">0s</span></div> |
| </div> |
| <div class="export-buttons"> |
| <button class="export-btn" onclick="exportDataset()">📥 Export as ZIP</button> |
| <button class="close-export" onclick="closeExportPopup()">Close</button> |
| </div> |
| </div> |
|
|
| |
| <div id="craft-menu"> |
| <h2>🔨 Forge</h2> |
| <ul id="craft-list"> |
| <li>Leather Armor (DEF +25) - 2000 Gold <button onclick="craftArmor(1)">Craft</button></li> |
| <li>Chain Mail (DEF +75) - 10000 Gold <button onclick="craftArmor(2)">Craft</button></li> |
| <li>Plate Armor (DEF +150) - 30000 Gold <button onclick="craftArmor(3)">Craft</button></li> |
| <li>Mythril Armor (DEF +250) - 60000 Gold <button onclick="craftArmor(4)">Craft</button></li> |
| <li>Great Staff (Spell +200) - 50000 Gold <button onclick="craftWeapon(1)">Craft</button></li> |
| <li>Great Sword (ATK +200) - 50000 Gold <button onclick="craftWeapon(2)">Craft</button></li> |
| </ul> |
| <button class="close-export" onclick="closeCraftMenu()">Close</button> |
| </div> |
|
|
| |
| <div id="game-over-screen"> |
| <h2>🏆 Game Over</h2> |
| <p>Level: <span id="game-over-level"></span> 🎖️</p> |
| <p>Total Gold: <span id="game-over-gold"></span> 💰</p> |
| <p>Total XP: <span id="game-over-exp"></span> ⭐</p> |
| <p>Total Decisions: <span id="game-over-decisions"></span> 📊</p> |
| <button onclick="showExportPopup()">💾 Export Dataset</button> |
| <button onclick="location.reload()">🔄 Restart</button> |
| </div> |
|
|
| <script> |
| |
| let gameData = { |
| states: [], |
| flatStates: [], |
| decisions: [], |
| metadata: { |
| game: "Emoji Quest RL", |
| version: "WebXOS 2026", |
| created: new Date().toISOString(), |
| license: "MIT", |
| default_config: "csv", |
| features: [ |
| {name: "timestamp", dtype: "int64"}, |
| {name: "action", dtype: "string"}, |
| {name: "reward", dtype: "float64"}, |
| {name: "outcome", dtype: "string"}, |
| {name: "decision_type", dtype: "string"}, |
| {name: "player_state", dtype: "string"}, |
| {name: "enemy_info", dtype: "string"}, |
| {name: "player_state_snapshot", dtype: "string"}, |
| {name: "enemy_state", dtype: "string"}, |
| {name: "enemy_count", dtype: "int64"}, |
| {name: "game_state", dtype: "string"} |
| ] |
| } |
| }; |
| |
| |
| const status = document.getElementById('status'); |
| const combatLog = document.getElementById('combat-log'); |
| const heroHealth = document.getElementById('hero-health'); |
| const heroHp = document.getElementById('hero-hp'); |
| const heroMana = document.getElementById('hero-mana'); |
| const heroMp = document.getElementById('hero-mp'); |
| const heroExp = document.getElementById('hero-exp'); |
| const heroExpText = document.getElementById('hero-exp-text'); |
| const heroLevel = document.getElementById('hero-level'); |
| const heroGold = document.getElementById('hero-gold'); |
| const heroStr = document.getElementById('hero-str'); |
| const heroInt = document.getElementById('hero-int'); |
| const heroVit = document.getElementById('hero-vit'); |
| const heroDef = document.getElementById('hero-def'); |
| const skillPoints = document.getElementById('skill-points'); |
| const armorLevel = document.getElementById('armor-level'); |
| const weaponLevel = document.getElementById('weapon-level'); |
| const enemyHealth = document.getElementById('enemy-health'); |
| const enemyHp = document.getElementById('enemy-hp'); |
| const enemyEmoji = document.getElementById('enemy-emoji'); |
| const mission = document.getElementById('mission'); |
| const skillsDiv = document.getElementById('skills'); |
| const craftMenu = document.getElementById('craft-menu'); |
| const exportPopup = document.getElementById('export-popup'); |
| const gameOverScreen = document.getElementById('game-over-screen'); |
| const innTimer = document.getElementById('inn-timer'); |
| |
| let hero = { |
| level: 1, hp: 100, maxHp: 100, mp: 50, maxMp: 50, exp: 0, expToLevel: 50, |
| str: 5, int: 5, vit: 5, def: 0, gold: 0, skillPoints: 0, |
| armorLevel: 0, hasGreatStaff: false, hasGreatSword: false, atkBonus: 0, spellBonus: 0 |
| }; |
| const startTime = Date.now(); |
| const baseEnemies = [ |
| { emoji: '👾', name: 'Zargoth', hp: 60, attack: 10 }, |
| { emoji: '🕷️', name: 'Skrix', hp: 50, attack: 12 }, |
| { emoji: '🦇', name: 'Vlyth', hp: 55, attack: 11 }, |
| { emoji: '🐍', name: 'Slytheron', hp: 80, attack: 15 }, |
| { emoji: '🦂', name: 'Stingrax', hp: 70, attack: 18 }, |
| { emoji: '🤖', name: 'Mechalon', hp: 100, attack: 20 }, |
| { emoji: '💾', name: 'Datavore', hp: 120, attack: 25 }, |
| { emoji: '🖥️', name: 'Screenix', hp: 110, attack: 22 }, |
| { emoji: '🕸️', name: 'Webtron', hp: 130, attack: 28 }, |
| { emoji: '🔋', name: 'Voltrix', hp: 140, attack: 26 }, |
| { emoji: '🐉', name: 'Drakzul', hp: 150, attack: 30 }, |
| { emoji: '👻', name: 'Spectrix', hp: 140, attack: 32 }, |
| { emoji: '👽', name: 'Xenorath', hp: 200, attack: 40 } |
| ]; |
| let enemyCount = 0; |
| let currentEnemy = spawnEnemy(); |
| let gameState = 'playing'; |
| let innCooldown = false; |
| let decisionCount = 0; |
| |
| |
| const audioContext = new (window.AudioContext || window.webkitAudioContext)(); |
| function playClickSound() { |
| const oscillator = audioContext.createOscillator(); |
| const gainNode = audioContext.createGain(); |
| oscillator.connect(gainNode); |
| gainNode.connect(audioContext.destination); |
| oscillator.type = 'square'; |
| oscillator.frequency.value = 880; |
| gainNode.gain.setValueAtTime(0.1, audioContext.currentTime); |
| gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.1); |
| oscillator.start(); |
| oscillator.stop(audioContext.currentTime + 0.1); |
| } |
| |
| function playInnSound() { |
| const oscillator = audioContext.createOscillator(); |
| const gainNode = audioContext.createGain(); |
| oscillator.connect(gainNode); |
| gainNode.connect(audioContext.destination); |
| oscillator.type = 'sine'; |
| oscillator.frequency.setValueAtTime(440, audioContext.currentTime); |
| oscillator.frequency.exponentialRampToValueAtTime(880, audioContext.currentTime + 0.5); |
| gainNode.gain.setValueAtTime(0.1, audioContext.currentTime); |
| gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.5); |
| oscillator.start(); |
| oscillator.stop(audioContext.currentTime + 0.5); |
| } |
| |
| |
| function recordState(action, reward, outcome) { |
| const timestamp = Date.now(); |
| const decision_type = getDecisionType(action); |
| |
| |
| const playerSnapshot = JSON.stringify({ |
| level: hero.level, |
| hp: hero.hp, |
| maxHp: hero.maxHp, |
| mp: hero.mp, |
| maxMp: hero.maxMp, |
| str: hero.str, |
| int: hero.int, |
| vit: hero.vit, |
| def: hero.def, |
| gold: hero.gold, |
| skillPoints: hero.skillPoints |
| }); |
| |
| |
| const enemyInfo = JSON.stringify({ |
| name: currentEnemy.name, |
| emoji: currentEnemy.emoji, |
| hp: currentEnemy.hp, |
| maxHp: currentEnemy.maxHp, |
| attack: currentEnemy.attack, |
| is_boss: currentEnemy.isBoss || false, |
| is_elite: currentEnemy.isElite || false |
| }); |
| |
| |
| const playerState = JSON.stringify(hero); |
| |
| |
| const enemyState = JSON.stringify(currentEnemy); |
| |
| |
| const completeState = { |
| timestamp, |
| action: action.toString(), |
| reward: parseFloat(reward), |
| outcome, |
| decision_type, |
| player_state_snapshot: playerSnapshot, |
| enemy_info: enemyInfo, |
| player_state: playerState, |
| enemy_state: enemyState, |
| enemy_count: enemyCount, |
| game_state: gameState |
| }; |
| |
| |
| gameData.states.push(completeState); |
| gameData.decisions.push(completeState); |
| gameData.flatStates.push(completeState); |
| |
| decisionCount++; |
| } |
| |
| function getDecisionType(actionId) { |
| if (typeof actionId === 'string') { |
| if (actionId.includes('upgrade')) return "upgrade_stat"; |
| if (actionId.includes('craft_armor')) return "craft_armor"; |
| if (actionId.includes('craft_weapon')) return "craft_weapon"; |
| if (actionId.includes('enemy_defeated')) return "combat_victory"; |
| if (actionId.includes('player_death')) return "player_death"; |
| if (actionId.includes('inn_rest')) return "rest_inn"; |
| if (actionId.includes('level_up')) return "progression"; |
| return actionId; |
| } |
| |
| const types = { |
| 1: "combat_attack", |
| 2: "combat_spell", |
| 4: "rest_inn" |
| }; |
| return types[actionId] || "unknown"; |
| } |
| |
| |
| function convertToCSV(data, columns) { |
| if (data.length === 0) return ''; |
| |
| const headers = columns.join(','); |
| const rows = data.map(item => { |
| return columns.map(col => { |
| let value = item[col]; |
| if (value === undefined || value === null) value = ''; |
| if (typeof value === 'object' && value !== null) { |
| value = JSON.stringify(value).replace(/"/g, '""'); |
| return `"${value}"`; |
| } |
| if (typeof value === 'string' && (value.includes(',') || value.includes('"'))) { |
| return `"${value.replace(/"/g, '""')}"`; |
| } |
| return value; |
| }).join(','); |
| }); |
| |
| return [headers, ...rows].join('\n'); |
| } |
| |
| // Minimal export popup |
| function showExportPopup() { |
| playClickSound(); |
| |
| // Update stats |
| document.getElementById('export-decision-count').textContent = decisionCount; |
| document.getElementById('export-enemy-count').textContent = enemyCount; |
| document.getElementById('export-gold').textContent = hero.gold; |
| document.getElementById('export-level').textContent = hero.level; |
| document.getElementById('export-time').textContent = Math.floor((Date.now() - startTime) / 1000) + 's'; |
| |
| exportPopup.style.display = 'block'; |
| } |
| |
| function closeExportPopup() { |
| playClickSound(); |
| exportPopup.style.display = 'none'; |
| } |
| |
| // Main export function - FIXED VERSION with consistent columns |
| function exportDataset() { |
| playClickSound(); |
| |
| // Define ALL columns for consistency |
| const allColumns = [ |
| 'timestamp', |
| 'action', |
| 'reward', |
| 'outcome', |
| 'decision_type', |
| 'player_state_snapshot', |
| 'enemy_info', |
| 'player_state', |
| 'enemy_state', |
| 'enemy_count', |
| 'game_state' |
| ]; |
| |
| // Prepare dataset with consistent structure |
| const completeDataset = { |
| game_states: gameData.states.map(state => ({ |
| timestamp: state.timestamp, |
| action: state.action, |
| reward: state.reward, |
| outcome: state.outcome, |
| decision_type: state.decision_type, |
| player_state_snapshot: state.player_state_snapshot, |
| enemy_info: state.enemy_info, |
| player_state: state.player_state, |
| enemy_state: state.enemy_state, |
| enemy_count: state.enemy_count, |
| game_state: state.game_state |
| })), |
| decisions: gameData.decisions.map(decision => ({ |
| timestamp: decision.timestamp, |
| action: decision.action, |
| reward: decision.reward, |
| outcome: decision.outcome, |
| decision_type: decision.decision_type, |
| player_state_snapshot: decision.player_state_snapshot, |
| enemy_info: decision.enemy_info, |
| player_state: decision.player_state, |
| enemy_state: decision.enemy_state, |
| enemy_count: decision.enemy_count, |
| game_state: decision.game_state |
| })), |
| summary: { |
| total_states: gameData.states.length, |
| total_decisions: gameData.decisions.length, |
| total_enemies_defeated: enemyCount, |
| total_gold_earned: hero.gold, |
| total_xp_earned: hero.exp, |
| play_time: Math.floor((Date.now() - startTime) / 1000), |
| final_level: hero.level, |
| final_gold: hero.gold, |
| final_hp: hero.hp, |
| final_mp: hero.mp |
| }, |
| metadata: { |
| ...gameData.metadata, |
| export_date: new Date().toISOString(), |
| license: "mit", |
| task_categories: ["reinforcement_learning", "decision_making"], |
| task_ids: ["emoji_quest_rl"], |
| pretty_name: "Emoji Quest RL Dataset" |
| } |
| }; |
| |
| // Create CSV files with ALL columns |
| const statesData = gameData.flatStates.map(state => { |
| const filtered = {}; |
| allColumns.forEach(col => { |
| filtered[col] = state[col] !== undefined ? state[col] : ''; |
| }); |
| return filtered; |
| }); |
| |
| const decisionsData = gameData.decisions.map(decision => { |
| const filtered = {}; |
| allColumns.forEach(col => { |
| filtered[col] = decision[col] !== undefined ? decision[col] : ''; |
| }); |
| return filtered; |
| }); |
| |
| const statesCSV = convertToCSV(statesData, allColumns); |
| const decisionsCSV = convertToCSV(decisionsData, allColumns); |
| |
| // Create README with consistent config |
| const readme = `--- |
| license: mit |
| task_categories: |
| - reinforcement_learning |
| - decision_making |
| task_ids: |
| - emoji_quest_rl |
| pretty_name: Emoji Quest RL Dataset |
| dataset_info: |
| configs: |
| - config_name: game_states |
| data_files: |
| - split: train |
| path: game_states.csv |
| features: |
| - name: timestamp |
| dtype: int64 |
| - name: action |
| dtype: string |
| - name: reward |
| dtype: float64 |
| - name: outcome |
| dtype: string |
| - name: decision_type |
| dtype: string |
| - name: player_state_snapshot |
| dtype: string |
| - name: enemy_info |
| dtype: string |
| - name: player_state |
| dtype: string |
| - name: enemy_state |
| dtype: string |
| - name: enemy_count |
| dtype: int64 |
| - name: game_state |
| dtype: string |
| - config_name: decisions |
| data_files: |
| - split: train |
| path: decisions.csv |
| features: |
| - name: timestamp |
| dtype: int64 |
| - name: action |
| dtype: string |
| - name: reward |
| dtype: float64 |
| - name: outcome |
| dtype: string |
| - name: decision_type |
| dtype: string |
| - name: player_state_snapshot |
| dtype: string |
| - name: enemy_info |
| dtype: string |
| - name: player_state |
| dtype: string |
| - name: enemy_state |
| dtype: string |
| - name: enemy_count |
| dtype: int64 |
| - name: game_state |
| dtype: string |
| default: game_states |
| --- |
| # Emoji Quest RL Dataset |
| Reinforcement learning dataset from Emoji Quest RL gameplay. |
| |
| ## Files |
| ### game_states.csv |
| Game state snapshots at each decision point. Contains player and enemy stats. |
| |
| ### decisions.csv |
| Player decisions with rewards and outcomes. Contains action choices and results. |
| |
| ## Summary |
| - Total states: ${completeDataset.summary.total_states} |
| - Total decisions: ${completeDataset.summary.total_decisions} |
| - Total enemies defeated: ${completeDataset.summary.total_enemies_defeated} |
| - Total gold earned: ${completeDataset.summary.total_gold_earned} |
| - Total XP earned: ${completeDataset.summary.total_xp_earned} |
| - Play time: ${completeDataset.summary.play_time} seconds |
| - Final level: ${completeDataset.summary.final_level} |
| - Final gold: ${completeDataset.summary.final_gold} |
| - Final HP: ${completeDataset.summary.final_hp} |
| - Final MP: ${completeDataset.summary.final_mp} |
| `; |
| |
| // Create ZIP - Only include the required 5 files |
| const zip = new JSZip(); |
| |
| // Add only the required files (no dataset_summary.json) |
| zip.file("game_states.csv", statesCSV); |
| zip.file("decisions.csv", decisionsCSV); |
| zip.file("game_states.json", JSON.stringify(completeDataset.game_states, null, 2)); |
| zip.file("decisions.json", JSON.stringify(completeDataset.decisions, null, 2)); |
| zip.file("README.md", readme); |
| |
| // Generate and download |
| zip.generateAsync({type: "blob", compression: "DEFLATE"}) |
| .then(blob => { |
| const url = URL.createObjectURL(blob); |
| const a = document.createElement('a'); |
| a.href = url; |
| a.download = `emoji_quest_${Date.now()}.zip`; |
| document.body.appendChild(a); |
| a.click(); |
| document.body.removeChild(a); |
| URL.revokeObjectURL(url); |
| |
| appendLog("✅ Dataset exported! Ready for HF Upload."); |
| closeExportPopup(); |
| }) |
| .catch(error => { |
| appendLog("❌ Export failed: " + error); |
| console.error(error); |
| }); |
| } |
| |
| // ESC key for quick export |
| document.addEventListener('keydown', function(e) { |
| if (e.key === 'Escape' && gameState === 'playing') { |
| showExportPopup(); |
| } |
| }); |
| |
| // Game commands |
| const commands = { |
| 1: { name: 'Attack', emoji: '⚔️', cost: 0, effect: (enemy) => { |
| let dmg = (hero.str * 3) + hero.atkBonus; |
| enemy.hp -= dmg; |
| return dmg; |
| }, log: 'slashes with Attack ⚔️' }, |
| 2: { name: 'Spell', emoji: '✨', cost: 15, effect: (enemy) => { |
| let dmg = 75 + (hero.int * 3) + hero.spellBonus; |
| enemy.hp -= dmg; |
| return dmg; |
| }, log: 'casts Spell ✨' }, |
| 4: { name: 'Inn', emoji: '🏡', cost: 0, effect: () => startInnTimer(), log: 'rests at Inn 🏡' } |
| }; |
| |
| const armors = [ |
| { name: 'None', def: 0, cost: 0 }, |
| { name: 'Leather Armor', def: 25, cost: 2000 }, |
| { name: 'Chain Mail', def: 75, cost: 10000 }, |
| { name: 'Plate Armor', def: 150, cost: 30000 }, |
| { name: 'Mythril Armor', def: 250, cost: 60000 } |
| ]; |
| |
| const weapons = [ |
| { name: 'None', spellBonus: 0, atkBonus: 0, cost: 0 }, |
| { name: 'Great Staff', spellBonus: 200, atkBonus: 0, cost: 50000 }, |
| { name: 'Great Sword', spellBonus: 0, atkBonus: 200, cost: 50000 } |
| ]; |
| |
| function spawnEnemy() { |
| enemyCount++; |
| let baseEnemy = baseEnemies[Math.floor(Math.random() * baseEnemies.length)]; |
| let scale = 1 + (enemyCount * 0.1); |
| let levelScale = 0.8 + (hero.level * 0.05); |
| let enemy = { |
| ...baseEnemy, |
| hp: Math.floor(baseEnemy.hp * scale), |
| maxHp: Math.floor(baseEnemy.hp * scale), |
| attack: Math.floor(baseEnemy.attack * scale * levelScale), |
| isBoss: false, |
| isElite: false |
| }; |
| if (enemyCount % 10 === 0) { |
| enemy.hp *= 2; |
| enemy.maxHp *= 2; |
| enemy.attack *= 2; |
| enemy.emoji = `👑${enemy.emoji}`; |
| enemy.name = `King ${enemy.name}`; |
| enemy.isBoss = true; |
| } else if (Math.random() < 0.2) { |
| enemy.hp = Math.floor(enemy.hp * 1.5); |
| enemy.maxHp = Math.floor(enemy.hp * 1.5); |
| enemy.attack = Math.floor(enemy.attack * 1.5); |
| enemy.emoji = `⭐${enemy.emoji}`; |
| enemy.name = `Elite ${enemy.name}`; |
| enemy.isElite = true; |
| } |
| return enemy; |
| } |
| |
| function playerTurn(commandId) { |
| if (gameState !== 'playing' || innCooldown) return; |
| playClickSound(); |
| |
| const command = commands[commandId]; |
| if (command.cost > 0 && hero.mp < command.cost) { |
| appendLog('Not enough Mana! 🔮'); |
| return; |
| } |
| |
| hero.mp -= command.cost; |
| let log = `🧙♂️ ${command.log}`; |
| let damage = 0; |
| |
| if (commandId === 1 || commandId === 2) { |
| damage = command.effect(currentEnemy); |
| log += ` for ${damage} damage!`; |
| recordState(command.name, damage, "damage_dealt"); |
| } else { |
| command.effect(currentEnemy); |
| return; |
| } |
| |
| appendLog(log); |
| updateUI(); |
| |
| if (currentEnemy.hp <= 0) { |
| recordState("enemy_defeated", 100, "victory"); |
| winCombat(); |
| } else if (!innCooldown) { |
| setTimeout(randomEnemyTurn, 500); |
| } |
| } |
| |
| function randomEnemyTurn() { |
| if (gameState !== 'playing' || innCooldown) return; |
| if (Math.random() < 0.5) { |
| let damage = Math.max(1, currentEnemy.attack - hero.def); |
| hero.hp -= damage; |
| appendLog(`${currentEnemy.emoji} ${currentEnemy.name} strikes for ${damage} damage! 💥 (Def: ${hero.def})`); |
| recordState("enemy_attack", -damage, "damage_taken"); |
| updateUI(); |
| if (hero.hp <= 0) { |
| gameState = 'over'; |
| status.textContent = 'Game Over! 💀'; |
| recordState("player_death", -1000, "defeat"); |
| showGameOverScreen(); |
| } |
| } else { |
| appendLog(`${currentEnemy.emoji} ${currentEnemy.name} hesitates... ⏳`); |
| recordState("enemy_hesitate", 0, "enemy_inaction"); |
| } |
| } |
| |
| function startInnTimer() { |
| if (innCooldown) return; |
| |
| playInnSound(); |
| innCooldown = true; |
| let timeLeft = 10; |
| |
| innTimer.style.display = 'block'; |
| innTimer.textContent = `Resting: ${timeLeft}s ⏳`; |
| status.textContent = 'Resting at the Inn... 🏡'; |
| |
| const timer = setInterval(() => { |
| timeLeft--; |
| innTimer.textContent = `Resting: ${timeLeft}s ⏳`; |
| |
| if (timeLeft <= 0) { |
| clearInterval(timer); |
| hero.hp = hero.maxHp; |
| hero.mp = hero.maxMp; |
| innCooldown = false; |
| innTimer.style.display = 'none'; |
| status.textContent = 'Tap a command to fight! 🎮'; |
| appendLog('🧙♂️ fully restored! 🌟'); |
| recordState("inn_rest", 200, "full_restoration"); |
| updateUI(); |
| } |
| }, 1000); |
| } |
| |
| function winCombat() { |
| const enemyKey = `${currentEnemy.emoji} ${currentEnemy.name}`; |
| let expGain = Math.floor(currentEnemy.maxHp / 2 * (1 + enemyCount * 0.05)); |
| let goldGain = Math.floor(currentEnemy.maxHp * (1 + enemyCount * 0.05)); |
| appendLog(`${enemyKey} defeated! +${expGain} EXP ⭐, +${goldGain} Gold 💰`); |
| hero.exp += expGain; |
| hero.gold += goldGain; |
| if (hero.exp >= hero.expToLevel) levelUp(); |
| currentEnemy = spawnEnemy(); |
| updateMission(); |
| updateUI(); |
| } |
| |
| function levelUp() { |
| hero.level++; |
| hero.exp -= hero.expToLevel; |
| hero.expToLevel = Math.floor(hero.expToLevel * 1.5); |
| hero.skillPoints += 2; |
| hero.maxHp += 20 + hero.vit * 2; |
| hero.maxMp += 10; |
| appendLog(`Level Up! Now Level ${hero.level}. +2 Skill Points! 🌟`); |
| recordState("level_up", 500, "progression"); |
| skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none'; |
| updateUI(); |
| } |
| |
| function upgradeStat(stat) { |
| if (hero.skillPoints > 0) { |
| playClickSound(); |
| hero[stat]++; |
| hero.skillPoints--; |
| appendLog(`+1 ${stat.toUpperCase()}! 🎯`); |
| recordState(`upgrade_${stat}`, 50, "stat_improvement"); |
| skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none'; |
| updateUI(); |
| } |
| } |
| |
| function craftArmor(level) { |
| playClickSound(); |
| const armor = armors[level]; |
| if (hero.gold >= armor.cost && hero.armorLevel < level) { |
| hero.gold -= armor.cost; |
| hero.def = armor.def; |
| hero.armorLevel = level; |
| appendLog(`Crafted ${armor.name}! DEF increased to ${hero.def} 🛡️`); |
| recordState(`craft_armor_${level}`, armor.def, "equipment_craft"); |
| closeCraftMenu(); |
| updateUI(); |
| } else if (hero.gold < armor.cost) { |
| appendLog('Not enough Gold! 💰'); |
| } else { |
| appendLog('You already have better armor! 🛡️'); |
| } |
| } |
| |
| function craftWeapon(index) { |
| playClickSound(); |
| const weapon = weapons[index]; |
| let alreadyOwned = (index === 1 && hero.hasGreatStaff) || (index === 2 && hero.hasGreatSword); |
| if (hero.gold >= weapon.cost && !alreadyOwned) { |
| hero.gold -= weapon.cost; |
| if (index === 1) { |
| hero.hasGreatStaff = true; |
| hero.spellBonus += weapon.spellBonus; |
| appendLog(`Crafted ${weapon.name}! Spell damage increased by ${weapon.spellBonus} ✨`); |
| } else if (index === 2) { |
| hero.hasGreatSword = true; |
| hero.atkBonus += weapon.atkBonus; |
| appendLog(`Crafted ${weapon.name}! Attack damage increased by ${weapon.atkBonus} ⚔️`); |
| } |
| recordState(`craft_weapon_${index}`, weapon.spellBonus + weapon.atkBonus, "weapon_craft"); |
| closeCraftMenu(); |
| updateUI(); |
| } else if (hero.gold < weapon.cost) { |
| appendLog('Not enough Gold! 💰'); |
| } else { |
| appendLog(`You already own the ${weapon.name}!`); |
| } |
| } |
| |
| function showGameOverScreen() { |
| gameOverScreen.style.display = 'block'; |
| document.getElementById('game-over-level').textContent = hero.level; |
| document.getElementById('game-over-gold').textContent = hero.gold; |
| document.getElementById('game-over-exp').textContent = Math.floor(hero.exp); |
| document.getElementById('game-over-decisions').textContent = decisionCount; |
| } |
| |
| function updateUI() { |
| heroHealth.style.width = `${(hero.hp / hero.maxHp) * 100}%`; |
| heroHp.textContent = `${hero.hp}/${hero.maxHp}`; |
| heroMana.style.width = `${(hero.mp / hero.maxMp) * 100}%`; |
| heroMp.textContent = `${hero.mp}/${hero.maxMp}`; |
| heroExp.style.width = `${(hero.exp / hero.expToLevel) * 100}%`; |
| heroExpText.textContent = `${Math.floor(hero.exp)}/${hero.expToLevel}`; |
| heroLevel.textContent = hero.level; |
| heroGold.textContent = hero.gold; |
| heroStr.textContent = hero.str; |
| heroInt.textContent = hero.int; |
| heroVit.textContent = hero.vit; |
| heroDef.textContent = hero.def; |
| skillPoints.textContent = hero.skillPoints; |
| armorLevel.textContent = armors[hero.armorLevel].name; |
| weaponLevel.textContent = `${hero.hasGreatStaff ? 'Great Staff' : ''}${hero.hasGreatStaff && hero.hasGreatSword ? ' + ' : ''}${hero.hasGreatSword ? 'Great Sword' : ''}` || 'None'; |
| enemyHealth.style.width = `${(currentEnemy.hp / currentEnemy.maxHp) * 100}%`; |
| enemyHp.textContent = currentEnemy.hp <= 0 ? 'DEFEATED' : `${currentEnemy.hp}/${currentEnemy.maxHp}`; |
| enemyEmoji.textContent = `${currentEnemy.emoji} ${currentEnemy.name}`; |
| } |
| |
| function updateMission() { |
| mission.textContent = `Enemies: ${enemyCount} | Decisions: ${decisionCount} | Exportable for RL! 📊`; |
| } |
| |
| function appendLog(message) { |
| if (message) { |
| combatLog.innerHTML += `<p>${message}</p>`; |
| combatLog.scrollTop = combatLog.scrollHeight; |
| } |
| } |
| |
| function openCraftMenu() { |
| playClickSound(); |
| craftMenu.style.display = 'block'; |
| } |
| |
| function closeCraftMenu() { |
| playClickSound(); |
| craftMenu.style.display = 'none'; |
| } |
| |
| // Initialize |
| updateMission(); |
| updateUI(); |
| </script> |
| </body> |
| </html> |