Reputation: 30666
For a project I am considering building a Boggle type game in PHP. All of the solutions I have seen online have used some sort of tree or hash based approach.
Are there any similar data structures built into PHP? Any advice on how to handle figuring out what words are present on a current board of letters?
Upvotes: 0
Views: 1116
Reputation: 488714
You might want to check out this question. It provides a lot of solutions on how to program a boggle solver. Most are in Python, but I also posted there a PHP solution. It is kind of slow (~2 seconds to calculate everything) but it should be a good starting point.
Upvotes: 0
Reputation: 6724
PHP does have hash data structures built into the language. They are generally called associative arrays, though.
This website has a very brief explanation of them.
Upvotes: 2
Reputation: 23321
Do you really need to figure out what words are available with the letters?
A simple method would be to simply let the user guess a word, check that the correct letters exist on the board, then check that the word is a real word.
This would be simple, however you would not be able to tell the user how many words are remaining.
Upvotes: 2