1. word game
- Posted by alan123 Sep 29, 2009
- 1266 views
finding this euphoria a bit hard to find what i need to make the game.I need to be abel to input a sentenc and the computer to read it one word at a time to compar for matchs and remember the possion of the words which will make a code. the computer will also check this code say 123 which could mean feed the cat.then act acordingly 2 this
2. Re: word game
- Posted by mattlewis (admin) Sep 29, 2009
- 1222 views
finding this euphoria a bit hard to find what i need to make the game.I need to be abel to input a sentenc and the computer to read it one word at a time to compar for matchs and remember the possion of the words which will make a code. the computer will also check this code say 123 which could mean feed the cat.then act acordingly 2 this
What have you tried so far? Plz post teh codez.
Matt
3. Re: word game
- Posted by jeremy (admin) Sep 29, 2009
- 1263 views
finding this euphoria a bit hard to find what i need to make the game.I need to be abel to input a sentenc and the computer to read it one word at a time to compar for matchs and remember the possion of the words which will make a code. the computer will also check this code say 123 which could mean feed the cat.then act acordingly 2 this
I think this will do it:
include std/console.e include std/sequence.e sequence sentence = prompt_string("Enter sentence:") sequence words = split_any(sentence, ",.:; ") for i = 1 to length(words) do printf(1, "Word %d: %s\n", { words[i] }) end for
See prompt_string and split_any
Jeremy
4. Re: word game
- Posted by Fendaril Sep 29, 2009
- 1153 views
- Last edited Sep 30, 2009
Wouldn't that print characters. i think a better way is to look for whitespace and record that position minus 1. What do you think?
EDIT:
Alan
Can I make this for you plz? It will be a nice challenge.pl0x.
5. Re: word game
- Posted by ghaberek (admin) Oct 01, 2009
- 1126 views
Wouldn't that print characters. i think a better way is to look for whitespace and record that position minus 1. What do you think?
I think that was just a demo to show how you'd process the words. But that is certainly a good method of breaking apart a sentence into words with several possible delimiters.
Rather than tracking the exact position of each word, like "1, feed. 2, the. 3, cat." you may have to work on some sort of basic grammar parser, with known verbs and nouns. Something like "feed (verb), the (article), cat (noun)" would probably be better. Then try to track a verb-object relationship. That way "feed cat" and "feed the cat" would be the same (since 'the' is unnecessary here). Order comes into play as well, "feed cat" and "cat feed" are two different things. (While most people say "cat food", "cat feed" is still technically correct, assuming you keep cats as livestock. )
Perhaps I'm over complicating things here. Maybe you just want some sort of command line parser, like "feed [noun] [food type]" where [noun] could be "cat" or "birds breadcrumbs" or "Steve burger", etc. In that case, check out cmd_parse().
-Greg
6. Re: word game
- Posted by alan123 Oct 13, 2009
- 1071 views
yes that would be good if you want too have a go at it thanks alan