46 Commits

Author SHA1 Message Date
Mike Mueller
eb8ca3fb60 Customize Worddle min word length.
Instead of a hard-coded 3, you can set a configuration value or pass a
--min=N parameter to the start command.
2012-05-02 01:34:31 -07:00
Mike Mueller
6648d546e4 Remove debugging code. 2012-05-02 00:51:00 -07:00
Mike Mueller
94632a6bcf Optimize prefix trie used in Worddle.
This makes the code a little uglier, but cuts time and memory in half when
building a new Worddle board.  Also updated the boards to not save a reference
to the wordtrie, so after generating the board, it's free for garbage
collection.
2012-04-27 18:23:04 -07:00
Mike Mueller
68dbff765c Compact color codes in Worddle results.
Previously every word would be LCYAN+word+LGRAY (or GRAY+word+LGRAY) and all
these extra color codes would cause the message to be truncated when a lot of
words are found.  Compacted by only sending a color code when a color change
is needed.
2012-04-24 17:07:13 -07:00
Mike Mueller
357d31490d Update game state on @worddle stop.
Otherwise subsequent calls to @worddle stats would throw an exception.
2012-04-23 23:48:19 -07:00
Mike Mueller
0dc36d83b5 Delete game if starting fails.
Can't be sure what kind of state the game is in, so it shouldn't be left
around (receiving handle_message calls, for example).
2012-04-23 23:46:47 -07:00
Mike Mueller
79093bffbc Use medium difficulty by default. 2012-04-23 19:44:03 -07:00
Mike Mueller
6aacd441d0 Make Wordshrink a little easier.
The previous difficulty settings were borderline insane.
2012-04-23 19:42:47 -07:00
Mike Mueller
142d61cbac Handle WordChain puzzle build failures.
Given certain dictionaries (e.g. scrabble), it can be hard or impossible to
create a puzzle meeting the criteria of 'hard' or 'evil' WordShrink.
2012-04-23 19:42:32 -07:00
Mike Mueller
43f07fd142 Attempt to make bountiful Worddle boards.
Generate 5 boards and pick the one with the most solutions.  It's more fun
when there are more solutions to be found.

Refactored a little - the board is now a class WorddleBoard.  Moved the
generation and solution discovery to WorddleBoard.  This simplifies Worddle a
little bit, but it probably could be simplified further.
2012-04-22 20:07:22 -07:00
Ben Schomp
efa6c89e40 Keep the color scheme. 2012-04-12 17:30:18 -04:00
Ben Schomp
38fc1e5ad6 Worddle: Award a golden ticket (yellow '*') in the post game word list for getting a longest word. 2012-04-09 13:31:07 -04:00
Mike Mueller
e706b6816b Clean up board display.
Removed color from "starting in n seconds" message to reduce distraction.
Moved board one column right to give it more breathing room.
2012-04-04 17:59:57 -07:00
Mike Mueller
c51e21b003 Add a "worddle stats" command. 2012-04-04 17:57:24 -07:00
Mike Mueller
77b94e68b2 Clean up and dial down messages.
Trying to make the game a little quieter in the main channel, and in general
cut down on flooding.  Still no verbosity tuning, but this should be a more
reasonable default level.
2012-04-04 15:28:10 -07:00
Mike Mueller
d3945ea763 Attempt to refactor text messages.
Worddle has a lot of logic dedicated to formatting text, and it makes the
code a little unreadable.  I tried to move most of the format strings out
as constants (and color them once instead of every time).  The resulting
code is a little cleaner looking, but I'm not sure I love it.
2012-04-04 01:52:38 -07:00
Mike Mueller
1b1b5331ea Inform late joiners of time left.
When you join late, you find out exactly how many seconds you have left
in the game.
2012-04-04 00:21:03 -07:00
Mike Mueller
79082016ef Implement "official" scoring mechanism.
Word values are now:

  Length | Points
  -------+--------
   3, 4  | 1
   5     | 2
   6     | 3
   7     | 5
   8+    | 11
2012-04-03 17:03:16 -07:00
Mike Mueller
4d5c9e4d2c Add 'start' and 'stop' Worddle commands.
Default is "start" so you can still just say "@worddle" to start a game.
"worddle stop" is the same as saying "@wordquit".
2012-04-03 17:01:34 -07:00
Mike Mueller
bffa11361a Fix Worddle to handle simultaneous games.
It was using the string 'worddle' as the unique identifier in all
scheduled events, which meant that a second game (in another channel,
at the same time) will erase the first game's scheduled events.

Now use the Worddle object's unique identifier when scheduling events.
2012-04-02 01:11:14 -07:00
Mike Mueller
78cef6b7a6 Clean up plugin shutdown logic.
Worked around a supybot bug and abstracted shutdown to calling
game.stop(now=True).  This way the Wordgames class can be ignorant
of the details of stopping a game.
2012-04-02 01:05:06 -07:00
Mike Mueller
21699c34c3 Relay pre-game taunts between players.
Anything typed before "Get Ready!" will be sent to other players.
2012-03-28 23:31:59 -07:00
Mike Mueller
25d750135c Support Freenode's TARGMAX value. 2012-03-28 23:16:17 -07:00
Mike Mueller
1462efce5f Fix bug showing Qu in 4th column.
If Q was the last letter in a row, it Was showing just 'Q' since the 'Q '
substring wasn't found.
2012-03-28 22:45:15 -07:00
Mike Mueller
7f721e7fb9 Tune pre-game timing.
* Whenever someone joins, put at least 5 seconds on the pre-game clock.
  (If more than 5 seconds are already remaining, do nothing.)
* Use the entire delay period before showing "Get ready!".
* Delay 3 more seconds before jumping into the game.
2012-03-28 00:42:28 -07:00
Mike Mueller
8f7016f28e Factor out Worddle results into class.
Also, results are now presented in descending order by score.
2012-03-28 00:30:44 -07:00
Mike Mueller
b489a4752b Only allow join if a game is running. 2012-03-27 22:57:54 -07:00
Mike Mueller
2fb7a3954b Fix regression in WordChain games.
Somehow I took out the code that handles public messages during a game.
2012-03-27 01:46:44 -07:00
Mike Mueller
e63a36b2c1 Turn debug mode off.
Did't mean to leave this on.
2012-03-27 01:39:55 -07:00
Mike Mueller
94ec34d5a6 General improvements to Worddle gameplay.
Added support for broadcasting messages in one shot if the IRC server
supports multiple targets. (Inspircd only right now, need to add support for
more servers.)  This will hopefully reduce flood issues and latency.

Cleaned up messages, improved use of color, added join notifications,
added a 'get ready' state 5 seconds before game starts.

Some code cleanup and refactoring.
2012-03-27 01:16:34 -07:00
Mike Mueller
353b5109dc Add a new game: Worddle
This is a clone of a famous game involving a 4x4 grid of random letters.
It uses Plugin's inFilter to filter out private messages to the bot during
the game, so that they are not treated as commands.  You can still send
commands to the bot using the command character during this period.  When
the game ends, the filter puts things back to normal.

Also implemented a new command when DEBUG is True, wordsolve, which shows
the solution to the current wordgame.
2012-03-26 16:39:37 -07:00
Mike Mueller
4bc4c0d858 Make _start_game arguments generic.
It shouldn't need to know what specific parameters the game will take.
(And its "length" parameter was out of date since the games currently
use "difficulty".)
2012-03-24 15:20:03 -07:00
Mike Mueller
d820ab1f1c Remove some useless checks.
Some solution length logic was previously moved to handle_message.  Some of
the code in _valid_solution became nonsensical (not broken, just weird).

Cleaned up.
2012-03-04 22:57:10 -08:00
Mike Mueller
b69967628a Change default dictionary and improve configurability.
Now defaults to the /usr/share/dict/american-english dictionary which is
probably found on many Linux systems today (avoiding the need to dig up a word
file on the interwebs).  On Debian/Ubuntu, you can 'apt-get install wamerican'.

Added a configurable regexp to filter the word list down to reasonable words.
Defaults to allow lowercase a-z only, therefore filtering out proper names,
hyphenations, contractions, and words with accented characters like "adiós".
(But hopefully still supporting non-English users by allowing this to be
changed.)
2012-03-04 13:46:46 -08:00
Mike Mueller
82e4665a82 Minor wording fix. 2012-03-03 14:42:58 -08:00
Mike Mueller
029ba10906 Oops, handle missing word file gracefully.
Apparently I backed out the previous change that handled this.
2012-03-03 14:41:00 -08:00
Mike Mueller
844723d28a Filter duplicate words in puzzles.
Was occasionally generating a puzzle foo > --- > --- > foo.  Oops.
2012-03-02 17:23:31 -08:00
Mike Mueller
a443d66473 Fix a performance issue in _find_solutions.
WordTwist successors can take you in circles (scare > stare > scare),
so check for this condition to avoid generating overly many potential
solutions.
2012-03-02 17:04:21 -08:00
Mike Mueller
17d1f91f8c Revise game difficulty settings.
Instead of taking lengths, the games now take easy|medium|hard|evil.
These values correspond to a range of puzzle lengths, word lengths, and
number of possible solutions.  I attempted to tune them to reasonable
values, but I could see them changing.

Also did a little more code clean-up.
2012-03-02 16:46:54 -08:00
Mike Mueller
b519259f54 Update copyright information. 2012-03-02 15:25:44 -08:00
Mike Mueller
51ca3bedfd Improve WordShrink's is_trivial definition.
No substrings should occur in any word of any solution (not just two
successive words).  This is really going to narrow down the set of puzzles,
hopefully it doesn't churn or get repetitive.
2012-02-24 20:18:36 -08:00
Mike Mueller
5e570f61c1 Refactor, optimize, clean-up.
The two games have a lot in common, so factored out a base class called
WordChain that implements most of the logic.  The game-specific behaviors
are implemented in the (now smaller) WordTwist and WordShrink classes.

Optimized to build a map of word relationships first and then derive all game
behavior from that map.  This could probably be improved even more, but for
the moment it is working nicely.
2012-02-24 19:17:05 -08:00
Mike Mueller
25136ae926 Fix a bug in error reporting. 2012-02-24 01:04:10 -08:00
Mike Mueller
e74ca803fe Restrict input snarfing a bit.
Only attempt to validate responses that look like words.
2012-02-24 00:33:14 -08:00
Mike Mueller
180252e826 Handle missing wordfile gracefully. 2012-02-24 03:21:45 -05:00
Mike Mueller
4afb3cbe3e Initial commit! 2012-02-24 00:10:33 -08:00