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
Need help with Prolog assignment
Started by bozovilla, Feb 27 2009 08:47 AM
3 replies to this topic
#1
Posted 27 February 2009 - 08:47 AM
#2
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) ...
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
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
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.
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


This topic is locked









