We have a programming project due in which we are supposed to create a boggle board. We are supposed to read in a file with the boggle dice (basically just sixteen lines of six random letters), then ask the user if they want to shake the board. If they say yes, the board shuffles 250 times by choosing two random board positions and swapping their position; doing this 250 times. Once the position has been swapped, a side (one of the six letters) must randomly appear "face up" (i.e. the side that actually appears on the board). I don't want any code; i haven't even started coding the program yet. I just wanted some advice on the best way to approach this program. I know I'll need a function to read the dice from the file and place it in an array. I'm a little confused as to whether or not I just need one array to hold the "dice", or do I need sixteen different arrays; one for each die (since each die has to act separately)? I also know I'll need a function to output to the screen, and a function to shuffle the board. Thanks for your help.
Recommended Answers
Jump to PostI'd put it in a 2D array. That way you can iterate over the rows and pick a random die face from each to face "up". Making your swaps with 16 different arrays could turn into a nightmare. I don't have too much to add besides that. Sounds like a …
Jump to Postrand() % 7 is going to get you numbers between 0 and 6 which will overstep the bounds of your array by 1 if a 6 is pulled.
I'm confused why you broke up the loop like you did?
Jump to Postrand() % 7 is going to get you numbers between 0 and 6 which will overstep the bounds of your array by 1 if a 6 is pulled.
I'm confused why you broke up the loop like you did?
That is correct, if you use rand() % 6 + 1 …
All 11 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.