|
-
Dec 17th, 2001, 02:21 PM
#1
Help the poor little children ;(
Ok, I am trying to write a program that will print out a simple wordsearch (you know, a grid of random letters with several themed words hidden in it). I'd really like it finished before Christmas, so does anyone have an algorithm for placing the letters on the grid? A 2-dimensional character array would be fine for the grid, I have the printing part done and dusted.
The list of words is already known to the program at runtime, the words will be no longer than 20 characters, and the grid will be about 25 grid squares in width and height.
I would like it to have words horizontally and vertically, diagonally would be brilliant, but not neccesary.
I'm not going to have much time to work on this myself which is why I'm asking here, normally I'd struggle through it myself 
Its for a school by the way, which explains the title!
-
Dec 21st, 2001, 02:07 AM
#2
Dazed Member
That would be a hard one on my opinion. Implementing a char array would be tough. Have you tried it yet?
-
Dec 21st, 2001, 02:25 PM
#3
A 2d char array is dead easy.
Dim Grid(1 to 20,1 to 20) As String * 1
Its just the algorithm to arrange the words on the puzzle that's giving me a bit of trouble.
-
Dec 21st, 2001, 06:21 PM
#4
PowerPoster
Hi woss
I dont think that the code will be so simple for that espec for someone to throw together in a day or two but i found this for ya. I havent downloaded it so cant vouch for it. but give it a go. I just searched google for "wordsearch game code"
regards
Stuart
http://www.freevbcode.com/ShowCode.Asp?ID=1869
-
Dec 22nd, 2001, 12:57 PM
#5
Cool, thanks for that, I'll have a look in a moment.
My current theory is to let the user pre-define the size of the grid and then use brute force to fit the words in
Starting at a random square, check each of the 8 normal directions (up, down, left, right, diagonal up-left etc...) to see if the word will fit without disrupting any other words, then move on to the next word and repeat.
The problem with that it that it may take a long time on a PalmOS device (which is the other platform I am porting to), but it would be OK for VB, because its much faster at that sort of thing.
I'll check out this code though. Thanks.
-
Dec 23rd, 2001, 04:58 PM
#6
Dazed Member
A 2d char array is dead easy.
I know that. I ment arranging the words.
-
Dec 24th, 2001, 11:06 AM
#7
Yeah, suuuure you did right.
Heh heh 
I've got it sussed out now. Thanks for your replies.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|