Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24
  1. #11
    Join Date
    Jan 2007
    Location
    Kansas City, KS
    Posts
    709
    Hey Liz! I guess that makes some sense. I'm gonna have to use is more often in order to get a hang of it.

    Next Question:
    Going back to my early days playing King's Quest and Space Quest (the earlier versions that required you to type in questions/actions) I noticed that you could rephrase the same questions or actions and get the same result. For example:

    -pickup item = pickup the item = grab item = grab the item etc.
    -move west = go west = walk west

    So my question is: How do you make it to where a program will give you the same result regardless if you use move, go, or walk? and how can I alter the code to where you can type in "move to west" and get the same result as if you would've typed in "move west"?

    This is the code I have for right now (I hope it's the right one):
    Code:
            public static string ExtractCommand(string line)
            {
                int index = line.IndexOf(' ');
                if (index == -1)
                    return line;
                else
                    return line.Substring(0, index);
            }
    
            public static string ExtractArguments(string line)
            {
                int index = line.IndexOf(' ');
                if (index == -1)
                    return "";
                else
                    return line.Substring(index + 1, line.Length - index - 1);
            }
    
            public static string WordWrap(string text, int bufferWidth)
            {
                return text;
            }
    Rico - VFX Artist in training
    USA: Kansas: Kansas City = (GMT -6:00) (CST)

  2. #12
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Given that you personally know words like talk, tell, say, whisper are all kinda ways of speaking.. you need to look at the bit where you take your command and work out what to do with it, and change it so that it also knows..
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  3. #13
    Join Date
    Jan 2007
    Location
    Kansas City, KS
    Posts
    709
    Hmmm well that's not helping much. Maybe I'm not understanding. I don't want to simply change it but make it to where I can type in multiple action and get the same result. Like the example I gave.... I want to be able to type in all of this:

    -pickup the blue ball
    -pickup blue ball
    -take blue ball
    -grab the blue ball
    -etc.

    ... and have it all mean the same thing. In the end, regardless of what I type in I want it to pick up the blue ball. So, how can I make it to where I can use pickup, take or grab? (so in the end I can use any of them instead of restricting myself to one).
    Rico - VFX Artist in training
    USA: Kansas: Kansas City = (GMT -6:00) (CST)

  4. #14
    Join Date
    Jan 2007
    Posts
    640
    Well... how I would approach it would be to use a Dictionary. So "Take" "Grab" "Pickup" would have the same value when looked up in that dictionary and that "Value" could be the command to excute. there are pobably simpler method and I currently have acss to C# to give you any type of example code.
    VK

  5. #15
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    1,215
    I can't remember the code of this exactly, but based on what I can see from the top part...

    There's going to be a bunch of IF checks, or a SWITCH statement nearby your call to ExtractArguments(string);

    To have the switch statement take in same-meaning words;
    Code:
    string text = Console.ReadLine();
    string command = ExtractCommand(text);
    string argument = ExtractArguments(text);
    
    switch (arguement)
    {
     case "grab":
     //grab code
        break;
    
     case "walk":
     case "go":
     case "move":
     //movement code
     break;
    }
    If it's a bunch of IF statements;
    Code:
    string text = Console.ReadLine();
    string command = ExtractCommand(text);
    string argument = ExtractArguments(text);
    
    if (argument == "move" || arguement == "go" || arguement == "walk")
    {
      //move code
    }

    As for ignoring the linking words like "to", 'the"...
    You'd need to make a new method.
    Code:
    public static string DeleteLinkingWords(string line)
    {
      //see if the next word is "to", or "the", or "in" or any other words you want to ignore
         //do needed canges to line.
         //return the edited line, and continue with command extraction
    
       //else, no changed made. so return the line as is :)
    }
    Theres an approach I would take on it, but I'll leave the actual coding of part for you

    Thinking about it... this method would only remove one linking word.
    so if there was a double-linking work used somewhere the above method wouldn't remove the second one.
    example:
    "There is a hole in the wall. Looks like it could fit a red Ball inside it.
    use red ball : ok
    put red ball in wall : ok, as only one linking word
    put red ball in the wall : ba-bow! two linking words.

    But this could be solved with a loop.

    Anyway, I'm rambling now. I'll shut up.

  6. #16
    Join Date
    Jan 2007
    Location
    Kansas City, KS
    Posts
    709
    Oh, nice! Thanks Jacquesy! I will give that a try. Great explanation and good examples. I will get back with the results.
    Rico - VFX Artist in training
    USA: Kansas: Kansas City = (GMT -6:00) (CST)

  7. #17
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Quote Originally Posted by Rico View Post
    Hmmm well that's not helping much. Maybe I'm not understanding. I don't want to simply change it but make it to where I can type in multiple action and get the same result. Like the example I gave.... I want to be able to type in all of this:
    Bar the dropping of the, in, etc

    Well disapointingly you then read someone else say change the case statement, and went ooh thats exactly what you wanted.. Which is what I was hinting at..

    sigh.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  8. #18
    Join Date
    Jan 2007
    Location
    Kansas City, KS
    Posts
    709
    Firs off I would like to thank: LizRiley, Jacquesy, Xperten, and VelariaKnight for helping me out through my journey of the Hyperion Project (by answering my questions and such).

    Before going on to the next set of videos I would like to ask you guys if it is wise to go on with the rest of the videos (seeing that that's were the real intro is) or if I should go back and try to understand everything that went on with the Hyperion Project. I'm planning on going back anyways.... after I finish the dvd.... but I don't know. What do you think?
    Rico - VFX Artist in training
    USA: Kansas: Kansas City = (GMT -6:00) (CST)

  9. #19
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    1,215
    Quote Originally Posted by Rico View Post
    seeing that that's were the real intro is
    Answered your own question.

  10. #20
    Join Date
    Jan 2007
    Location
    Kansas City, KS
    Posts
    709
    Awww come on... that was a low blow.

    The reason I asked was because they put the Hyperion Project in before the intro to C# videos. So, I wasn't sure if we had to be really familiar with what we did in that project prior to engaging in the intro to C# videos.

    Regardless, I went ahead and watched the intro to C# videos anyways. Even though I had previously taken an 'intro to programming' class here at a local college, which used C#..... I feel like I still learned a lot from these videos.

    p.s. the 'Overview to .NET' was a doozy.
    Rico - VFX Artist in training
    USA: Kansas: Kansas City = (GMT -6:00) (CST)

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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