1. #1
    High Overlord Nemean's Avatar
    Join Date
    Jun 2010
    Auburn, Al

    Boggle word solver

    I need some help fixing this problem with the code i made. It uses depth first search to go through the matrix to find all possible words in a boggle board. However it when i run it nothing comes out even though it goes through everything. Any tips here is the code.

    private void wordSearch(String prefix, int row, int col) 
     // checks to see if it is out of bounds
        if (row < 0 || col < 0 || row >= size || col >= size)
    // see if the letter has been used yet
        if (checkTable[row][col]) 
      // the letter has been visited
          checkTable[row][col] = true;
     //is the prefix in the dictionary  
           prefix = prefix + board.getLetter(row, col); 
           if (dictionary.contains(prefix) && prefix.length() > 2)
    // looks at all adjacent 
        for (int i = -1; i <= 1; i++)
            for (int j = -1; j <= 1; j++)
               wordSearch(prefix, row + i, col + j);
        checkTable[row][col] = false;
    checkTable is an x by x boolean table initialized to be false.
    dictionary.contains checks to see if the word is in the dictionary.

    if you need any more information let me know.
    Last edited by Nemean; 2012-11-11 at 08:40 PM.
    CPU: Intel i5-2500k MB: ASRock Z77 Extreme
    GPU: Asus HD 7850 RAM: Mushkin Blackline 8GB
    HDD: WD Caviar Black 1TB PSU: OCZ 500W CASE: Cooler Master HAF 922

  2. #2
    Super Moderator Darsithis's Avatar
    Join Date
    Jan 2011
    There is no need to have two threads:

    For Moderation Concerns, please contact a Global:
    TzivaDarsithisRadux SimcaElysiaZaelsinoxskarmaArlee

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts