Compare commits
4 Commits
cenode-v3-
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
fab9967747 | ||
|
0264801299 | ||
|
040f5528ea | ||
|
8c30cc246f |
14
Dockerfile
Normal file
14
Dockerfile
Normal 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
|
63
README.md
63
README.md
@ -1,14 +1,71 @@
|
|||||||
# SHERLOCK
|
# 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.
|
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)
|
* [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
|
## Licensing
|
||||||
|
|
||||||
The contents of this repository are licensed under the Apache License v2. See LICENSE for further information.
|
The contents of this repository are licensed under the Apache License v2. See LICENSE for further information.
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<input class="username clear" id="login_username" placeholder="User ID" type="text" autofocus>
|
<input class="username clear" id="login_username" placeholder="User ID" type="text" autofocus>
|
||||||
<div class="clear"></div>
|
<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>
|
<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>
|
<div class="clear"></div>
|
||||||
<button id="login">Login</button>
|
<button id="login">Login</button>
|
||||||
</div>
|
</div>
|
||||||
@ -35,7 +35,6 @@
|
|||||||
<div id="unanswered"></div>
|
<div id="unanswered"></div>
|
||||||
</div>
|
</div>
|
||||||
<button class="change_view dashboard" data-view="dashboard" id="score">Dashboard</button>
|
<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 id="online_status" class="status"></div>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
@ -46,7 +45,6 @@
|
|||||||
<input id="autofill" type="checkbox" checked="checked"/><span style="margin-left:5px;">Input suggestions</span>
|
<input id="autofill" type="checkbox" checked="checked"/><span style="margin-left:5px;">Input suggestions</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align:left;margin-left:1%;display:inline-block;float:left;">
|
<div style="text-align:left;margin-left:1%;display:inline-block;float:left;">
|
||||||
<!-- <div id="online_status" class="status"></div>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="text_input_area">
|
<div id="text_input_area">
|
||||||
@ -66,6 +64,7 @@
|
|||||||
<script src="node_modules/cenode/dist/cenode.min.js"></script>
|
<script src="node_modules/cenode/dist/cenode.min.js"></script>
|
||||||
<script src="node_modules/cenode/dist/models.js"></script>
|
<script src="node_modules/cenode/dist/models.js"></script>
|
||||||
<script src="js/sherlock-models.js"></script>
|
<script src="js/sherlock-models.js"></script>
|
||||||
|
<script src="models/custom.js"></script>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
22
js/main.js
22
js/main.js
@ -6,13 +6,13 @@ var scoredCards = [];
|
|||||||
var spacePressed = 0;
|
var spacePressed = 0;
|
||||||
var lastSpacePressed = 0;
|
var lastSpacePressed = 0;
|
||||||
var forbidInput = false;
|
var forbidInput = false;
|
||||||
var multiplayer;
|
//var multiplayer;
|
||||||
var latestLatitude = null;
|
var latestLatitude = null;
|
||||||
var latestLongitude = null;
|
var latestLongitude = null;
|
||||||
|
|
||||||
var loggingConfigs = [
|
var loggingConfigs = [
|
||||||
{url: 'http://logger.cenode.io/cards/sherlock', loggedCards: []},
|
//{url: 'http://logger.cenode.io/cards/sherlock', loggedCards: []},
|
||||||
{url: 'http://logger2.cenode.io/cards/sherlock', loggedCards: []}
|
//{url: 'http://logger2.cenode.io/cards/sherlock', loggedCards: []}
|
||||||
];
|
];
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
@ -48,7 +48,7 @@ var ui = {
|
|||||||
text : null,
|
text : null,
|
||||||
guess : null,
|
guess : null,
|
||||||
autofill : null,
|
autofill : null,
|
||||||
multiplayer: null
|
//multiplayer: null
|
||||||
},
|
},
|
||||||
overlays : {
|
overlays : {
|
||||||
login : null,
|
login : null,
|
||||||
@ -72,7 +72,7 @@ function initializeUi(){
|
|||||||
ui.inputs.text = document.getElementById("text");
|
ui.inputs.text = document.getElementById("text");
|
||||||
ui.inputs.guess = document.getElementById("guess");
|
ui.inputs.guess = document.getElementById("guess");
|
||||||
ui.inputs.autofill = document.getElementById("autofill");
|
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.login = document.getElementById("login_overlay");
|
||||||
ui.overlays.moira = document.getElementById("moira_overlay");
|
ui.overlays.moira = document.getElementById("moira_overlay");
|
||||||
ui.overlays.dashboard = document.getElementById("dashboard_overlay");
|
ui.overlays.dashboard = document.getElementById("dashboard_overlay");
|
||||||
@ -107,21 +107,21 @@ function login(e){
|
|||||||
}
|
}
|
||||||
user.id = ui.inputs.loginUserId.value.charAt(0).toUpperCase() + ui.inputs.loginUserId.value.slice(1);
|
user.id = ui.inputs.loginUserId.value.charAt(0).toUpperCase() + ui.inputs.loginUserId.value.slice(1);
|
||||||
user.id = user.id.trim();
|
user.id = user.id.trim();
|
||||||
multiplayer = ui.inputs.multiplayer.checked == true;
|
//multiplayer = ui.inputs.multiplayer.checked == true;
|
||||||
if(user.id == null || user.id == ""){
|
if(user.id == null || user.id == ""){
|
||||||
ui.info.loginError.style.display = "block";
|
ui.info.loginError.style.display = "block";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(multiplayer){
|
//if(MULTIPLAYER_MODEL){
|
||||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, SHERLOCK_NODE_MODEL);
|
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
|
||||||
ui.info.onlineStatus.style.display = "block";
|
ui.info.onlineStatus.style.display = "block";
|
||||||
checkOnline();
|
checkOnline();
|
||||||
}
|
/*}
|
||||||
else{
|
else{
|
||||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL);
|
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
|
||||||
ui.info.onlineStatus.style.display = "none";
|
ui.info.onlineStatus.style.display = "none";
|
||||||
}
|
}*/
|
||||||
node.attachAgent();
|
node.attachAgent();
|
||||||
node.agent.setName(user.id+" agent");
|
node.agent.setName(user.id+" agent");
|
||||||
window.setTimeout(function(){
|
window.setTimeout(function(){
|
||||||
|
@ -125,9 +125,3 @@ var SHERLOCK_CORE_MODEL = [
|
|||||||
"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 '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'"
|
"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_MODEL = [
|
|
||||||
"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"
|
|
||||||
];
|
|
||||||
|
3
models/custom.js
Normal file
3
models/custom.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
var CUSTOM_MODEL= [
|
||||||
|
|
||||||
|
];
|
5
models/multiplayer.js
Normal file
5
models/multiplayer.js
Normal 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
14
nginx_sherlock.conf
Normal 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
13
package-lock.json
generated
Normal 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="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,6 @@
|
|||||||
"author": "Will Webberley & Alun Preece",
|
"author": "Will Webberley & Alun Preece",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cenode": "^3.0.3"
|
"cenode": "^3.0.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user