Producer/consumer Queue "trick"

Evan Simpson evan at tokenexchange.com
Mon Jan 17 18:42:33 CET 2005


I should clarify up front that I may have given an overblown sense of 
how long the producer thread typically takes to generate a board; It's 
usually a few tenths of a second, up to a few seconds for especially 
fecund boards.

My concern was that even a few seconds is long enough for fifty requests 
to get piled up, and I was experiencing mysterious breakdowns where 
Apache was suddenly totally clogged up and taking *minutes* to respond.

Jeremy Bowers wrote:
> Looking over your information about "how to play", my only guess is that
> you're generating all possible words that may exist in the board, at the
> time of board generation.

Yep.  I do this in order to minimize the cost of the most common request 
that WEBoggle handles, which is checking a submitted word to see whether 
it is a valid word on the board, a valid word not on the board, or an 
invalid word.  With the current code, this averages 1ms.

> But it also looks like you score once at the end (as you have to anyhow in
> order to cancel out words found by multiple people, according to the rules
> of Boggle). 

WEBoggle is a little different than regular Boggle, in that your score 
is the plain sum of the scores for all of the words that you found, with 
no cancellation.  I'm planning to add a "vs." feature eventually that 
will involve cancellation, but even then I'll retain the immediate 
feedback upon guessing a word.

In addition, many players enjoy seeing the list of "Words not found by 
anyone".

> (The other thing I can think of is that you are trying to verify that the
> board contains some minimal number of words, in which case I submit that
> boards with only 20-ish words is just part of the game :-) I've never sat
> down and really studied the Boggle dice, but I've always expected/hoped
> that there is at least one or two dice with all vowels; even so the odds
> of no vowels are small and easily algorithmically discarded. )

Believe it or not, before I added code to filter them out, I was 
generating enough boards with *zero* valid words on them to get complaints.

> Also, entirely separate plug, you may be interested in my XBLinJS project

Very nifty!  Well beyond my current needs, but good to know about.

Cheers,

Evan @ 4-am




More information about the Python-list mailing list