This is my assignment below. I don't even know how to start. I'm new to prolog. Can anyone provide any simple sample codes to start something off? Thanks alot.

One way of generating a crossword puzzle is

i) choose the number of rows and columns nad form an empty grid of that size

ii) choose a set of words that could appear in the puzzle, we call this dictionary iii)randomly choose a word from the dictionary and a direction either 'down" or "across"

iv) try to fit the chosen word into the currentgrid in the direction chosen

v) repeate form step iii) until the puzzle is complete

University assignment help also mentions

i) choose number of rows and columns e.g. choose a crossword grid with R Rows and C columns and write a prolog predicate that takes such a grid and prints it out as a crossword puzzle.

ii) representing a dictionary of allowed words as a simple list ,write a prolog predicate that writes out the list of words as a a column of words iii)start with simple non overlapping placement nad only move on to more sophisticated puzzles if you have time

Mihail121
—
2009-02-27T11:34:14Z —
#2

This is actually a quite simple assignment and I'm 100% sure you can already find functional solutions to it.

1) Just take some random numbers:

choose(X,Y) :- random(X), random(Y).

then unify your grid variable with ([], X, Y) to create an empty grid. Printing the grid is then trivial recursive traversal of the list.

2) Take some crossword dictionary from the net, there are millions of them and do

dict(D, [firstWord, secondWord, thirdWord,...]).

3) choose random index in D, that has not been already selected (maintain a list of selected words)

4) Use the same swapping strategy you had in your operating systems course: best-fit, first-fit, worst-fit or next-fit.

5) ...

Reedbeta
—
2009-02-27T17:13:20Z —
#3

Moreover, if you need help on a homework assignment, the appropriate thing to do is ask your classmates or your professor for help, not an internet forum.

bozovilla
—
2009-02-28T09:29:45Z —
#4

Sorry, I'm still clueless on how should I do it. What does it mean by:

then unify your grid variable with ([], X, Y) to create an empty grid. Printing the grid is then trivial recursive traversal of the list.

Possible to go throught with me step by step? I can't find any source else where. Even if i found, I dont understand them. I really appreciate any form help.