Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 17588, WordSearch

by Mark Shapiro Email: Anonymous

This is a simple multi-threaded word-search application (using Boggle rules)
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 6.0  to 6.0 937 downloads
Copyright: No significant restrictions

Size: 475,808 bytes
Updated on Mon, 18 Mar 2002 11:17:59 GMT
Originally uploaded on Fri, 01 Mar 2002 07:59:34 GMT
SHA1 Hash: 59FDCB26C3CC90D0A397FCEF8B1FFAF3966B26A6
MD5 Hash: 1531DBAB952AC01016C0FAFDDAA27B50

    Explore the files in this upload

This is a simple multi-threaded word-search application (using Boggle rules, so diagonals are allowed.) Up to 8 threads run simultaneously, scanning the 'board' for valid words. All threads use the same board and the same dictionary of words. Each thread is responsible for finding all words beginning at a given cell in the grid. Threads update their progress visually in two ways: (1) A progress bar for each active thread, which is updated synchronously with the main VCL thread. (2) Individual cells in the letter grid are re-drawn to indicate which thread is processing that cell as a root. clWindow cells are inactive. clGreen cells are finished. clYellow cells are in progress, with the thread number displayed above the letter. In "slow" mode, clRed cells indicate a word has been found.

The program can be compiled in one of two mode: Slow search, or normal search. This is controlled via a compiler directive in SearchThread.pas. In slow search mode, delays are added to make the visual update more noticable on fast systems, and a shortcut in the search algorithm is weakened. In normal search mode, there are no delays, and a shortcut in the search algorithm is used.

The application will run without any user intervention. When the scanning is complete, the user can click on a "Go Again!" button to generate a new board and a new search. The user can also control the size of the board, via a spinedit above the "Go Again!" button, or via a single, integer command line parameter. The dictionary is loaded automatically from a text file, 'words.txt', with one word per line.

A critical section is used to control the re-spawning of new threads as each thread completes. Re-drawing a grid cell, updating a progress bar, and adding a word to the found list, are done via calls to Synchronize. Simultaneous read access to the cell values and the dictionary is permitted.
The dictionary is stored in a 'trie' structure - a tree where each branch represents a given letter of the alphabet, and words are identified by the branches taken going down the tree from the root to a leaf. The depth of the trie is controlled by a MaxDepth property. Any words longer than the max depth are stored in a TStringList in a leaf node.

Update 3/18/2002 - Threads are now distributed evenly across multiple processors, if detected.

Contest entry forMultithreaded programming

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03