File size: 44,002 Bytes
9f5da3a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | <!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 */
#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%);
}
/* Minimal Export Popup */
#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 */
#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 */
#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; }
}
/* Mobile scaling */
@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>
<!-- Inn Timer -->
<div id="inn-timer"></div>
<!-- Minimal Export Popup -->
<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>
<!-- Craft Menu -->
<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>
<!-- Game Over Screen -->
<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>
// Game state tracking
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"}
]
}
};
// Core game variables
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;
// Audio
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);
}
// Record game state - FIXED VERSION with consistent data structure
function recordState(action, reward, outcome) {
const timestamp = Date.now();
const decision_type = getDecisionType(action);
// Create player state snapshot (the 6 missing columns)
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
});
// Create enemy info (the 6 missing columns)
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
});
// Create player state (the 4 new columns)
const playerState = JSON.stringify(hero);
// Create enemy state (the 4 new columns)
const enemyState = JSON.stringify(currentEnemy);
// Create the complete state object with ALL columns
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
};
// Add to game data
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";
}
// CSV helper
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> |