1. word game

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

new topic     » topic index » view message » categorize

2. Re: word game

alan123 said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: word game

alan123 said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: word game

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: word game

Fendaril said...

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. tongue)

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: word game

yes that would be good if you want too have a go at it thanks alan

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu