]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/wordlet/wordlet.factor
assocs.extras: fix usages of collect-key-by collect-value-by
[factor.git] / extra / wordlet / wordlet.factor
index c5c34345acfdea754739003a3328a7beaa2ce61e..05a0bbd5eda7b8b59511b4dbadad7f79d8c07ddb 100644 (file)
@@ -1,11 +1,21 @@
 ! Copyright (C) 2022 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays ascii assocs assocs.extras colors
-combinators hashtables io io.styles kernel math random ranges
-sequences sequences.extras sets sorting strings
-wordlet.word-list ;
+USING: accessors arrays ascii assocs assocs.extras base91 colors
+combinators hashtables io io.encodings.binary
+io.encodings.string io.encodings.utf8 io.files io.styles kernel
+literals math random ranges sequences sequences.extras sets
+sorting splitting strings ;
 IN: wordlet
 
+<PRIVATE
+
+CONSTANT: word-list $[
+    "vocab:wordlet/word-list.txt" binary file-contents
+    base91> utf8 decode "\n" split fast-set
+]
+
+PRIVATE>
+
 TUPLE: wordlet-game secret-word chances guesses ;
 
 : <wordlet-game> ( secret-word chances -- wordlet-game )
@@ -39,7 +49,7 @@ TUPLE: wordlet-game secret-word chances guesses ;
        guess>chars
     ] with map concat members
     [ background of ] assoc-map
-    [ first ] collect-value-by
+    [ drop ] collect-value-by
     [ [ color>n ] zip-with sort-values reverse first first ] assoc-map
     CHAR: a CHAR: z [a..b] [ 1string COLOR: white ] { } map>assoc [ or ] assoc-merge ;
 
@@ -87,4 +97,4 @@ TUPLE: wordlet-game secret-word chances guesses ;
     "wordlet Started" print
     word-list random 6 <wordlet-game> play-wordlet ;
 
-MAIN: play-random-wordlet-game
\ No newline at end of file
+MAIN: play-random-wordlet-game