开发者

'8 Ball' Program

开发者 https://www.devze.com 2023-03-20 18:53 出处:网络
I\'ve tried looking on google but i guess I can just not get the right search phrases to find what I want.If you are familiar with the afterNET IRC server, there is a command \'.8\' which is an 8 ball

I've tried looking on google but i guess I can just not get the right search phrases to find what I want. If you are familiar with the afterNET IRC server, there is a command '.8' which is an 8 ball. It answers more than just yes/no questions tho. It gives you a variety of answers bas开发者_JAVA技巧ed on certain words you use in your question, like when, where, color, etc

I'd like to make something like this but have no idea where to start. I've recently studied DFA (Deterministic Finite Automata), is that where I should start? I understand I don't want to be scripting out every possible combination of words people use, but it would be nice to have a system that feels sorta realistic (like the 8ball program on the IRC server), and is expandable for more 'words' whenever I want.

Thanks for any help/links!


You may be giving most 8ball implementations more credit than they deserve. I think the point is that the questions are for yes/no answers, so the provided answers only have to cover a fairly predictable set of possibilities.

Most 8ball scripts that I am aware of (example) will just use an array and a random number to grab an answer.

Magic 8ball bots are very popular on irc as they are very easy to implement - simply respond to text with a given marker (in this case ".8") and respond with a random answer.

I have never heard of a magic 8ball using a deterministic approach, Cleverbot style. Actually, trying that, I'm not even sure how deterministic that is as most of the responses are also totally random and unrelated to what I was saying.

// our answers array
String[] answers = [ "yes", "no", "for sure", "unlikely", "most certainly", "definitely not" ];

public String ask8Ball() {
    // rand returns a float between 0>=res>1, the (int) cast rounds down
    int index = (int)(java.lang.Math.random() * 7);
    return answers[index];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消