Help With Making "Boggle" Game

OhioJuggalo
06-21-2004, 02:01 PM
I'm not sure if any of you are familiar with this game but I'll try to explain it. There's 16 dice with 6 sides and one letter per side. They fit inot this tray just to help keep em together in a square shape. You put the cover over that and shake the dice up to randomize everything, then you begin the game. The object of the game is to find words in the dice. The letters have to be touching one another.

What I want to do is get rid of the physical dice and shaking and have the computer do it for me, so I and any other players can just look off the computer screen and play. My problem is I have been out of school for almost a month and forgot how to do loops. I need to do this to make sure that each die only shows up once. If anyone can help that would be great.

Iceplug
06-21-2004, 02:04 PM
So, you just want to have random letters show up in some labels?
Well, to generate a random uppercase letter , you can just use a System.Random to create some random numbers from 65 to 90 (65 and 90 being the ascii codes for A and Z).
Then, after you have created the random number, use System.Convert.ToChar to turn this number into a character, and then display it into a label. :)

OhioJuggalo
06-21-2004, 03:13 PM
So, you just want to have random letters show up in some labels?
Well, to generate a random uppercase letter , you can just use a System.Random to create some random numbers from 65 to 90 (65 and 90 being the ascii codes for A and Z).
Then, after you have created the random number, use System.Convert.ToChar to turn this number into a character, and then display it into a label. :)

Well I want to have it exactly like the game where each die has different letters, instead of just taking random letters and putting them on labels. I want it to sort of pick where each die goes, then pick which side faces up. It's just a little project I'm doing to keep my skills sharp over the summer, so when I go back to school I won't have to relearn everything.

Iceplug
06-22-2004, 10:47 AM
Well, it's not going to make a noticeable difference, unless you decide what letters you want on the dice.

One way might involve you declaring 16 arrays of strings or 16 arrays of characters, (which could be in a multidimensional array,)
loading each element of the array with a random character, or a predefined array that you want to use.
(initialize arrays by using the {}, as in New Char() {"A"c, "E"c, "I"c, "O"c, "U"c} )

Then, I guess you'll want to keep a die from appearing twice. In that case, you may need to declare an array of 16 booleans to indicate if you have drawn the die that matches this number.
(10 would mean that you have already picked a character from the tenth die.)

Then, use System.Random to pick a random die (from 0 to 15), check if the boolean that matches this die is false. If it is false, set it to true and immediately create another random number to draw a number from this die. Assign the random string or character from this element to the label.

Generating the random numbers and then checking the boolean would have to be done in a Do While loop, because you are going to Do something While you keep picking a die that has already been used. So, after you have exited the Do Loop,
(in the Do loop, you Do generate random dice index numbers)
you will have a number for a die that has not been used.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum