0

Hello everyone, so I am working on a word puzzle generator. I have the bulk of it completed-but I am confused on how to proceed from one part. The puzzle must be a user defined size, but the words must then be outputted to a grid in either diaganol, up and down, or left and right (randomly of course), and then the rest of the grid has to be filled with random characters. I am not exactly sure how to output my words in up/down/diagonal format, and then fill the rest of the grid with random characters. I created a random character script, but I don't know how to go from here

void randomChar (char names[MAX][LEN], int num)
{
	int i = 0;
	int j = 0;
	char arr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	for ( i = 0; i < num; i++)
	{
		j = rand() %20;
		while (j >= 0)
		{
			names[i][j] = arr[rand() % 36];
			j--;
		}
	}
}

Any help would be greatly appreciated.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by WaltP
0

Define a value for each of the 8 directions:
1-up
2-down
3-left
4-right
5-up/left
6-up/right
7-down/left
8-down/right

Then get a random number to decide which direction to choose.
Randomly choose a starting location and see if the word will fit
1) enough space in the chosen direction
2) any letters already set must not be changed.
For #2 you may have to modify the starting location to make the word fit.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.