home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boldly Go Collection
/
version40.iso
/
TS
/
17A
/
ANGRY.ZIP
/
ANGRY.DOC
< prev
next >
Wrap
Text File
|
1992-07-30
|
5KB
|
129 lines
Article 337 of rec.puzzles.crosswords:
Path: wet!netcomsv!apple!agate!ames!olivea!uunet!munnari.oz.au!manuel!nimbus!tridge
From: tridge@nimbus.anu.edu.au (Andrew Tridgell)
Newsgroups: rec.puzzles.crosswords
Subject: angry: a cross word builder (version 1.0)
Message-ID: <1992Jul28.002644.11322@newshost.anu.edu.au>
Date: 28 Jul 92 00:26:44 GMT
Sender: news@newshost.anu.edu.au
Organization: Australian National University, Canberra
Lines: 908
Originator: tridge@nimbus
I got quite a few replies from people who said that they would like a
copy of my crossword builder, so I'm now posting version 1.0. At this
stage I'm just posting source code. The main reason for this is that
the replies I got raised several queries that showed my ignorance of
crossword building. Once these are resolved (if ever) then I'll have
to organise a post of an IBM PC binary.
Before I go on I should explain that the code was produced as part of
a race. My wife tried to produce the crossword by hand (with the help
of a windows based crossword program) and I tried to write code to do
it automatically. I won, which shows the code was not designed to be
"model programming". It helped that my wife is hopeless with
crosswords.
Here are some of the questions that were raised along with some other
limitations of the code:
Q) Does it produce rotationally symmetric crosswords?
A) No. I didn't even know crosswords were supposed to be rotationally
symmetric. Why are they? I looked a few up in the paper and found that
were indeed symmetric, which I had never noticed before.
Q) Can you input your own grid?
A) No. It probably wouldn't be all that hard to re-code it to do this
but I suspect that with a short list of words you wouldn't get a high
success rate. If you fed it the whole dictionary then there wouldn't
be a problem (I think).
Q) Can it produce crosswords with no black squares? (such as 6x6 problem)
A) No. It can ONLY produce crosswords where you can place the words
one at a time so that after each word the crossword is "legal". This
precludes a whole host of possible crosswords.
Q) What is the .pzl format?
A) It's the format used by the Microsoft windows shareware program
"xword" - available from a friendly ftp site near you. Angry also
saves the puzzles in plain text, with spaces for black squares. I put
in the .pzl format so you could get pretty printouts.
Q) How does it work?
A) Brute force, with a bit of smarts built in. In concept it tries all
words in all positions then picks the word with the highest "score",
places that word then tries again. Doing this with a dictionary would
take years of course, so I then define a "depth" so the user can
compromise between speed and better crosswords. If
depth==number_of_words then it is brute force. If depth is N then do this
1. pick N words at random
2. find the best position for each word (highest score - see below)
3. choose randomly from among highest scoring words
4. place word
5. if any words left go to 1.
6. remove any words not connected to other words
7. goto 1
FINAL. If depth > 10 then do a brute force final effort.
SCORE:
+35 for connection not at the end of a word
+30 for connection at end of a word
+9 for not lying along an edge
+1 for being oriented differently to the last word
(these are VERY ad hoc)
Angry gives up when it can't place any more words. It then tries to
produce another, and prints it if it is better then the first. These
keeps going till you stop the program. (press ^C under unix - press
and key under DOS)
Whenever a better xword is found it is written both to best.doc and
best.pzl.
Usage: angry Xsize Ysize WordList [depth]
Xsize: number of squares across
Ysize: number of squares down
WordList: file containing a column of words
depth: depth of search. This defaults to 1 (fastest). I recommend
about 5 for normal use. If you put in 11 or high then you will
activate a brute force search at the end of the build (slow).
Q) How fast is it?
A) That depends on the depth. With a depth of 1 it produces crosswords
every few seconds on a Sun4. On a PC it may take 30 seconds to get a
crossword. The time will increase as Xsize*Ysize. It will not increase
with an increase in wordlist length (not by much anyway) unless
depth>10 in which case the final stage goes linearly with the number
of words.
Q) How big can it get?
A) The only limitation is the machines memory. Also the words can't
be longer than 1000 letters - which I don't think will be a problem
(at least in English!)
OK enought drivel for now - here is the source. Remember - it cost
nothing.