Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top