Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
faf71e5ed7 | |||
4405d97daf | |||
cb1fe15cae | |||
101e369da3 | |||
83b8c3db73 |
5
Makefile
5
Makefile
@ -1,12 +1,13 @@
|
||||
WORD_LENGTH=5
|
||||
MIN_FREQUENCY=1
|
||||
VALID_ANSWER_FREQ_MIN=10
|
||||
VALID_INPUT_FREQ_MIN=1
|
||||
SOURCE_WORDLIST=1_1_all_fullalpha.txt
|
||||
ALLOWED_TYPELIST=allowed_types
|
||||
|
||||
all: wordlist.js .SUBMODULES
|
||||
|
||||
wordlist.js:
|
||||
./scripts/gen_wordlist.py ${SOURCE_WORDLIST} ${WORD_LENGTH} ${MIN_FREQUENCY} ${ALLOWED_TYPELIST} > wordlist.js
|
||||
./scripts/gen_wordlist.py ${SOURCE_WORDLIST} ${WORD_LENGTH} ${VALID_ANSWER_FREQ_MIN} ${VALID_INPUT_FREQ_MIN} ${ALLOWED_TYPELIST} > wordlist.js
|
||||
|
||||
clean:
|
||||
rm -rf wordlist.js
|
||||
|
@ -7,4 +7,5 @@ verb
|
||||
pron
|
||||
conj
|
||||
noc
|
||||
vmod
|
||||
@
|
||||
|
10
game.js
10
game.js
@ -1,7 +1,7 @@
|
||||
// global constants
|
||||
const gridWidth = 5
|
||||
const gridHeight = 6
|
||||
const word = wordlist[Math.floor(Math.random()*wordlist.length)];
|
||||
const word = wordlist.valid_answers[Math.floor(Math.random()*wordlist.valid_answers.length)];
|
||||
|
||||
// global state variables
|
||||
var gameCompleted = null
|
||||
@ -42,9 +42,11 @@ function checkGridRow() {
|
||||
getGridRow(row).items.forEach(item => rowWord += item.letter)
|
||||
|
||||
console.log(rowWord)
|
||||
if (!wordlist.includes(rowWord)) {
|
||||
body.classList.add("incorrect")
|
||||
setTimeout( () => body.classList.remove("incorrect"), 500)
|
||||
if (!wordlist.valid_inputs.includes(rowWord)) {
|
||||
getGridRow(row).items.forEach(item => {
|
||||
item.HTMLItem.classList.add("incorrect")
|
||||
setTimeout( () => item.HTMLItem.classList.remove("incorrect"), 500)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,11 @@ class WordListItem:
|
||||
|
||||
self.word = word[1] if word[1].isalpha() else word[3]
|
||||
self.pos = word[2]
|
||||
self.frequency = int(word[4])
|
||||
self.freq = int(word[4])
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return f"<WordListItem {self.word=} {self.pos=} {self.frequency=}>"
|
||||
return f"<WordListItem {self.word=} {self.pos=} {self.freq=}>"
|
||||
|
||||
|
||||
def get_args():
|
||||
@ -23,7 +23,8 @@ def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('wordlist')
|
||||
parser.add_argument('word_length', type=int)
|
||||
parser.add_argument('frequency_min', type=int)
|
||||
parser.add_argument('valid_answer_freq_min', type=int)
|
||||
parser.add_argument('valid_input_freq_min', type=int)
|
||||
parser.add_argument('allowedtypelist')
|
||||
return parser.parse_args()
|
||||
|
||||
@ -36,22 +37,24 @@ def main(args):
|
||||
|
||||
types = set()
|
||||
with open(args.wordlist) as fp:
|
||||
words = [ WordListItem(line) for line in fp.read().strip().lower().split('\n') ]
|
||||
src_words = [ WordListItem(line) for line in fp.read().strip().lower().split('\n') ]
|
||||
|
||||
[ types.add(word.pos) for word in words ]
|
||||
src_words = [ word for word in src_words if word.word.isalpha() ]
|
||||
src_words = [ word for word in src_words if len(word.word) == args.word_length ]
|
||||
src_words = [ word for word in src_words if word.pos in allowed_types ]
|
||||
|
||||
words = [ word.word for word in words if word.frequency >= args.frequency_min and word.word.isalpha() and len(word.word) == args.word_length and word.pos in allowed_types ]
|
||||
[ types.add(word.pos) for word in src_words ]
|
||||
|
||||
words = {}
|
||||
words['valid_answers'] = [ w.word for w in src_words if w.freq >= args.valid_answer_freq_min ]
|
||||
words['valid_inputs'] = [ w.word for w in src_words if w.freq >= args.valid_input_freq_min ]
|
||||
|
||||
words.sort()
|
||||
# remove duplicates
|
||||
words = list(set(words))
|
||||
print(f"wordlist = {json.dumps(words)}")
|
||||
print(f"{args=}", file=sys.stderr)
|
||||
print(f"{len(words)=}", file=sys.stderr)
|
||||
print(f"{len(words['valid_answers'])=}", file=sys.stderr)
|
||||
print(f"{len(words['valid_inputs'])=}", file=sys.stderr)
|
||||
print(f"{types=}", file=sys.stderr)
|
||||
print(f"{'cares' in words=}", file=sys.stderr)
|
||||
print(f"{'ideas' in words=}", file=sys.stderr)
|
||||
print(f"{'prose' in words=}", file=sys.stderr)
|
||||
|
||||
return 0
|
||||
|
||||
|
26
styles.css
26
styles.css
@ -1,4 +1,10 @@
|
||||
@import url("https://alv.cx/styles.css");
|
||||
@import url("https://styles.alv.cx/colors/gruvbox.css");
|
||||
@import url("https://styles.alv.cx/base.css");
|
||||
|
||||
:root {
|
||||
--light: var(--colorscheme-light);
|
||||
}
|
||||
|
||||
|
||||
:root {
|
||||
--default-bg: #fefefe;
|
||||
@ -78,37 +84,37 @@ body {
|
||||
|
||||
@keyframes correct {
|
||||
0% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
50% {
|
||||
background: var(--green);
|
||||
}
|
||||
100% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes incorrect {
|
||||
0% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
50% {
|
||||
background: var(--red);
|
||||
}
|
||||
100% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes clicked {
|
||||
0% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
50% {
|
||||
background: var(--dark-bg);
|
||||
background: var(--bg-lc);
|
||||
}
|
||||
100% {
|
||||
background: var(--default-bg);
|
||||
background: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,11 +129,13 @@ body {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: rgba(255, 255, 255, 0.8)
|
||||
background-color: var(--bg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
#end_screen * {
|
||||
width: fit-content;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#end_screen_image {
|
||||
|
Loading…
Reference in New Issue
Block a user