I created this application a couple of months ago: http://www.mondofacto.com/word-tools/scrabble-solver.html
The application allows the user to enter a set of letters that they specify, and returns an echo of which real words they can use, as well as what score they will receive to use these letters.
Basically, I want to expand the application so that users can enter "empty tiles" - one that can be qualified as any of the 26 letters of the alphabet, as well as repeat words that are valid.
Below is a screenshot of the database structure.
http:
You may need to copy this ^ file to your browser.
The query executed by this data when the user enters, for example, "aardvark", is as follows:
SELECT * FROM scrabble WHERE a <= 3 AND b <= 0 AND c <= 0 AND d <= 1 AND e <= 0 AND f <= 0 AND g <= 0 AND h <= 0 AND i <= 0 AND j <= 0 AND k <= 1 AND l <= 0 AND m <= 0 AND n <= 0 AND o <= 0 AND p <= 0 AND q <= 0 AND r <= 2 AND s <= 0 AND t <= 0 AND u <= 0 AND v <= 1 AND w <= 0 AND x <= 0 AND y <= 0 AND z <= 0 AND length <= 8 ORDER BY scrabble DESC
If you want to see the results, enter the word in the link that I posted at the top.
Right
So does anyone know how to do this? I started with the following code, which adds each character of the alphabet to the end of a line entered by the user if they put spaces (spaces are empty tiles).
if (preg_match('/[\s]/', $string)) { $wild_string = $string; foreach (range('a','z') as $i) { $wild_string = $string; $wild_string .= $i; }
The $ wild_string variable is such that each letter is added to the on loop. Dropping it to the start line in each loop, it stops the code from adding all 26 letters to the entered line.
I hope someone can help and sorry if I waffle :)
Andy.