Compare commits

...

4 Commits

Author SHA1 Message Date
Will Webberley
fab9967747 updated README 2018-10-12 11:35:03 +01:00
Will Webberley
0264801299 support for running in Docker 2018-10-12 11:33:15 +01:00
Will Webberley
040f5528ea bumbed cenode version 2017-07-21 22:55:06 +01:00
Will Webberley
8c30cc246f updated to work with CENode 3 2017-02-27 22:40:22 +00:00
11 changed files with 438 additions and 327 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.sw*
node_modules/

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
from nginx:latest
RUN rm /etc/nginx/conf.d/*
ADD ./nginx_sherlock.conf /etc/nginx/conf.d
ADD js /var/www/sherlock/js
ADD css /var/www/sherlock/css
ADD media /var/www/sherlock/media
ADD node_modules /var/www/sherlock/node_modules
ADD index.html /var/www/sherlock
ADD models /models
EXPOSE 80

View File

@ -1,14 +1,71 @@
# SHERLOCK
This repository contains the source code for the ITA project's SHERLOCK game for CE experiments.
## Introduction
This repository contains the source code for the ITA project's SHERLOCK game for Controlled English experiments.
The game uses the CENode library to maintain a knowledge base, which is described purely in ITA Controlled English.
For more information, take a look at the following webpages:
For more information on the ITA project and CENode, take a look at the following webpages:
* [usukita.org](https://www.usukita.org)
* [dais-ita.org/pub](https://dais-ita.org/pub)
* [cenode.io](http://cenode.io)
## Running the game
### Getting started
The easiest way to run the game is to use Docker:
```
docker run -p 80:80 flyingsparx/sherlock
```
Then navigate to [localhost](http://localhost) to start the game using the default Sherlock 'world' in an isolated environment.
### Extending the game's world
To enable users to start the game with more context, extra models can be passed, where each model is described by a JavaScript array of pure CE sentences inside a global variable named `CUSTOM_MODEL`.
For example, the following model can be used to tell CENode that there is such a thing called a 'movie', and that there is a movie called Harry Potter:
```javascript
var CUSTOM_MODEL = [
"conceptualise a ~ movie ~ M",
"there is a movie named 'Harry Potter'"
];
```
To start a new Sherlock game such that its world contains this information, we can pass it into the Docker container (given the model is saved in a file called `harry_potter.js`):
```
docker run -p 80:80 -v ${PWD}/harry_potter.js:/models/custom.js flyingsparx/sherlock
```
### Use case: multiplayer
CENode supports inter-node communication out-of-the-box, through use of [policies](https://github.com/willwebberley/CENode/wiki/Policies). Since policies are again described by pure CE, a multiplayer game can be set-up through a relay CENode instance using the same `CUSTOM_MODEL` setup.
For example, given a relay CENode instance is configured at `http://mycenode.com`, the relevant policies can be described in a file called `multiplayer.js`:
```javascript
var CUSTOM_MODEL = [
"there is an agent named 'RemoteAgent' that has 'mycenode.com' as address",
"there is a tell policy named 'p2' that has 'true' as enabled and has the agent 'RemoteAgent' as target",
"there is a listen policy named 'p4' that has 'true' as enabled and has the agent 'RemoteAgent' as target"
];
```
And this can be passed into the Docker container as before to enable players of the game to exist in the same 'world':
```
docker run -p 80:80 -v ${PWD}/multiplayer.js:/models/custom.js flyingsparx/sherlock
```
The policies on the node mean that the game allows players to continue even when they have no network connectivity. The games will sync up as individual players leave and join the network.
To set-up a simple CENode relay, take a look at the [CENode Explorer project](https://github.com/willwebberley/CENode-explorer).
## Licensing
The contents of this repository are licensed under the Apache License v2. See LICENSE for further information.

View File

@ -20,11 +20,11 @@
<input class="username clear" id="login_username" placeholder="User ID" type="text" autofocus>
<div class="clear"></div>
<p style="display:none;color:rgb(220,220,220);font-weight:300;font-size:15px;" id="login_error">Please enter a User ID to continue.</p>
<input id="multiplayer" type="checkbox" checked="checked" style="width:20px;"/><span style="margin-left:5px;color:white;">Multiplayer</span>
<!--<input id="multiplayer" type="checkbox" checked="checked" style="width:20px;"/><span style="margin-left:5px;color:white;">Multiplayer</span>-->
<div class="clear"></div>
<button id="login">Login</button>
</div>
<img src="/media/logo.jpg" class="attribution">
<img src="media/logo.jpg" class="attribution">
</div>
<div class="overlay" id="moira_overlay">
<header>
@ -35,7 +35,6 @@
<div id="unanswered"></div>
</div>
<button class="change_view dashboard" data-view="dashboard" id="score">Dashboard</button>
<!--<button class="logout" id="logout">Logout</button>-->
<div id="online_status" class="status"></div>
<div class="clear"></div>
@ -46,7 +45,6 @@
<input id="autofill" type="checkbox" checked="checked"/><span style="margin-left:5px;">Input suggestions</span>
</div>
<div style="text-align:left;margin-left:1%;display:inline-block;float:left;">
<!-- <div id="online_status" class="status"></div>-->
</div>
</div>
<div id="text_input_area">
@ -63,7 +61,10 @@
</div>
</div>
<script src="http://cenode.io/cenode.js"></script>
<script src="node_modules/cenode/dist/cenode.min.js"></script>
<script src="node_modules/cenode/dist/models.js"></script>
<script src="js/sherlock-models.js"></script>
<script src="models/custom.js"></script>
<script src="js/main.js"></script>
</body>
</html>

View File

@ -1,157 +1,22 @@
var node;
var shown_cards = [];
var asked_questions = [];
var submitted_statements = [];
var scored_cards = [];
var space_pressed = 0;
var last_space_pressed = 0;
var forbid_input = false;
var multiplayer;
var last_successful_request = 0;
var latest_latitude = null;
var latest_longitude = null;
var shownCards = [];
var askedQuestions = [];
var submittedStatements = [];
var scoredCards = [];
var spacePressed = 0;
var lastSpacePressed = 0;
var forbidInput = false;
//var multiplayer;
var latestLatitude = null;
var latestLongitude = null;
var logging_configs = [
{url: 'http://logger.cenode.io/cards/sherlock', logged_cards: []},
{url: 'http://logger2.cenode.io/cards/sherlock', logged_cards: []}
];
var SHERLOCK_CORE = [
"conceptualise a ~ sherlock thing ~ S that is an entity and is an imageable thing",
"conceptualise an ~ organisation ~ O that is a sherlock thing",
"conceptualise a ~ fruit ~ F that is a sherlock thing and is a locatable thing",
"conceptualise a ~ room ~ R that is a location and is a sherlock thing",
"conceptualise a ~ hat colour ~ C",
"conceptualise a ~ sport ~ S",
"conceptualise a ~ character ~ C that is a sherlock thing and is a locatable thing and has the hat colour C as ~ hat colour ~",
"conceptualise the character C ~ works for ~ the organisation O and ~ eats ~ the fruit F and ~ plays ~ the sport S",
"conceptualise the hat colour C ~ is worn by ~ the character C",
"conceptualise an ~ object ~ O that is an entity",
"conceptualise the object O ~ resides in ~ the room R",
"conceptualise the room R ~ contains ~ the fruit F and has the character C as ~ contents ~ and has the object O as ~ additional contents ~",
"conceptualise the fruit F ~ is eaten by ~ the character C",
"conceptualise the sport S ~ is played by ~ the character C and ~ is in ~ the room R",
"conceptualise a ~ question ~ Q that has the value V as ~ text ~ and has the value W as ~ value ~ and has the value X as ~ relationship ~",
"conceptualise the question Q ~ concerns ~ the sherlock thing C",
"there is a rule named r1 that has 'if the character C ~ eats ~ the fruit F then the fruit F ~ is eaten by ~ the character C' as instruction",
"there is a rule named r2 that has 'if the character C ~ plays ~ the sport S then the sport S ~ is played by ~ the character C' as instruction",
"there is a rule named r3 that has 'if the character C has the hat colour S as ~ hat colour ~ then the hat colour S ~ is worn by ~ the character C' as instruction",
"there is a rule named r4 that has 'if the character C ~ is in ~ the room R then the room R has the character C as ~ contents ~' as instruction",
"there is a rule named r5 that has 'if the fruit F ~ is in ~ the room R then the room R ~ contains ~ the fruit F' as instruction",
// Inverse rules:
"there is a rule named r6 that has 'if the fruit F ~ is eaten by ~ the character C then the character C ~ eats ~ the fruit F' as instruction",
"there is a rule named r7 that has 'if the sport S ~ is played by ~ the character C then the character C ~ plays ~ the sport S' as instruction",
"there is a rule named r8 that has 'if the hat colour S ~ is worn by ~ the character C then the character C has the hat colour S as ~ hat colour ~' as instruction",
"there is a rule named r9 that has 'if the room R has the character C as ~ contents ~ then the character C ~ is in ~ the room R' as instruction",
"there is a rule named r10 that has 'if the room R ~ contains ~ the fruit F then the fruit F ~ is in ~ the room R' as instruction",
"there is a character named 'Prof Crane' that has 'http://sherlock.cenode.io/media/crane.png' as image",
"there is a character named 'Dr Finch' that has 'http://sherlock.cenode.io/media/finch.png' as image",
"there is a character named 'Col Robin' that has 'http://sherlock.cenode.io/media/robin.png' as image",
"there is a character named 'Sgt Stork' that has 'http://sherlock.cenode.io/media/stork.png' as image",
"there is a character named 'Rev Hawk' that has 'http://sherlock.cenode.io/media/hawk.png' as image",
"there is a character named 'Capt Falcon' that has 'http://sherlock.cenode.io/media/falcon.png' as image",
"there is a character named 'Elephant' that has 'http://sherlock.cenode.io/media/Elephant.png' as image",
"there is a character named 'Giraffe' that has 'http://sherlock.cenode.io/media/Giraffe.png' as image",
"there is a character named 'Hippopotamus' that has 'http://sherlock.cenode.io/media/Hippopotamus.png' as image",
"there is a character named 'Leopard' that has 'http://sherlock.cenode.io/media/Leopard.png' as image",
"there is a character named 'Lion' that has 'http://sherlock.cenode.io/media/Lion.png' as image",
"there is a character named 'Zebra' that has 'http://sherlock.cenode.io/media/Zebra.png' as image",
"there is a room named 'Ruby Room'",
"there is a room named 'Sapphire Room'",
"there is a room named 'Gold Room'",
"there is a room named 'Amber Room'",
"there is a room named 'Emerald Room'",
"there is a room named 'Silver Room'",
"there is a fruit named 'pineapple'",
"there is a fruit named 'apple'",
"there is a fruit named 'banana'",
"there is a fruit named 'orange'",
"there is a fruit named 'lemon'",
"there is a fruit named 'pear'",
"there is a fruit named 'grape'",
"there is a fruit named 'kiwi'",
"there is a fruit named 'tomato'",
"there is a hat colour named 'green'",
"there is a hat colour named 'red'",
"there is a hat colour named 'yellow'",
"there is a hat colour named 'black'",
"there is a hat colour named 'white'",
"there is a hat colour named 'purple'",
"there is a hat colour named 'pink'",
"there is a hat colour named 'blue'",
"there is a hat colour named 'brown'",
"there is a hat colour named 'grey'",
"there is a sport named 'tennis'",
"there is a sport named 'badminton'",
"there is a sport named 'rugby'",
"there is a sport named 'football'",
"there is a sport named 'soccer'",
"there is a sport named 'running'",
"there is a sport named 'swimming'",
"there is a sport named 'athletics'",
"there is a sport named 'baseball'",
"there is a sport named 'rounders'",
"there is a sport named 'softball'",
"there is a sport named 'cricket'",
"there is a sport named 'golf'",
"there is a sport named 'basketball'",
"there is a rule named objectrule1 that has 'if the object O ~ resides in ~ the room R then the room R has the object O as ~ additional contents ~' as instruction",
"there is an object named 'gorilla'",
"there is an object named 'dinosaur'",
"there is an object named 'robot'",
"there is an object named 'ghost'",
"there is an object named 'balloon'",
"there is a question named 'q1' that has 'What character eats pineapples?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'pineapple'",
"there is a question named 'q2' that has 'What sport does Zebra play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Zebra'",
"there is a question named 'q3' that has 'What character eats apples?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'apple'",
"there is a question named 'q4' that has 'What colour hat is Elephant wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Elephant'",
"there is a question named 'q6' that has 'Where is Giraffe?' as text and has 'is in' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q7' that has 'What colour hat is Lion wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Lion'",
"there is a question named 'q8' that has 'Where is Lion?' as text and has 'is in' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q9' that has 'Which character is in the emerald room?' as text and has 'contents' as value and concerns the sherlock thing 'Emerald Room'",
"there is a question named 'q12' that has 'What character eats bananas?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'banana'",
"there is a question named 'q13' that has 'What character is in the sapphire room?' as text and has 'contents' as value and concerns the sherlock thing 'Sapphire Room'",
"there is a question named 'q17' that has 'What sport does Elephant play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q18' that has 'What character is wearing a red hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'red'",
"there is a question named 'q19' that has 'What character plays rugby?' as text and has 'is played by' as relationship and concerns the sherlock thing 'rugby'",
"there is a question named 'q20' that has 'What fruit does Leopard eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Leopard'",
"there is a question named 'q23' that has 'What fruit does Giraffe eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q24' that has 'What colour hat is Zebra wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Zebra'",
"there is a question named 'q25' that has 'Where is the apple?' as text and has 'is in' as relationship and concerns the sherlock thing 'apple'",
"there is a question named 'q26' that has 'What character is wearing a yellow hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'yellow'",
"there is a question named 'q28' that has 'What fruit is in the silver room?' as text and has 'contains' as relationship and concerns the sherlock thing 'Silver Room'",
"there is a question named 'q30' that has 'What character is wearing a blue hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'blue'",
"there is a question named 'q31' that has 'What character eats lemons?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'lemon'",
"there is a question named 'q33' that has 'What fruit does Elephant eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q34' that has 'What character plays basketball?' as text and has 'is played by' as relationship and concerns the sherlock thing 'basketball'",
"there is a question named 'q35' that has 'What character plays soccer?' as text and has 'is played by' as relationship and concerns the sherlock thing 'soccer'",
"there is a question named 'q36' that has 'What sport does Lion play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q37' that has 'What character is in the ruby room?' as text and has 'contents' as value and concerns the sherlock thing 'Ruby Room'",
"there is a question named 'q39' that has 'What character plays golf?' as text and has 'is played by' as relationship and concerns the sherlock thing 'golf'",
"there is a question named 'q40' that has 'What character eats oranges?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'orange'",
"there is a question named 'q41' that has 'What colour hat is Hippopotamus wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Hippopotamus'",
"there is a question named 'q45' that has 'What character is in the amber room?' as text and has 'contents' as value and concerns the sherlock thing 'Amber Room'",
"there is a question named 'q47' that has 'Where is Elephant?' as text and has 'is in' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q48' that has 'Where is the pear?' as text and has 'is in' as relationship and concerns the sherlock thing 'pear'",
"there is a question named 'q50' that has 'What fruit does Lion eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q52' that has 'What sport does Giraffe play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q53' that has 'Where is Hippopotamus?' as text and has 'is in' as relationship and concerns the sherlock thing 'Hippopotamus'",
"there is a question named 'q54' that has 'What sport does Hippopotamus play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Hippopotamus'"
];
var SHERLOCK_NODE = [
"there is an agent named 'Mycroft' that has 'http://mycroft.cenode.io' as address",
"there is a tell policy named 'p2' that has 'true' as enabled and has the agent 'Mycroft' as target",
"there is a listen policy named 'p4' that has 'true' as enabled and has the agent 'Mycroft' as target"
var loggingConfigs = [
//{url: 'http://logger.cenode.io/cards/sherlock', loggedCards: []},
//{url: 'http://logger2.cenode.io/cards/sherlock', loggedCards: []}
];
var settings = {
logged_in : false,
loggedIn : false,
};
var user = {
@ -160,16 +25,16 @@ var user = {
questions : [],
answers : [],
inputs: [],
input_counter : 0,
inputCounter : 0,
score : 0,
current_screen : "login"
currentScreen : "login"
};
var log = {
recording_presses : false,
recordingPresses : false,
keypresses : 0,
start_time : 0,
end_time : 0
startTime : 0,
endTime : 0
};
var ui = {
@ -178,60 +43,60 @@ var ui = {
logout : null,
},
inputs : {
login_user_id : null,
main_user_id : null,
loginUserId : null,
mainUserId : null,
text : null,
guess : null,
autofill : null,
multiplayer: null
//multiplayer: null
},
overlays : {
login : null,
moira : null,
dashboard: null
},
view_changers : [],
viewChangers : [],
info : {
cards : null,
questions : null,
login_error : null,
loginError : null,
score : null,
online_status : null
onlineStatus : null
}
};
function initialize_ui(){
function initializeUi(){
ui.buttons.login = document.getElementById("login");
ui.inputs.login_user_id = document.getElementById("login_username");
ui.inputs.main_user_id = document.getElementById("username");
ui.inputs.loginUserId = document.getElementById("login_username");
ui.inputs.mainUserId = document.getElementById("username");
ui.inputs.text = document.getElementById("text");
ui.inputs.guess = document.getElementById("guess");
ui.inputs.autofill = document.getElementById("autofill");
ui.inputs.multiplayer = document.getElementById("multiplayer");
//ui.inputs.multiplayer = document.getElementById("multiplayer");
ui.overlays.login = document.getElementById("login_overlay");
ui.overlays.moira = document.getElementById("moira_overlay");
ui.overlays.dashboard = document.getElementById("dashboard_overlay");
ui.info.cards = document.getElementById("cards");
ui.info.questions = document.getElementById("questions");
ui.info.login_error = document.getElementById("login_error");
ui.info.loginError = document.getElementById("login_error");
ui.info.score = document.getElementById("score");
ui.info.online_status = document.getElementById("online_status");
ui.view_changers = document.getElementsByClassName("change_view");
ui.info.onlineStatus = document.getElementById("online_status");
ui.viewChangers = document.getElementsByClassName("change_view");
}
function bind_listeners(){
function bindListeners(){
ui.buttons.login.onclick = login;
ui.inputs.login_user_id.onkeyup = login;
ui.inputs.text.onkeyup = key_up;
ui.inputs.text.onkeydown = key_down;
for(var i = 0; i < ui.view_changers.length; i++){
ui.view_changers[i].onclick = function(e){change_view(e.target.getAttribute("data-view"));};
ui.inputs.loginUserId.onkeyup = login;
ui.inputs.text.onkeyup = keyUp;
ui.inputs.text.onkeydown = keyDown;
for(var i = 0; i < ui.viewChangers.length; i++){
ui.viewChangers[i].onclick = function(e){changeView(e.target.getAttribute("data-view"));};
}
}
function change_view(view){
user.selected_screen = view;
update_ui();
function changeView(view){
user.selectedScreen = view;
updateUi();
}
function login(e){
@ -240,49 +105,45 @@ function login(e){
return;
}
}
user.id = ui.inputs.login_user_id.value.charAt(0).toUpperCase() + ui.inputs.login_user_id.value.slice(1);
user.id = ui.inputs.loginUserId.value.charAt(0).toUpperCase() + ui.inputs.loginUserId.value.slice(1);
user.id = user.id.trim();
multiplayer = ui.inputs.multiplayer.checked == true;
//multiplayer = ui.inputs.multiplayer.checked == true;
if(user.id == null || user.id == ""){
ui.info.login_error.style.display = "block";
ui.info.loginError.style.display = "block";
return;
}
if(multiplayer){
node = new CENode(MODELS.CORE, SHERLOCK_CORE, SHERLOCK_NODE);
ui.info.online_status.style.display = "block";
check_online();
}
//if(MULTIPLAYER_MODEL){
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
ui.info.onlineStatus.style.display = "block";
checkOnline();
/*}
else{
node = new CENode(MODELS.CORE, SHERLOCK_CORE);
ui.info.online_status.style.display = "none";
}
node.agent.set_name(user.id+" agent");
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
ui.info.onlineStatus.style.display = "none";
}*/
node.attachAgent();
node.agent.setName(user.id+" agent");
window.setTimeout(function(){
node.add_sentence("there is a tell card named 'msg_{uid}' that is from the agent '"+node.agent.get_name().replace(/'/g, "\\'")+"' and is to the agent '"+node.agent.get_name().replace(/'/g, "\\'")+"' and has the timestamp '{now}' as timestamp and has 'there is an agent named \\'"+node.agent.get_name().replace(/'/g, "\\\'")+"\\'' as content");
node.add_sentence("there is a feedback policy named 'p3' that has the individual '"+user.id+"' as target and has 'true' as enabled and has 'full' as acknowledgement");
node.addSentence("there is a tell card named 'msg_{uid}' that is from the agent '"+node.agent.name.replace(/'/g, "\\'")+"' and is to the agent '"+node.agent.name.replace(/'/g, "\\'")+"' and has the timestamp '{now}' as timestamp and has 'there is an agent named \\'"+node.agent.name.replace(/'/g, "\\\'")+"\\'' as content");
node.addSentence("there is a feedback policy named 'p3' that has the individual '"+user.id+"' as target and has 'true' as enabled and has 'full' as acknowledgement");
}, 100);
settings.logged_in = true;
user.selected_screen = "moira";
settings.loggedIn = true;
user.selectedScreen = "moira";
user.cards = [];
ui.info.login_error.style.display = "none";
ui.info.loginError.style.display = "none";
update_ui();
load_questions();
poll_for_instances();
for(var i = 0; i < logging_configs.length; i++){
log_cards(logging_configs[i]);
updateUi();
loadQuestions();
pollForInstances();
for(var i = 0; i < loggingConfigs.length; i++){
logCards(loggingConfigs[i]);
}
}
function add_sentence(t){
node.add_sentence(t);
}
function key_down(e){
if(forbid_input){
function keyDown(e){
if(forbidInput){
e.preventDefault();
return false;
}
@ -291,60 +152,60 @@ function key_down(e){
return false;
}
if(e.keyCode == 32){
space_pressed = new Date().getTime();
if((space_pressed - last_space_pressed) < 400 && ui.inputs.text.value.slice(-1) == ' '){
spacePressed = new Date().getTime();
if((spacePressed - lastSpacePressed) < 400 && ui.inputs.text.value.slice(-1) == ' '){
if(ui.inputs.text.value.length < ui.inputs.guess.value.length && ui.inputs.autofill.checked == true){
e.preventDefault();
ui.inputs.text.value = node.guess_next(ui.inputs.text.value.substring(0, ui.inputs.text.value.length-1)) + " ";
ui.inputs.text.value = node.nlParser.guessNext(ui.inputs.text.value.substring(0, ui.inputs.text.value.length-1)) + " ";
return false;
}
}
last_space_pressed = new Date().getTime();
lastSpacePressed = new Date().getTime();
}
}
function key_up(e){
if(forbid_input){
function keyUp(e){
if(forbidInput){
e.preventDefault();
return false;
}
if(e.keyCode == 13){
log.recording_presses = false;
log.end_time = parseInt(new Date().getTime());
log.recordingPresses = false;
log.endTime = parseInt(new Date().getTime());
send();
}
else if(e.keyCode == 38){
if(user.input_counter > 0){
user.input_counter--;
ui.inputs.text.value = user.inputs[user.input_counter];
if(user.inputCounter > 0){
user.inputCounter--;
ui.inputs.text.value = user.inputs[user.inputCounter];
}
e.preventDefault();
}
else if(e.keyCode == 40){
if(user.input_counter < user.inputs.length-1){
user.input_counter++;
ui.inputs.text.value = user.inputs[user.input_counter];
if(user.inputCounter < user.inputs.length-1){
user.inputCounter++;
ui.inputs.text.value = user.inputs[user.inputCounter];
}
else{
ui.inputs.text.value = "";
}
}
else if(e.keyCode == 9){
ui.inputs.text.value = node.guess_next(ui.inputs.text.value);
ui.inputs.text.value = node.nlParser.guessNext(ui.inputs.text.value);
e.preventDefault();
return false;
}
else{
if(log.recording_presses == false){
log.recording_presses = true;
log.start_time = parseInt(new Date().getTime());
if(log.recordingPresses == false){
log.recordingPresses = true;
log.startTime = parseInt(new Date().getTime());
log.keypresses = 0;
}
log.keypresses++;
}
if(ui.inputs.autofill.checked == true){
ui.inputs.guess.value = node.guess_next(ui.inputs.text.value);
ui.inputs.guess.value = node.nlParser.guessNext(ui.inputs.text.value);
}
else{
ui.inputs.guess.value = "";
@ -356,78 +217,78 @@ function send(){
ui.inputs.text.value = "";
user.inputs.push(input);
user.input_counter = user.inputs.length;
user.inputCounter = user.inputs.length;
var sentence = input.replace(/'/g, "\\'");
var card;
if(sentence.toLowerCase().trim() == 'show anomalies'){
add_card_simple(sentence, 'user');
addCardSimple(sentence, 'user');
var objects = node.concepts.object.instances;
for(var i = 0; i < objects.length; i++){
add_card_simple(objects[i].gist, 'friend');
addCardSimple(objects[i].gist, 'friend');
}
return;
}
else if(sentence.toLowerCase().indexOf("who ") == 0 || sentence.toLowerCase().indexOf("what ") == 0 || sentence.toLowerCase().indexOf("where ") == 0 || sentence.toLowerCase().indexOf("list ") == 0){
card = "there is an ask card named 'msg_{uid}' that has '"+sentence+"' as content and is to the agent '"+node.agent.get_name().replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp";
add_card_simple(input, 'user');
card = "there is an ask card named 'msg_{uid}' that has '"+sentence+"' as content and is to the agent '"+node.agent.name.replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp";
addCardSimple(input, 'user');
}
else{
if(submitted_statements.indexOf(input.toLowerCase()) > -1 ){
add_card_simple("I cannot accept duplicate information from the same user.", 'friend');
if(submittedStatements.indexOf(input.toLowerCase()) > -1 ){
addCardSimple("I cannot accept duplicate information from the same user.", 'friend');
return window.alert("The input is invalid or you've already entered this information!");
}
submitted_statements.push(input.toLowerCase());
submittedStatements.push(input.toLowerCase());
card = "there is an nl card named 'msg_{uid}' that has '"+sentence+"' as content and is to the agent '"+node.agent.get_name().replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp";
add_card_simple(input, 'user');
card = "there is an nl card named 'msg_{uid}' that has '"+sentence+"' as content and is to the agent '"+node.agent.name.replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp";
addCardSimple(input, 'user');
}
node.add_sentence(card);
node.addSentence(card);
}
function confirm_card(id, content){
function confirmCard(id, content){
document.getElementById("confirm_"+id).style.display = "none";
document.getElementById("unconfirm_"+id).style.display = "none";
forbid_input = false;
forbidInput = false;
ui.inputs.text.focus();
if(submitted_statements.indexOf(content.toLowerCase()) > -1){
add_card_simple("I cannot accept duplicate information from the same user.", 'friend');
if(submittedStatements.indexOf(content.toLowerCase()) > -1){
addCardSimple("I cannot accept duplicate information from the same user.", 'friend');
return window.alert("You have already entered or conifirmed this statement.");
}
submitted_statements.push(content.toLowerCase());
submittedStatements.push(content.toLowerCase());
add_card_simple("Yes.", 'user');
var card = "there is a tell card named 'msg_{uid}' that has '"+content.replace(/'/g, "\\'")+"' as content and is to the agent '"+node.agent.get_name().replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp and is in reply to the card '"+id+"'";
addCardSimple("Yes.", 'user');
var card = "there is a tell card named 'msg_{uid}' that has '"+content.replace(/'/g, "\\'")+"' as content and is to the agent '"+node.agent.name.replace(/'/g, "\\'")+"' and is from the individual '"+user.id+"' and has the timestamp '{now}' as timestamp and is in reply to the card '"+id+"'";
card+=" and has '"+log.keypresses+"' as number of keystrokes";
card+=" and has '"+log.end_time+"' as submit time";
card+=" and has '"+log.start_time+"' as start time";
if(latest_latitude && latest_longitude){
card+=" and has '"+latest_latitude+"' as latitude";
card+=" and has '"+latest_longitude+"' as longitude";
card+=" and has '"+log.endTime+"' as submit time";
card+=" and has '"+log.startTime+"' as start time";
if(latestLatitude && latestLongitude){
card+=" and has '"+latestLatitude+"' as latitude";
card+=" and has '"+latestLongitude+"' as longitude";
}
node.add_sentence(card);
node.addSentence(card);
}
function unconfirm_card(id){
function unconfirmCard(id){
document.getElementById("confirm_"+id).style.display = "none";
document.getElementById("unconfirm_"+id).style.display = "none";
add_card_simple("No.", 'user');
add_card_simple("OK.", 'friend');
forbid_input = false;
addCardSimple("No.", 'user');
addCardSimple("OK.", 'friend');
forbidInput = false;
ui.inputs.text.focus();
}
function update_ui(){
if(settings.logged_in == true){
function updateUi(){
if(settings.loggedIn == true){
ui.overlays.login.style.display = "none";
ui.info.score.innerHTML = user.score+' points';
if(user.selected_screen == "moira"){
if(user.selectedScreen == "moira"){
ui.overlays.moira.style.display = "block";
ui.overlays.dashboard.style.display = "none";
}
else if(user.selected_screen == "dashboard"){
else if(user.selectedScreen == "dashboard"){
ui.overlays.dashboard.style.display = "block";
ui.overlays.moira.style.display = "none";
}
@ -435,29 +296,29 @@ function update_ui(){
else{
ui.overlays.login.style.display = "block";
ui.overlays.moira.style.display = "none";
ui.inputs.login_user_id.value = "";
ui.inputs.loginUserId.value = "";
ui.info.cards.innerHTML = "";
}
}
function add_card_simple(text, user){
function addCardSimple(text, user){
ui.info.cards.innerHTML += '<li class="card '+user+'"><p>'+text+'</p></li>';
ui.info.cards.scrollTop = ui.info.cards.scrollHeight;
}
function add_card(card){
function addCard(card){
var content = card.content;
var id = card.name;
var tos = card.is_tos.map(function(to){
return to.name.toLowerCase();
});
var from = card.is_from.name;
var card_type = card.type;
var linked_content = card.linked_content;
var cardType = card.type;
var linkedContent = card.linked_content;
if(!content){return;}
if(id == null || (id != null && shown_cards.indexOf(id) == -1)){
shown_cards.push(id);
if(id == null || (id != null && shownCards.indexOf(id) == -1)){
shownCards.push(id);
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
var c = '<li class="card';
if(tos && tos.indexOf(user.id) > -1){c+=' user';}
@ -469,17 +330,17 @@ function add_card(card){
}
c+='">';
c+='<p>';
if(card_type != null && card_type.name == "confirm card"){
if(cardType != null && cardType.name == "confirm card"){
c+='OK. Is this what you meant?<br /><br />';
}
c+=content.replace(/(?:\r\n|\r|\n)/g, ' <br /> ').replace(/ /g, '&nbsp;&nbsp;')+'</p>';
if(card_type != null && card_type.name == "confirm card"){
c+='<button id="confirm_'+id+'" class="confirm" onclick="confirm_card(\''+id+'\', \''+content.replace(/'/g, "\\'")+'\')">Yes</button>';
c+='<button id="unconfirm_'+id+'" class="unconfirm" onclick="unconfirm_card(\''+id+'\')">No</button>';
forbid_input = true;
if(cardType != null && cardType.name == "confirm card"){
c+='<button id="confirm_'+id+'" class="confirm" onclick="confirmCard(\''+id+'\', \''+content.replace(/'/g, "\\'")+'\')">Yes</button>';
c+='<button id="unconfirm_'+id+'" class="unconfirm" onclick="unconfirmCard(\''+id+'\')">No</button>';
forbidInput = true;
}
if(linked_content != null){
c+='<img src="'+linked_content+'" alt="Attachment" />';
if(linkedContent != null){
c+='<img src="'+linkedContent+'" alt="Attachment" />';
}
c+='</li>';
ui.info.cards.innerHTML+=c;
@ -487,32 +348,32 @@ function add_card(card){
}
}
function get_question_state(q){
function getQuestionState(q){
if(q.responses.length == 0){return "unanswered";}
else if(q.responses.length < 5){return "unconfident";}
else if(q.responses.length < 3){return "unconfident";}
else{
var responses = {};
var response_vols = [];
var responseVols = [];
for(var j = 0; j < q.responses.length; j++){
if(!(q.responses[j] in responses)){responses[q.responses[j]] = 0;}
responses[q.responses[j]]++;
}
for(key in responses){response_vols.push(responses[key]);}
response_vols.sort().reverse();
if(response_vols.length == 1){return "answered";}
else if(response_vols.length > 1 && (response_vols[0]-response_vols[1]) >= 5){return "answered";}
for(key in responses){responseVols.push(responses[key]);}
responseVols.sort().reverse();
if(responseVols.length == 1){return "answered";}
else if(responseVols.length > 1 && (responseVols[0]-responseVols[1]) >= 3){return "answered";}
else{return "contested";}
}
}
function load_questions(){
var qs = node.get_instances("question");
function loadQuestions(){
var qs = node.getInstances("question");
for(var i = 0; i < qs.length; i++){
var q = {};
q.responses = [];
for(var j = 0; j < qs[i].values.length; j++){
var ins_name = typeof qs[i].values[j].instance == 'string' ? qs[i].values[j].instance : qs[i].values[j].instance.name;
q[qs[i].values[j].label] = ins_name;
var insName = typeof qs[i].values[j].instance == 'string' ? qs[i].values[j].instance : qs[i].values[j].instance.name;
q[qs[i].values[j].label] = insName;
}
for(var j = 0; j < qs[i].relationships.length; j++){
q[qs[i].relationships[j].label] = qs[i].relationships[j].instance.name;
@ -521,12 +382,12 @@ function load_questions(){
}
}
function poll_for_instances(){
function pollForInstances(){
if(node == null){
return;
}
setTimeout(function(){
var ins = node.get_instances();
var ins = node.getInstances();
for(var i = 0; i < user.questions.length; i++){user.questions[i].responses = [];}
for(var i = 0; i < ins.length; i++){
// Detect if type of card. If so, filter and add to UI if necessary
@ -534,7 +395,7 @@ function poll_for_instances(){
var tos = ins[i].is_tos;
if(tos){for(var j = 0; j < tos.length; j++){
if(tos[j].name.toLowerCase() == user.id.toLowerCase()){
add_card(ins[i]);
addCard(ins[i]);
}
}}
}
@ -570,7 +431,7 @@ function poll_for_instances(){
user.score = 0;
var ratios = {};
for(var i = 0; i < user.questions.length ; i++){
var state = get_question_state(user.questions[i]);
var state = getQuestionState(user.questions[i]);
ui.info.questions.innerHTML += '<li onclick="alert(\''+user.questions[i].text+'\');" class="response question '+state+'">'+(i+1)+'</li>';
if(state == 'answered'){
user.score++;
@ -587,33 +448,33 @@ function poll_for_instances(){
for(var type in ratios){
document.getElementById(type).style.width = Math.floor(ratios[type] * 100 / parseFloat(user.questions.length))+'%';
}
update_ui();
poll_for_instances();
updateUi();
pollForInstances();
},1000);
}
function log_cards(config){
function logCards(config){
try{
var cards = node.get_instances("card", true);
var cards = node.getInstances("card", true);
var properties = ['timestamp', 'content', 'is in reply to', 'is from', 'number of keystrokes', 'submit time', 'start time', 'latitude', 'longitude'];
var unlogged_cards = [];
var unloggedCards = [];
for(var i = 0; i < cards.length; i++){
if(config.logged_cards.indexOf(cards[i].name) == -1){
var card_to_log = {};
card_to_log.name = cards[i].name;
card_to_log.type = cards[i].type.name;
if(config.loggedCards.indexOf(cards[i].name) == -1){
var cardToLog = {};
cardToLog.name = cards[i].name;
cardToLog.type = cards[i].type.name;
for(var j = 0; j < properties.length; j++){
var prop = properties[j];
if(cards[i].property(prop)){
card_to_log[prop] = cards[i].property(prop).name || cards[i].property(prop);
cardToLog[prop] = cards[i].property(prop).name || cards[i].property(prop);
}
}
unlogged_cards.push(card_to_log);
unloggedCards.push(cardToLog);
}
}
if(unlogged_cards.length == 0){
if(unloggedCards.length == 0){
setTimeout(function(){
log_cards(config);
logCards(config);
}, 3000);
return;
}
@ -623,46 +484,48 @@ function log_cards(config){
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
setTimeout(function(){
for(var i = 0; i < unlogged_cards.length; i++){
config.logged_cards.push(unlogged_cards[i].name);
for(var i = 0; i < unloggedCards.length; i++){
config.loggedCards.push(unloggedCards[i].name);
}
log_cards(config);
logCards(config);
}, 10000);
}
else if(xhr.readyState == 4 && xhr.status != 200){
setTimeout(function(){
log_cards(config);
logCards(config);
}, 5000);
}
}
xhr.send(JSON.stringify(unlogged_cards));
xhr.send(JSON.stringify(unloggedCards));
}
catch(err){
console.log(err);
setTimeout(function(){
log_cards(config);
logCards(config);
}, 5000);
}
}
function check_online(){
function checkOnline(){
var now = new Date().getTime();
var last = node.agent.get_last_successful_request();
if (node.agent){
var last = node.agent.policyHandler.lastSuccessfulRequest;
var diff = now - last;
if(diff < 5000){
ui.info.online_status.style.backgroundColor = "green";
ui.info.onlineStatus.style.backgroundColor = "green";
}
else{
ui.info.online_status.style.backgroundColor = "rgb(200,200,200)";
ui.info.onlineStatus.style.backgroundColor = "rgb(200,200,200)";
}
}
setTimeout(function(){
check_online();
checkOnline();
}, 1000);
}
var record_position = function(position){
latest_longitude = position.coords.longitude;
latest_latitude = position.coords.latitude;
var recordPosition = function(position){
latestLongitude = position.coords.longitude;
latestLatitude = position.coords.latitude;
}
window.onresize = function(event) {
@ -676,12 +539,12 @@ window.onbeforeunload = function() {
};
window.onload = function(){
initialize_ui();
bind_listeners();
initializeUi();
bindListeners();
ui.overlays.moira.style.display = "none";
ui.overlays.dashboard.style.display = "none";
if (navigator.geolocation) {
navigator.geolocation.watchPosition(record_position);
navigator.geolocation.watchPosition(recordPosition);
}
ui.inputs.text.focus();
ui.info.cards.style.height = (window.innerHeight - 200)+'px';

127
js/sherlock-models.js Normal file
View File

@ -0,0 +1,127 @@
var SHERLOCK_CORE_MODEL = [
"conceptualise a ~ sherlock thing ~ S that is an entity and is an imageable thing",
"conceptualise an ~ organisation ~ O that is a sherlock thing",
"conceptualise a ~ fruit ~ F that is a sherlock thing and is a locatable thing",
"conceptualise a ~ room ~ R that is a location and is a sherlock thing",
"conceptualise a ~ hat colour ~ C",
"conceptualise a ~ sport ~ S",
"conceptualise a ~ character ~ C that is a sherlock thing and is a locatable thing and has the hat colour C as ~ hat colour ~",
"conceptualise the character C ~ works for ~ the organisation O and ~ eats ~ the fruit F and ~ plays ~ the sport S",
"conceptualise the hat colour C ~ is worn by ~ the character C",
"conceptualise an ~ object ~ O that is an entity",
"conceptualise the object O ~ resides in ~ the room R",
"conceptualise the room R ~ contains ~ the fruit F and has the character C as ~ contents ~ and has the object O as ~ additional contents ~",
"conceptualise the fruit F ~ is eaten by ~ the character C",
"conceptualise the sport S ~ is played by ~ the character C and ~ is in ~ the room R",
"conceptualise a ~ question ~ Q that has the value V as ~ text ~ and has the value W as ~ value ~ and has the value X as ~ relationship ~",
"conceptualise the question Q ~ concerns ~ the sherlock thing C",
"there is a rule named r1 that has 'if the character C ~ eats ~ the fruit F then the fruit F ~ is eaten by ~ the character C' as instruction",
"there is a rule named r2 that has 'if the character C ~ plays ~ the sport S then the sport S ~ is played by ~ the character C' as instruction",
"there is a rule named r3 that has 'if the character C has the hat colour S as ~ hat colour ~ then the hat colour S ~ is worn by ~ the character C' as instruction",
"there is a rule named r4 that has 'if the character C ~ is in ~ the room R then the room R has the character C as ~ contents ~' as instruction",
"there is a rule named r5 that has 'if the fruit F ~ is in ~ the room R then the room R ~ contains ~ the fruit F' as instruction",
// Inverse rules:
"there is a rule named r6 that has 'if the fruit F ~ is eaten by ~ the character C then the character C ~ eats ~ the fruit F' as instruction",
"there is a rule named r7 that has 'if the sport S ~ is played by ~ the character C then the character C ~ plays ~ the sport S' as instruction",
"there is a rule named r8 that has 'if the hat colour S ~ is worn by ~ the character C then the character C has the hat colour S as ~ hat colour ~' as instruction",
"there is a rule named r9 that has 'if the room R has the character C as ~ contents ~ then the character C ~ is in ~ the room R' as instruction",
"there is a rule named r10 that has 'if the room R ~ contains ~ the fruit F then the fruit F ~ is in ~ the room R' as instruction",
"there is a character named 'Prof Crane' that has 'http://sherlock.cenode.io/media/crane.png' as image",
"there is a character named 'Dr Finch' that has 'http://sherlock.cenode.io/media/finch.png' as image",
"there is a character named 'Col Robin' that has 'http://sherlock.cenode.io/media/robin.png' as image",
"there is a character named 'Sgt Stork' that has 'http://sherlock.cenode.io/media/stork.png' as image",
"there is a character named 'Rev Hawk' that has 'http://sherlock.cenode.io/media/hawk.png' as image",
"there is a character named 'Capt Falcon' that has 'http://sherlock.cenode.io/media/falcon.png' as image",
"there is a character named 'Elephant' that has 'http://sherlock.cenode.io/media/Elephant.png' as image",
"there is a character named 'Giraffe' that has 'http://sherlock.cenode.io/media/Giraffe.png' as image",
"there is a character named 'Hippopotamus' that has 'http://sherlock.cenode.io/media/Hippopotamus.png' as image",
"there is a character named 'Leopard' that has 'http://sherlock.cenode.io/media/Leopard.png' as image",
"there is a character named 'Lion' that has 'http://sherlock.cenode.io/media/Lion.png' as image",
"there is a character named 'Zebra' that has 'http://sherlock.cenode.io/media/Zebra.png' as image",
"there is a room named 'Ruby Room'",
"there is a room named 'Sapphire Room'",
"there is a room named 'Gold Room'",
"there is a room named 'Amber Room'",
"there is a room named 'Emerald Room'",
"there is a room named 'Silver Room'",
"there is a fruit named 'pineapple'",
"there is a fruit named 'apple'",
"there is a fruit named 'banana'",
"there is a fruit named 'orange'",
"there is a fruit named 'lemon'",
"there is a fruit named 'pear'",
"there is a fruit named 'grape'",
"there is a fruit named 'kiwi'",
"there is a fruit named 'tomato'",
"there is a hat colour named 'green'",
"there is a hat colour named 'red'",
"there is a hat colour named 'yellow'",
"there is a hat colour named 'black'",
"there is a hat colour named 'white'",
"there is a hat colour named 'purple'",
"there is a hat colour named 'pink'",
"there is a hat colour named 'blue'",
"there is a hat colour named 'brown'",
"there is a hat colour named 'grey'",
"there is a sport named 'tennis'",
"there is a sport named 'badminton'",
"there is a sport named 'rugby'",
"there is a sport named 'football'",
"there is a sport named 'soccer'",
"there is a sport named 'running'",
"there is a sport named 'swimming'",
"there is a sport named 'athletics'",
"there is a sport named 'baseball'",
"there is a sport named 'rounders'",
"there is a sport named 'softball'",
"there is a sport named 'cricket'",
"there is a sport named 'golf'",
"there is a sport named 'basketball'",
"there is a rule named objectrule1 that has 'if the object O ~ resides in ~ the room R then the room R has the object O as ~ additional contents ~' as instruction",
"there is an object named 'gorilla'",
"there is an object named 'dinosaur'",
"there is an object named 'robot'",
"there is an object named 'ghost'",
"there is an object named 'balloon'",
"there is a question named 'q1' that has 'What character eats pineapples?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'pineapple'",
"there is a question named 'q2' that has 'What sport does Zebra play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Zebra'",
"there is a question named 'q3' that has 'What character eats apples?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'apple'",
"there is a question named 'q4' that has 'What colour hat is Elephant wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Elephant'",
"there is a question named 'q6' that has 'Where is Giraffe?' as text and has 'is in' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q7' that has 'What colour hat is Lion wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Lion'",
"there is a question named 'q8' that has 'Where is Lion?' as text and has 'is in' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q9' that has 'Which character is in the emerald room?' as text and has 'contents' as value and concerns the sherlock thing 'Emerald Room'",
"there is a question named 'q12' that has 'What character eats bananas?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'banana'",
"there is a question named 'q13' that has 'What character is in the sapphire room?' as text and has 'contents' as value and concerns the sherlock thing 'Sapphire Room'",
"there is a question named 'q17' that has 'What sport does Elephant play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q18' that has 'What character is wearing a red hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'red'",
"there is a question named 'q19' that has 'What character plays rugby?' as text and has 'is played by' as relationship and concerns the sherlock thing 'rugby'",
"there is a question named 'q20' that has 'What fruit does Leopard eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Leopard'",
"there is a question named 'q23' that has 'What fruit does Giraffe eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q24' that has 'What colour hat is Zebra wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Zebra'",
"there is a question named 'q25' that has 'Where is the apple?' as text and has 'is in' as relationship and concerns the sherlock thing 'apple'",
"there is a question named 'q26' that has 'What character is wearing a yellow hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'yellow'",
"there is a question named 'q28' that has 'What fruit is in the silver room?' as text and has 'contains' as relationship and concerns the sherlock thing 'Silver Room'",
"there is a question named 'q30' that has 'What character is wearing a blue hat?' as text and has 'is worn by' as relationship and concerns the sherlock thing 'blue'",
"there is a question named 'q31' that has 'What character eats lemons?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'lemon'",
"there is a question named 'q33' that has 'What fruit does Elephant eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q34' that has 'What character plays basketball?' as text and has 'is played by' as relationship and concerns the sherlock thing 'basketball'",
"there is a question named 'q35' that has 'What character plays soccer?' as text and has 'is played by' as relationship and concerns the sherlock thing 'soccer'",
"there is a question named 'q36' that has 'What sport does Lion play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q37' that has 'What character is in the ruby room?' as text and has 'contents' as value and concerns the sherlock thing 'Ruby Room'",
"there is a question named 'q39' that has 'What character plays golf?' as text and has 'is played by' as relationship and concerns the sherlock thing 'golf'",
"there is a question named 'q40' that has 'What character eats oranges?' as text and has 'is eaten by' as relationship and concerns the sherlock thing 'orange'",
"there is a question named 'q41' that has 'What colour hat is Hippopotamus wearing?' as text and has 'hat colour' as value and concerns the sherlock thing 'Hippopotamus'",
"there is a question named 'q45' that has 'What character is in the amber room?' as text and has 'contents' as value and concerns the sherlock thing 'Amber Room'",
"there is a question named 'q47' that has 'Where is Elephant?' as text and has 'is in' as relationship and concerns the sherlock thing 'Elephant'",
"there is a question named 'q48' that has 'Where is the pear?' as text and has 'is in' as relationship and concerns the sherlock thing 'pear'",
"there is a question named 'q50' that has 'What fruit does Lion eat?' as text and has 'eats' as relationship and concerns the sherlock thing 'Lion'",
"there is a question named 'q52' that has 'What sport does Giraffe play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Giraffe'",
"there is a question named 'q53' that has 'Where is Hippopotamus?' as text and has 'is in' as relationship and concerns the sherlock thing 'Hippopotamus'",
"there is a question named 'q54' that has 'What sport does Hippopotamus play?' as text and has 'plays' as relationship and concerns the sherlock thing 'Hippopotamus'"
];

3
models/custom.js Normal file
View File

@ -0,0 +1,3 @@
var CUSTOM_MODEL= [
];

5
models/multiplayer.js Normal file
View File

@ -0,0 +1,5 @@
var CUSTOM_MODEL= [
"there is an agent named 'RemoteAgent' that has 'explorer.cenode.io' as address",
"there is a tell policy named 'p2' that has 'true' as enabled and has the agent 'RemoteAgent' as target",
"there is a listen policy named 'p4' that has 'true' as enabled and has the agent 'RemoteAgent' as target"
];

14
nginx_sherlock.conf Normal file
View File

@ -0,0 +1,14 @@
server_tokens off; # for security-by-obscurity: stop displaying nginx version
server {
listen 80 default_server;
server_name _;
root /var/www/sherlock/;
location / {
root /var/www/sherlock/;
}
location /models {
root /;
}
}

13
package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "sherlock",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"cenode": {
"version": "3.0.12",
"resolved": "https://registry.npmjs.org/cenode/-/cenode-3.0.12.tgz",
"integrity": "sha1-AU+CypoLDpOgr9oigEddDoVkpj4="
}
}
}

13
package.json Normal file
View File

@ -0,0 +1,13 @@
{
"name": "sherlock",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/flyingsparx/sherlock.git"
},
"author": "Will Webberley & Alun Preece",
"license": "Apache-2.0",
"dependencies": {
"cenode": "^3.0.11"
}
}