This is a simple little word boggle game for those of you that would like to see something interesting.

It is not very complex nor is it all to intelligent.


The game is that you basically select letters on a game board to try and make words, only letters that are above and to the side are accepted (basically all touching minus the angles).


The game uses a text reader to read an external text file with over 170k english/uk words loaded into it and also loads an external alphabet file that is designed around the most common letters, these files can both be tweaked to add words or letters that you feel would make the game more playable.


The graphics for the game are also included.

The game has some pretty neat stuff going on within it and is over 1.5k lines of code so i will refrain from posting all of it here.

you can get the game at
http://www.privacymaker.com/PWS/Word%20Boggle.zip

some snips from the code::

this snippet of code loads the external text file and allows me to read the text file into a string and split it into an array.
I then use a foreach loop to itterate through and determin if the word is a valid word.

if it is the answer is submitted.

public string answerSubmit(string answer)
{
 
//make lowercase for the list
answer = answer.ToLower();
//if the words list is empty, build it
string[] wordArray;
TextReader tr = new StreamReader("words.wld");
//read the entire stream
string WordsList = tr.ReadToEnd();
//close the stream
tr.Close();
//remove all return carriages and new lines
WordsList = WordsList.Replace("\r\n", " ");
//save the new wordslist to an array
wordArray = WordsList.Split(' ');
string strReturn = "true";
foreach(string word in wordArray)
{
if(word == answer)
{
scoreUpdate(word);
lstAnswers.Items.Add(word);
break;
}
}
ClearPanel();//renables all and removes highlights
txtAnswers.Text = "";
return strReturn;
}

this snippit assigns letters to already used text boxes.

when you form a word off of a set of cells the array that contains the list of currently selected cells is passed through this function along with the current answer. if the answer is in the list then it breaks apart the array that contains the selected boxes and assigns new letters based on them.

public string[] assignAlpha(string[] memoryArray, string answer)
  {
   //make lowercase for the list
   answer = answer.ToLower();
   //if the words list is empty, build it
   string[] wordArray;
   TextReader tr = new StreamReader("words.wld");
   //read the entire stream
   string WordsList = tr.ReadToEnd();
   //close the stream
   tr.Close();
   //remove all return carriages and new lines
   WordsList = WordsList.Replace("\r\n", " ");
   //save the new wordslist to an array
   wordArray = WordsList.Split(' ');
   string strReturn = "false";
   foreach(string word in wordArray)
   {
    if(word == answer)
    {
     strReturn = "true";
     break;
    }
   }
   if(strReturn == "true")
   {
    string[] strAlphaArray = onFormLoad();//retreive the alphabet
    string[] strMemArray = memoryArray;//assign the memory array
    Random rndCharacter = new Random();//create the random number
    TextBox[] txtBog = new TextBox[16];
    //assign all of the text boxes to an array of text boxes
    txtBog[0] = txtBog1;
    txtBog[1] = txtBog2;
    txtBog[2] = txtBog3;
    txtBog[3] = txtBog4;
    txtBog[4] = txtBog5;
    txtBog[5] = txtBog6;
    txtBog[6] = txtBog7;
    txtBog[7] = txtBog8;
    txtBog[8] = txtBog9;
    txtBog[9] = txtBog10;
    txtBog[10] = txtBog11;
    txtBog[11] = txtBog12;
    txtBog[12] = txtBog13;
    txtBog[13] = txtBog14;
    txtBog[14] = txtBog15;
    txtBog[15] = txtBog16;
    //count through memory array
    int maxCount = strMemArray.Length-1;
    int count = 0;
    int rndMax = strAlphaArray.Length -1;
    while(count >= 0 && count <= maxCount)
    {
     if(strMemArray[count] == null)
     {
      break;
     }
     //retrieve the number from the text
     //create new array
     string[] strHolder = strMemArray[count].Split('g');
     int intCurrentBog = Int32.Parse(strHolder[1]) - 1;
     txtBog[intCurrentBog].Text = strAlphaArray[rndCharacter.Next(0, rndMax)];
     count++;
    }
   }

Recommended Answers

All 3 Replies

you load the whole file and parse through it every time someone submits a word?
wouldn't it be better to load the list once when the program starts up?

you load the whole file and parse through it every time someone submits a word?
wouldn't it be better to load the list once when the program starts up?

im still working on some things, and smarter algorithms to handle letter assignments.


though it may seem like a lot though, to load it each time, i have noticed no impact on game performance :D

Member Avatar for iamthwee

im still working on some things, and smarter algorithms to handle letter assignments.


though it may seem like a lot though, to load it each time, i have noticed no impact on game performance :D

It's ok. Pretty GUI. But where's the auto-solving mechanism. Once you start programming that things become interesting?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.