Click here to Skip to main content
15,869,940 members
Articles / Desktop Programming / Windows Forms
Article

Lingo - A Simple Word Game in C#

Rate me:
Please Sign up or sign in to vote.
4.76/5 (13 votes)
22 Aug 2007CPOL7 min read 90.9K   6.6K   39   9
Lingo is a simple five-letter word game in C#. It is based on the popular TV game show of the same name. The idea of the game is simple: you are given five chances to guess a five letter word, given two letters in the word initially.

Introduction

Screenshot - Lingo.pngingo is a simple word game that is based on the popular TV game show format of the same name. The idea of the game is to give a player five chances to guess a five letter word, given two letters in the word initially. Along the way, for every guess made, if a letter in the guess falls in the same place as that in the original word, or if a letter is present in the original word but not in the same position in the guess word, the player will be apprised.

Gameplay

Lingo has the following gameplay elements:

  • Five chances to guess a five letter word
  • Two letters will be marked initially
  • Correct letters and letters present in the original word but not in the correct position will be highlighted
  • Checks if the player provides a valid word (if the word is not valid, the player loses a chance)
  • Scoring is based on how many chances are required to guess a word. 5 points awarded for guessing it right the first time, 1 point for guessing it at the last attempt
  • Provides a mechanism to select the difficulty level of the game. Three levels are present (easy, medium and hard). Each level has its own exclusive set of words, and combined, the dictionary of five letter words is over 12,000 words strong. Most of the words are really obscure, but it's a good list nonetheless.
  • Provides a mechanism to have a much needed 5-minute break from anything that requires you to have a 5-minute break. :)

Here's how the screen will look like on starting up Lingo:

Screenshot - Screen_New.jpg

The Edition Black version looks like below.

Screenshot - Edition_Black.jpg

You are provided with two letters (in blue) of a five letter that you have to figure out in five or less guesses. For every guess you make, if a letter falls in the exact position, or if a letter is present in the word but not in the correct position, you will be notified. If the program feels you are having difficulty with a word, it would give you one more bonus letter from the original word (marked in orange at the top, first screen).

A sample course of play would look like:

Screenshot - Screen_New_InGame.jpg

To start with, the game provides two letters 'n' and 'o'. We have to figure out the word in at most five attempts. Our first attempt was 'notes', and 'n', 'o' and 't' highlighted in red indicates they are not in the right position, and 's' in green indicates it's in the correct position. If an invalid word ('sugam') is entered, you effectively miss a chance, and the letters will not be processed.

The game allows you to control the difficulty level. Right-clicking on the form gives you the option to set your difficulty level as either Easy, Medium or Difficult. On choosing a difficulty level, words you have to guess in the game will be of that difficulty level.

Screenshot - Screen_New_Options.jpg

The game uses a word list of over 12,000 words. I have not been able to verify all the words in the list, as I have collected it from various sources over a span of time and just combined them all. (Googling a lot helped me a lot!).

After the player is finished off with a word, a link appears near the bottom of the form, which on clicking should take you to the WordNet site, and use their online application to get a definition for the word. Not all words may get a definition, as the word list file used in Lingo is very large (most of the words are too obscure).

So why not go ahead and download the source and the executable, and try this little piece?

You can download the executables separately. There is a basic version, and the Edition Black version.

Using the Code

The entire solution and source code files are present in the zip file. The solution file was created in Visual Studio 2008 Orcas Beta 2. If you are not able to open the same, you may have to create a new project in your Visual Studio version and add all the files under the Lingo folder to it. The icons and the word list file (Lingo\Words\Lingo.txt) need to be set as embedded as resources into the assembly. It was compiled with .NET 2.0.

I am not going to give any description or snippets of the code here; it has been fairly documented and should be easy to follow. [After all, it's just a simple game. :)]

UPDATE: I have added some fading effects to the game. I use labels on the form quite a lot, and extended the Label class to create the FadeLabel class. This new label is capable of transitioning its fore and back colors. Check it out.

UPDATE (22 AUG 2007): I have put up the Edition Black version of the game for download. No source is available at the moment, as it's still a work in progress. I'll put it up as soon as I complete it. On the technical front, I used images extensively for this version (those colorful letters in the screenshot), and overall sports a black theme. It still needs a bit of polishing UI wise, but the game should be playable at any rate.

Points of Interest

The only bit of real thinking I had to do in writing this game was conforming to the following requirement I made:

Assume the word to guess is "lingo". And assume "oodle" is a word you suggested.
On processing your guess, the following should be output

  • Correct Letters: none
  • Wrong Position Letters: 'o' at first position, 'l' at fourth position

Note that the second 'o' should not be mentioned as a letter in the wrong position, as we already have reported an 'o' prior to that. So if you enter 'ooooo', only the last letter should be highlighted as it is in the correct position, and if you enter 'ooooz', only the first letter should be highlighted, and not the other 'o's. Hope you get the idea.

At first glance, this seems straightforward to achieve (and eventually it is). But I do suggest that before you take a look at the code to see how I solved it, please try to come up with an algorithm on your own (it'll take hardly a few minutes of your time if you care to do so, and if you like this sort of thing it'll be interesting). When you have one ready, compare with the solution I have implemented. If yours is simpler, let me know too.

History and Updates

  • 17 AUG 2007: Initial release
  • 18 AUG 2007: Minor enhancements and new features added
    • [+] If the program detects you are having difficulty with a word, it will give you one more bonus letter so that you can solve the word
    • [+] Includes a bonus score counter, which gets added to your base score when you get a word. The idea being the faster you guess a word, the better your score
    • [~] The UI has undergone a bit of tweaking to make it better looking
    • [~] Modified the way the initial two random letters are chosen
  • 19 AUG 2007: New features
    • [+] Added fading labels. Refer to the FadeLabel class in the source file for more details
    • [+] Created the main Lingo icon for the game
  • 22 AUG 2007: Edition Black is released
    • [+] A new version of the game. Enhanced the UI quite a bit. This version sports a black theme, and colorful buttons for the letters
    • [+] Created a lot of new icons for the game, mostly used in Edition Black

Credits

The icons in the application are from the Silk Icon Set[^] available for free from FamFamFam.com[^]. The icon set contains 1000 16x16 icons. There are other icon sets available on that site. Do have a look.

Icons not used from the above source were made by me using a combination of Inkscape, Paint.NET and GIMP.

Having The Last Word

So much for that. There are many enhancements that can be made to the existing application, starting with a bit of code refactoring to enhancing the UI, adding timers, music, graphics and effects, multiplayer? (hmmm)... Feel free to put your ideas into it.

In the end, if you are into word games, I do hope Lingo gets your attention for a fun 5 minutes.
Enjoy.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
I work as a Technology Lead for an IT services company based in India.

Passions include programming methodologies, compiler theory, cartooning and calligraphy.

Comments and Discussions

 
GeneralNice Game Pin
Mushtaque Nizamani23-Aug-07 19:27
Mushtaque Nizamani23-Aug-07 19:27 
GeneralRe: Nice Game Pin
Benzi K. Ahamed27-Aug-07 22:21
Benzi K. Ahamed27-Aug-07 22:21 
GeneralCant run the game Pin
thomasraku20-Aug-07 7:59
thomasraku20-Aug-07 7:59 
GeneralRe: Cant run the game Pin
Benzi K. Ahamed20-Aug-07 12:04
Benzi K. Ahamed20-Aug-07 12:04 
GeneralRe: Cant run the game Pin
thomasraku20-Aug-07 18:33
thomasraku20-Aug-07 18:33 
AnswerRe: Cant run the game Pin
98 Z2821-Aug-07 13:56
98 Z2821-Aug-07 13:56 
GeneralSmall suggestion Pin
SHaroz17-Aug-07 21:57
SHaroz17-Aug-07 21:57 
GeneralRe: Small suggestion Pin
Benzi K. Ahamed17-Aug-07 22:22
Benzi K. Ahamed17-Aug-07 22:22 
GeneralRe: Small suggestion Pin
SHaroz17-Aug-07 23:12
SHaroz17-Aug-07 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.