0

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?

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
roflwaffle
  • 29,590
  • 21
  • 71
  • 94

3 Answers3

2

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.

Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
2

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.

Steven Oxley
  • 6,563
  • 6
  • 43
  • 55
0

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.

Community
  • 1
  • 1
Paolo Bergantino
  • 480,997
  • 81
  • 517
  • 436