summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extractor/extractor.py13
-rw-r--r--pub/blankplays.js5
-rw-r--r--pub/index.html2
3 files changed, 13 insertions, 7 deletions
diff --git a/extractor/extractor.py b/extractor/extractor.py
index 0960eb1..f4c361d 100644
--- a/extractor/extractor.py
+++ b/extractor/extractor.py
@@ -4,6 +4,8 @@ import sys
import os
import shutil
import argparse
+import os
+pid = os.getpid()
parser = argparse.ArgumentParser(description='''BlankPlays challenge extractor.
Extracts challenges from log files generated by Macondo's autoplay command.''')
@@ -54,7 +56,7 @@ class GameState:
col += 1
else:
row += 1
-
+
def board_string(self) -> str:
rows = []
for row in range(15):
@@ -98,7 +100,7 @@ class GameState:
i += 1
if len(vertical_word) > 1:
words.append(vertical_word)
- if not all(word in word_list for word in words):
+ if not all(word.upper() in word_list for word in words):
return []
return words
@@ -116,11 +118,12 @@ class GameState:
if os.path.exists(filename):
print(filename, 'already exists. Aborting.')
sys.exit(1)
- with open('challenge.tmp', 'wb') as out:
+ tmpnam = f'challenge-{pid}.tmp'
+ with open(tmpnam, 'wb') as out:
out.write(self.board_string().encode())
for square, letter, _ in self.blank_plays():
out.write(f'{square} {letter}\n'.encode())
- os.rename('challenge.tmp', filename)
+ os.rename(f'challenge-{pid}.tmp', filename)
def is_nice(play: tuple[int, str, list[str]]) -> bool:
_square, letter, words = play
@@ -148,7 +151,6 @@ for filename in args.log_files:
if game_id not in games:
games[game_id] = GameState()
play = fields[4]
- games[game_id].make_play(play)
if fields[3] == '?':
game = games[game_id]
plays = game.blank_plays()
@@ -160,4 +162,5 @@ for filename in args.log_files:
print(len(plays), 'plays')
count += 1
game_idx += 1
+ games[game_id].make_play(play)
print(count, 'challenges made.')
diff --git a/pub/blankplays.js b/pub/blankplays.js
index 13a1232..8b80804 100644
--- a/pub/blankplays.js
+++ b/pub/blankplays.js
@@ -75,6 +75,9 @@ function loadAttempt() {
let saveDataStr = localStorage.getItem(`attempt-${lexicon}-${challengeId}`);
if (!saveDataStr) return;
let saveData = JSON.parse(saveDataStr);
+ if (saveData.version !== 2) {
+ return;
+ }
let solution = saveData.solution.split(';');
for (let row = 0; row < N; row++) {
for (let col = 0; col < N; col++) {
@@ -105,7 +108,7 @@ function saveAttempt() {
for (let col = 0; col < N; col++)
solution.push(currAttempt[row][col].join(','));
let saveData = {
- version: 1,
+ version: 2,
solution: solution.join(';'),
finished: finished,
eliminated: eliminated.join(''),
diff --git a/pub/index.html b/pub/index.html
index ce7c9d8..b09e55a 100644
--- a/pub/index.html
+++ b/pub/index.html
@@ -6,7 +6,7 @@
<title>BlankPlays</title>
<link rel="icon" href="/icon.png">
<link rel="stylesheet" href="/index.css?v=1">
- <script src="/blankplays.js?v=4" id="main-script" async></script>
+ <script src="/blankplays.js?v=5" id="main-script" async></script>
</head>
<body>
<script blocking="render">