Compare commits
4 Commits
master
...
cenode-v3-
Author | SHA1 | Date | |
---|---|---|---|
|
3d0106787b | ||
|
be40c09631 | ||
|
3df62f560b | ||
|
867915c9d4 |
14
Dockerfile
14
Dockerfile
@ -1,14 +0,0 @@
|
||||
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,71 +1,14 @@
|
||||
# SHERLOCK
|
||||
|
||||
## Introduction
|
||||
|
||||
This repository contains the source code for the ITA project's SHERLOCK game for Controlled English experiments.
|
||||
This repository contains the source code for the ITA project's SHERLOCK game for CE experiments.
|
||||
|
||||
The game uses the CENode library to maintain a knowledge base, which is described purely in ITA Controlled English.
|
||||
|
||||
For more information on the ITA project and CENode, take a look at the following webpages:
|
||||
For more information, take a look at the following webpages:
|
||||
|
||||
* [dais-ita.org/pub](https://dais-ita.org/pub)
|
||||
* [usukita.org](https://www.usukita.org)
|
||||
* [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.
|
||||
|
@ -20,7 +20,7 @@
|
||||
<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>
|
||||
@ -35,6 +35,7 @@
|
||||
<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>
|
||||
@ -45,6 +46,7 @@
|
||||
<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">
|
||||
@ -64,7 +66,6 @@
|
||||
<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>
|
||||
|
22
js/main.js
22
js/main.js
@ -6,13 +6,13 @@ var scoredCards = [];
|
||||
var spacePressed = 0;
|
||||
var lastSpacePressed = 0;
|
||||
var forbidInput = false;
|
||||
//var multiplayer;
|
||||
var multiplayer;
|
||||
var latestLatitude = null;
|
||||
var latestLongitude = null;
|
||||
|
||||
var loggingConfigs = [
|
||||
//{url: 'http://logger.cenode.io/cards/sherlock', loggedCards: []},
|
||||
//{url: 'http://logger2.cenode.io/cards/sherlock', loggedCards: []}
|
||||
{url: 'http://logger.cenode.io/cards/sherlock', loggedCards: []},
|
||||
{url: 'http://logger2.cenode.io/cards/sherlock', loggedCards: []}
|
||||
];
|
||||
|
||||
var settings = {
|
||||
@ -48,7 +48,7 @@ var ui = {
|
||||
text : null,
|
||||
guess : null,
|
||||
autofill : null,
|
||||
//multiplayer: null
|
||||
multiplayer: null
|
||||
},
|
||||
overlays : {
|
||||
login : null,
|
||||
@ -72,7 +72,7 @@ function initializeUi(){
|
||||
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");
|
||||
@ -107,21 +107,21 @@ function login(e){
|
||||
}
|
||||
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.loginError.style.display = "block";
|
||||
return;
|
||||
}
|
||||
|
||||
//if(MULTIPLAYER_MODEL){
|
||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
|
||||
if(multiplayer){
|
||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, SHERLOCK_NODE_MODEL);
|
||||
ui.info.onlineStatus.style.display = "block";
|
||||
checkOnline();
|
||||
/*}
|
||||
}
|
||||
else{
|
||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL, CUSTOM_MODEL);
|
||||
node = new CENode(CEModels.core, SHERLOCK_CORE_MODEL);
|
||||
ui.info.onlineStatus.style.display = "none";
|
||||
}*/
|
||||
}
|
||||
node.attachAgent();
|
||||
node.agent.setName(user.id+" agent");
|
||||
window.setTimeout(function(){
|
||||
|
@ -125,3 +125,9 @@ 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 '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"
|
||||
];
|
||||
|
@ -1,3 +0,0 @@
|
||||
var CUSTOM_MODEL= [
|
||||
|
||||
];
|
@ -1,5 +0,0 @@
|
||||
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"
|
||||
];
|
@ -1,14 +0,0 @@
|
||||
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
13
package-lock.json
generated
@ -1,13 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"cenode": "^3.0.11"
|
||||
"cenode": "^3.0.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user