OSDN Git Service

エッジの描画を曲線に変更。
[chnosproject/AI004.git] / aijobs.js
index 38eacbb..b33656f 100644 (file)
--- a/aijobs.js
+++ b/aijobs.js
@@ -2,15 +2,18 @@ var AI_Job_Ask_isWord = function(env){
        AI_Job_Ask_isWord.base.call(this, env);
        this.waiting = false;
        this.currentCandidate = null;
+       this.isPromptedByUser = false;
 }.extend(AI_Job, {
+       //ユーザーが空入力をすると、候補単語が単語であるかどうかをユーザーに問いかける。
        tick: function(){
                //定期的に呼ばれることを期待する
                //戻り値がundefinedで処理終了
-               if(!this.waiting && this.env.memory.candidateWordList.length > 0){
+               if(!this.waiting && this.env.memory.candidateWordList.length > 0 && this.isPromptedByUser){
                        this.currentCandidate = this.env.memory.candidateWordList.pop();
                        this.env.memory.removeMemoryTagByObject(this.currentCandidate);
                        this.env.message("「" + this.currentCandidate.str + "」は単語ですか?(y/n)\n");
                        this.waiting = true;
+                       this.isPromptedByUser = false;
                }
                return 0;
        },
@@ -20,12 +23,18 @@ var AI_Job_Ask_isWord = function(env){
                if(this.env.input.lastSentenceSourceType != "User"){
                        return 0;
                }
-               if(s == "y"){
-                       this.env.memory.appendMemoryTag(new AI_WordTag(this.currentCandidate.str));
-                       this.env.message(this.env.memory.wordList.length + "個目の単語を登録しました!\n");
+               if(this.waiting == false){
+                       if(s == ""){
+                               this.isPromptedByUser = true;
+                       }
+               } else{
+                       if(s == "y"){
+                               this.env.memory.appendMemoryTag(new AI_WordTag(this.currentCandidate.str));
+                               this.env.message(this.env.memory.wordList.length + "個目の単語を登録しました!\n");
+                       }
+                       this.waiting = false;
+                       this.currentCandidate = null;
                }
-               this.waiting = false;
-               this.currentCandidate = null;
                return 0;
        }
 });
\ No newline at end of file