Spaces:
Sleeping
Sleeping
File size: 17,106 Bytes
54e73c3 |
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 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wordle Solver</title>
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #1a1a1a;
color: #ffffff;
min-height: 100vh;
}
.container {
padding: 2rem;
max-width: 1200px;
margin: 0 auto;
}
h1 {
color: #ffffff;
margin: 0 0 1rem 0;
font-size: 2.5rem;
font-weight: 700;
text-align: center;
font-family: 'Helvetica Neue', Arial, sans-serif;
letter-spacing: 0.05em;
}
.disclaimer {
color: #999999;
font-size: 0.9rem;
text-align: center;
margin-bottom: 1rem;
font-style: italic;
}
.feedback-instruction {
color: #ffffff;
font-size: 1.1rem;
text-align: center;
margin-bottom: 0.5rem;
}
#current-word {
color: #ffffff;
font-size: 1.5rem;
text-align: center;
margin: 0 0 1rem 0;
font-weight: bold;
}
.warning-note {
color: #ffa500;
font-size: 0.9rem;
text-align: center;
margin: 0 0 2rem 0;
padding: 8px 16px;
background-color: rgba(255, 165, 0, 0.1);
border: 1px solid rgba(255, 165, 0, 0.3);
border-radius: 6px;
max-width: 500px;
margin-left: auto;
margin-right: auto;
margin-bottom: 2rem;
}
.game-container {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
margin: 0 auto;
max-width: 450px;
}
.row-indicator {
width: 30px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: space-around;
height: 100%;
}
.arrow {
font-size: 1.5rem;
color: #ffffff;
opacity: 0;
transition: opacity 0.3s;
height: 62px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 5px;
}
.arrow.active {
opacity: 1;
}
.game-grid {
display: grid;
grid-template-rows: repeat(6, 1fr);
gap: 5px;
max-width: 350px;
padding: 20px;
}
.grid-row {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 5px;
}
.grid-cell {
width: 62px;
height: 62px;
border: 2px solid #3a3a3c;
background-color: transparent;
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
font-weight: bold;
color: #ffffff;
text-transform: uppercase;
}
.grid-cell.filled {
border-color: #565758;
}
.grid-cell.selected {
border-color: #ffffff;
border-width: 3px;
}
.grid-cell.correct {
background-color: #6aaa64;
border-color: #3a3a3c;
}
.grid-cell.present {
background-color: #c9b458;
border-color: #3a3a3c;
}
.grid-cell.absent {
background-color: #787c7e;
border-color: #3a3a3c;
}
.feedback-buttons {
display: flex;
justify-content: center;
gap: 15px;
margin: 30px auto 0;
max-width: 600px;
}
.feedback-btn {
padding: 12px 20px;
border: none;
border-radius: 6px;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-weight: bold;
font-size: 14px;
color: #ffffff;
cursor: pointer;
transition: opacity 0.2s;
}
.feedback-btn:hover {
opacity: 0.8;
}
.feedback-btn.green {
background-color: #6aaa64;
}
.feedback-btn.yellow {
background-color: #c9b458;
}
.feedback-btn.gray {
background-color: #787c7e;
}
.control-buttons {
display: flex;
justify-content: center;
gap: 15px;
margin: 20px auto 0;
}
.control-btn {
padding: 10px 18px;
border: none;
border-radius: 6px;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #ffffff;
background-color: #565758;
cursor: pointer;
transition: opacity 0.2s;
}
.control-btn:hover {
opacity: 0.8;
}
</style>
</head>
<body>
<div class="container">
<h1>Wordle Solver</h1>
<p class="disclaimer">This solver is unofficial and not affiliated with the New York Times or Wordle.</p>
<h2 class="feedback-instruction">Enter feedback for</h2>
<h2 id="current-word">ARISE</h2>
<div class="warning-note" id="warning-note">
β οΈ Make sure your feedback is accurate - incorrect feedback may lead to wrong suggestions!
</div>
<div class="game-container">
<div class="row-indicator">
<div class="arrow active" id="arrow-0">β€</div>
<div class="arrow" id="arrow-1">β€</div>
<div class="arrow" id="arrow-2">β€</div>
<div class="arrow" id="arrow-3">β€</div>
<div class="arrow" id="arrow-4">β€</div>
<div class="arrow" id="arrow-5">β€</div>
</div>
<div class="game-grid">
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
</div>
</div>
<div class="feedback-buttons">
<button class="feedback-btn green">Green (Correct)</button>
<button class="feedback-btn yellow">Yellow (Wrong Position)</button>
<button class="feedback-btn gray">Gray (Not in Word)</button>
</div>
<div class="control-buttons">
<button class="control-btn" id="clear-cell-btn">Clear Cell</button>
<button class="control-btn" id="next-row-btn">Next Row</button>
<button class="control-btn" id="reset-game-btn">Reset Game</button>
</div>
</div>
<script>
let currentRow = 0;
let currentCol = 0;
const maxCols = 5;
const maxRows = 6;
// Get all grid cells
const gridCells = document.querySelectorAll('.grid-cell');
function getCellIndex(row, col) {
return row * maxCols + col;
}
function addLetter(letter) {
if (currentCol < maxCols) {
const cellIndex = getCellIndex(currentRow, currentCol);
gridCells[cellIndex].textContent = letter;
gridCells[cellIndex].classList.add('filled');
currentCol++;
}
}
function deleteLetter() {
if (currentCol > 0) {
currentCol--;
const cellIndex = getCellIndex(currentRow, currentCol);
const cell = gridCells[cellIndex];
// Remove color classes instead of text content
cell.classList.remove('correct', 'present', 'absent', 'filled');
}
}
function updateRowIndicator() {
// Hide all arrows
for (let i = 0; i < maxRows; i++) {
document.getElementById(`arrow-${i}`).classList.remove('active');
}
// Show current row arrow
if (currentRow < maxRows) {
document.getElementById(`arrow-${currentRow}`).classList.add('active');
}
}
function getRowFeedback(row) {
// Convert row colors to byg string (black/yellow/green)
let feedback = "";
for (let col = 0; col < maxCols; col++) {
const cellIndex = getCellIndex(row, col);
const cell = gridCells[cellIndex];
if (cell.classList.contains('absent')) {
feedback += 'b'; // black/gray
} else if (cell.classList.contains('present')) {
feedback += 'y'; // yellow
} else if (cell.classList.contains('correct')) {
feedback += 'g'; // green
} else {
feedback += '?'; // no color set
}
}
return feedback;
}
function submitWord() {
if (currentCol < maxCols) {
alert("You need to have 5 colored cells!");
return;
}
if (currentCol === maxCols) {
// Get current row feedback before moving
const feedback = getRowFeedback(currentRow);
const currentWord = document.getElementById('current-word').textContent;
console.log(`Round ${currentRow + 1}: Guessed "${currentWord}" with feedback "${feedback}"`);
// Check if word is solved (all green)
if (feedback === 'ggggg') {
alert("π Congratulations! Word found! π");
document.getElementById('current-word').textContent = "SOLVED!";
console.log(`π SOLVED in ${currentRow + 1} rounds! Final word: "${currentWord}"`);
// Disable further interaction
return;
}
// Send feedback to solver and get next word
document.getElementById('current-word').textContent = "Loading... this may take a while";
fetch('/get_next_word', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ feedback: feedback })
})
.then(response => response.json())
.then(data => {
if (data.word === 'ERROR') {
alert("β No valid words remaining! There might be an error in your feedback.");
return;
}
// Update the current word display
document.getElementById('current-word').textContent = data.word;
console.log(`Round ${currentRow + 2}: Next word suggested: "${data.word}" (${data.candidates_remaining} candidates remaining)`);
})
.catch(error => {
console.error('Error:', error);
alert("Error communicating with solver!");
});
// Move to next row
currentRow++;
currentCol = 0;
if (currentRow >= maxRows) {
currentRow = maxRows - 1; // Stay on last row
}
// Update arrow indicator
updateRowIndicator();
}
}
// Handle physical keyboard input (Enter and Backspace only)
document.addEventListener('keydown', function(event) {
const key = event.key.toUpperCase();
if (key === 'BACKSPACE') {
deleteLetter();
} else if (key === 'ENTER') {
submitWord();
}
});
// Handle feedback button clicks - color cells in sequence
document.querySelectorAll('.feedback-btn').forEach(btn => {
btn.addEventListener('click', function() {
const cellIndex = getCellIndex(currentRow, currentCol);
if (currentCol < maxCols) {
const cell = gridCells[cellIndex];
// Remove existing color classes
cell.classList.remove('correct', 'present', 'absent');
// Add new color class based on button
if (this.classList.contains('green')) {
cell.classList.add('correct');
} else if (this.classList.contains('yellow')) {
cell.classList.add('present');
} else if (this.classList.contains('gray')) {
cell.classList.add('absent');
}
// Move to next cell
currentCol++;
}
});
});
// Handle control button clicks
document.getElementById('clear-cell-btn').addEventListener('click', function() {
deleteLetter();
});
document.getElementById('next-row-btn').addEventListener('click', function() {
submitWord();
});
document.getElementById('reset-game-btn').addEventListener('click', function() {
// Reset frontend state
currentRow = 0;
currentCol = 0;
// Clear all grid cells
gridCells.forEach(cell => {
cell.classList.remove('correct', 'present', 'absent', 'filled', 'selected');
});
// Reset arrow indicator
updateRowIndicator();
// Clear any solved state immediately
document.getElementById('current-word').textContent = "Loading...";
// Reset backend state
fetch('/reset_game', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(data => {
document.getElementById('current-word').textContent = data.word;
console.log('Game reset. Starting word:', data.word);
})
.catch(error => {
console.error('Error:', error);
// If there's an error, still show the default starting word
document.getElementById('current-word').textContent = "ARISE";
});
});
</script>
</body>
</html>
|