0
嘿大家好,我一直在创建一个小聊天机器人(用于娱乐和练习)。创建一个“假AI”聊天程序
我有一个不能正常工作下面的函数(FULL CODE HERE):
function runAI() {
if (i.val().length > 0) {
if ($.inArray(i.val(), helloInputArray)) {
r = Math.floor(Math.random()*4);
o.html(o.html()+helloOutputArray[r]);
i.val('');
i.focus();
} else if ($.inArray(i.val(), byeInputArray)) {
r = Math.floor(Math.random()*4);
o.html(o.html()+byeOutputArray[r]);
i.val('');
i.focus();
} else {
o.html(o.html()+"I don't know what that means...<br />");
i.val('');
i.focus();
}
}
}
它似乎总是返回helloOutputArray
...
完美,非常感谢你 - 会很快接受。 – 2010-09-15 10:19:19
@Neurofluxation - 我实际上已经给你在你最后一个问题的例子:) http://stackoverflow.com/questions/3716477/is-there-a-way-where-i-can-hold-all-potential - 数组/ 3716495#3716495 – GenericTypeTea 2010-09-15 10:20:21
道歉 - 没有看到 - 我有另一个有效的答案 - 仍然+ 2rep为你(不要抱怨!^ _ ^) – 2010-09-15 10:21:36