RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 2915 | Replies: 3
Reply
Join Date: Apr 2004
Location: Tracy
Posts: 744
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Rep Power: 7
Solved Threads: 32
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Word Boggle Game Complete

  #1  
Jul 31st, 2006
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++;
    }
   }
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!

sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 482
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Word Boggle Game Complete

  #2  
Aug 1st, 2006
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?
Reply With Quote  
Join Date: Apr 2004
Location: Tracy
Posts: 744
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Rep Power: 7
Solved Threads: 32
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: Word Boggle Game Complete

  #3  
Aug 1st, 2006
Originally Posted by campkev
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
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!

sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
Reply With Quote  
Join Date: Aug 2005
Posts: 4,832
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 324
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Word Boggle Game Complete

  #4  
Aug 4th, 2006
Originally Posted by Killer_Typo
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

It's ok. Pretty GUI. But where's the auto-solving mechanism. Once you start programming that things become interesting?
... the hat of 'is this a cat in a hat?'
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:46 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC