For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2004 > Generating crossword frameworks









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Generating crossword frameworks
Nameless

2004-04-14, 12:31 am

"reader" wrote in message
news:a9Zec.5489$Fo4.66948@typhoon.sonic.net...
>. . .
> When I visualize a crossword puzzle, I see a matrix in which
> some cells are blacked out, so that's how I would represent it.
>
> Accordingly, in PDC Prolog, I might say
>
> domains
> TEMPLATE = ROW*
> ROW = CELL*
> CELL = is(CHAR) ; nil
>
> and a puzzle layout like
>
> _ _ _ _ x x
> _ x x x x _
> _ _ _ _ _ _
> _ x _ x x _
> _ x _ _ _ x
> x x x _ x x
> _ _ _ _ _ x
>
> would be represented by
>
> predicates
> puzzle(TEMPLATE)
> clauses
> puzzle([
> [_,_,_,_,nil,nil],
> [_,nil,nil,nil,nil,_],
> [_,_,_,_,_,_],
> [_,nil,_,nil,nil,_],
> [_,nil,_,_,_,nil],
> [nil,nil,nil,_,nil,nil],
> [_,_,_,_,_,nil]
> ]).
>. . .


A more interesting challenge would be how to efficiently
generate a 'random' crossword framework (pattern) given a
number of constraints such as grid/matrix size, minimum and
maximum site (word) length, and no isolated sites (there
exists a path from any one site to another).

For those readers who are game enough to try, here's a
concrete example problem:

Write a Prolog programme which will generate a 'random'
crossword framework given the following constraints:

- Matrix: 10x10
- Min. site length: 2
- Max. site length: 6
- At least one site shall be max. site length
- No isolated sites

The programme should facilitate use of other values than
the first three given above, i.e. the programme should
be generic.

It would be interesting to see and discuss solutions here.

--
Mail sent to this email address is automatically deleted
(unread) on the server. Send replies to the newsgroup.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com