Need help with Prolog assignment

74f4a7c1a82b02c71616f3a29f9361cc
0
bozovilla 101 Feb 27, 2009 at 08:47

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

3 Replies

Please log in or register to post a reply.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Feb 27, 2009 at 11:34

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) …

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Feb 27, 2009 at 17:13

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.

74f4a7c1a82b02c71616f3a29f9361cc
0
bozovilla 101 Feb 28, 2009 at 09:29

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.