Thanks for the reply Bart,

Yes, I have indeed gone through the process you described in my Word Search
game. But things are a little different for a cross word puzzle.

1) Words can only be placed either vertical (top to bottom) or horizontal
(left to right). We are talking about English only words.
2) To make a proper crossword puzzle every word MUST cross at least one
other word. To be even more specific all the words need to be "tied"
together, meaning no floater group(s) of word(s).
3) ANY adjacent letters must build a word.

The brute force method you have stated could potential break after only a
few words.

One idea I had was to do the following

1) Sort the word list by the longest to the shortest word (since longer
words will be harder to place)
2) Select word to be placed
3) Enter the first word at a random location
4) Select the next word to be placed
5) Recurse backwards from the end of the word and do compares against
letters the placed word and the next word.
6) If a match is found, try and place it.
7) If the word exceeds the bounds of the board then skip this matching
location
8) If no matching location is found which allows the word to me placed, then
skip it (actually goes to a holding array)
9) Go to 4

The interesting thing about this approach is if the recursion comes across
another crossing word, it should "run" down that "branch of the board as
well.

I am still mapping out the logic for this method, but was hoping that
someone here had tangible knowledge or could point me to some.

Again, any help is welcome.

Charles P.



On 6/19/06, Bart Wttewaall <[EMAIL PROTECTED]> wrote:

Hi Charles,

I don't know how others would take a swing at this, but this is what I
would do:

First, define your boundaries. You're making a crossword puzzle, so
that would be a matrix with a specified width and height. Next up
you'll want to add words. Grab your nearest dictionairy and pounce in
those characters. It might be best to store those in a library-class
of some sort. Or perhaps an external txt- or xml-file. Then comes the
tricky part: write the algorithm.

I guess the following steps should be implemented in the algorithm:
1. choose a word
2. set some variable to 'horizontal' or 'vertical', perhaps even
'diagonal'
3. try fit the characters in some empty place in the matrix.
4. if it fits (maybe overlapping an alrady placed word), hurray!
    - if not, continue until you've tried all spaces, then dump it and
get another word.
5. goto 1

Now if you're not happy with the result, run the application a few
hundred times. Either that or you might want to add a little more
magic to the algorithm and shuffle/sort the words to spaces where the
overlap other words the most.

I hope this gives you some ideas.
Good luck!

Bart

2006/6/19, Charles Parcell <[EMAIL PROTECTED]>:
> Can anyone point me to any links or give me some pointers on building a
> programmatically built crossword puzzle board?  I don't mean just
building
> squares, but rather taking a word list and building intersecting words.
>
> I have already build a word search game which is similar but there are
some
> additional rules which a cross word puzzle uses and is making it a much
> harder task than original thought. For instance words can only be placed
in
> two directions rather than eight, In addition, words which are placed
> horizontally or vertically next to one another must also make words in
the
> apposing direction.
>
> So, any help would be greatly appreciated!
>
> Charles P.
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to