Jump to content


Need help with Prolog assignment


3 replies to this topic

#1 bozovilla

    New Member

  • Members
  • Pip
  • 2 posts

Posted 27 February 2009 - 08:47 AM

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

#2 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 27 February 2009 - 11:34 AM

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

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 5306 posts
  • LocationBellevue, WA

Posted 27 February 2009 - 05:13 PM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 bozovilla

    New Member

  • Members
  • Pip
  • 2 posts

Posted 28 February 2009 - 09:29 AM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users