Skip to content
Browse files

add the concept of a "best" response to rei's loop

  • Loading branch information...
1 parent a299a35 commit ee6398e60fa0f0ca186be8bc8a4c0fdd6fcd5e71 @obra committed Jul 30, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 app/scripts/rei.js
View
9 app/scripts/rei.js
@@ -80,11 +80,16 @@ define(
};
console.log(args);
+ var bestResponse;
jQuery.each(that.responsePlugins, function(index, plugin) {
console.log("Asking " + plugin.name + " about " + input);
- responses[plugin.name] = plugin.reply(args);
+ var thisResponse = plugin.reply(args);
+ responses[plugin.name] = thisResponse;
+ if (!bestResponse || thisResponse[0] > bestResponse[0]) {
+ bestResponse = thisResponse;
+ }
});
- return responses;
+ return { responses: responses, bestResponse: bestResponse };
}
}
});

0 comments on commit ee6398e

Please sign in to comment.
Something went wrong with that request. Please try again.