Search Unity

Need urgent help with word search game code (C#)

Discussion in 'Scripting' started by Maple-Senpai, Jun 19, 2020.

  1. Maple-Senpai

    Maple-Senpai

    Joined:
    Oct 2, 2018
    Posts:
    14
    Hi guys, I need help with creating a word search game.

    Let me explain somethings.

    - Current board is 8x8 matrix so 64 total letters. Made with a panel with grid layout and a bunch of empty buttons.
    - Already able to generate random letters on each buttons.
    - Already able to fetch a random word from my dictionary file.

    The problem is I completely have no idea how am I supposed put the words in a random position in the field horizontally, vertically, and diagonally without going out of the field / the word being cut-off.

    This is an example of what I'm trying to do:



    Hope you guys can help me out with the code. Cheers!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Really quick off the top of my head, this is how I might do it:

    First part is easy:
    1. Pick a word at random
    2. Pick a direction at random
    Next part is a bit harder:

    Given the word and direction you chose, pick a legal spot to start the word:
    1. Find all legal spots to start the word (A spot is legal if the word wouldn't go out of bounds based on its length and direction. It also can't conflict with any existing letters on the board if the word were to be placed there)
    2. Pick one of the legal spots at random
    3. If there are no legal spots, pick a different direction
    4. If there are still no legal spots, pick a different word
    Keep going until you have some predetermined number of words on the board. Then fill the empty slots with random letters.
     
  3. Maple-Senpai

    Maple-Senpai

    Joined:
    Oct 2, 2018
    Posts:
    14
    Thanks for the help but I don't think it would help me out that much. I can get the gist of the logic behind it the problem is the code since I'm not completely sure how I should code it.
     
  4. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    Does that mean you are asking us to code it for you? I guess most people here have NOT done such thing yet. But they would sit down and try to achieve it. Thats the meaning of "developing". Not taking a premade solution and paste it in. But to develop it. If you don't want to do it you should look for another activity.
    It is fine to ask for direction, for insight, for opinions, for advice and especially for help with concrete problems. But just saying "someone give me code" ist lame and won't get you far.
     
    profitdefiant likes this.