GithubHelp home page GithubHelp logo

isabella232 / correlations-game Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ftlabs/correlations-game

0.0 0.0 0.0 611 KB

A Node.js app for playing the FT Labs Correlation game

JavaScript 26.73% CSS 0.15% HTML 73.12%

correlations-game's Introduction

FT Labs Correlations Game

What is it?

This is an API for playing the FT Labs Correlations game.

How do I play it?

The game is simple. We ask you which of three people (persons B, C, and D) have recently been mentioned in an article with person A. If you know the answer (or guess correctly), the same question will be asked, but with the person from the previous round being used as the seed for the options in this round.

API

API Order

To play the game to completion, the consumer of the API must interact with the endpoints (described later in this document) in a certain order. A typical interaction should look like this:

  1. GET /interface/start
  2. GET /interface/question/:gameUUID
  3. GET /interface/answer/:gameUUID/:submittedAnswer

Steps 2. and 3. repeat until the game has either been won or lost by the user.

If an incorrect answer is given, the game will be declared as over, and the /interface/question endpoint will no longer return new questions for that gameUUID. At this point, the client must call /interface/start to begin a new game and get a new gameUUID.

API Endpoints

All example responses assume the request has been successfully completed

GET /interface/start

// Example Response
{
	"status" : "OK",
	"data" : {
		"gameID" : "19bc851b-3632-46df-917d-967605922b23"
	}
}

GET /interface/question/:gameUUID

// Example Response
{
	"status" : "ok",
	"data" : {
		"seed" : "people:Xi Jinping",
		"options" : {
			"a" : "people:Christine Lagarde",
			"b" : "people:Donald Trump Jr.",
			"c" : "people:Alexis Tsipras"
		}
	}
}

GET /interface/answer/:gameUUID/:submittedAnswer

// Example response (if correct answer is given)
{
	"status" : "ok",
	"correct" : true
}

// Example response (if incorrect answer is given)
{
	"status" : "ok",
	"correct" : false
}

For local dev/testing: index routes

The following env params need to be set:

  • CORRELATION_SERVICE_HOST=...
  • CORRELATIONS_SERVICE_TOKEN=...

... and if you want to avoid using AWS DynamoDB

  • DATABASE=PRETEND
    • NB: always start a new session after restarting the server, since this DB in in-memory only.

The following env params may be set:

  • BARNIER_LIST=people:Michel Barnier,people:Nancy Pelosi
  • DEBUG=correlations-game:*,bin:lib:*

... to explore alternative game mechanics

  • MAX_CANDIDATES=10 # to limit the game size (default is -1, meaning no limit)
  • FIRST_FEW_MAX=5 # which subset of the most-connected candidates to choose from
  • GAME_VARIANT=any_seed # which is the default
    • Other values are:
    • any_seed # pick any candidate, denylist candidate
    • any_seed_kill_answer # pick any candidate, denylist candidate and answer
    • seed_from_answer # pick initial any candidate then only from answer, denylist candidate
    • seed_from_answer_or_any # pick initial any candidate then from answer or any, denylist candidate
  • GAME_DISTANCE_OF_WRONG1=2 # how many chainLengths away to start looking for the first wrong answer - the further away, the 'easier' the question becomes because the wrong answers are 'wronger'
  • GAME_DISTANCE_OF_WRONG2=3 # ditto the 2nd wrong answer. Too far is bad because the number of candidates per link drops drastically after 3.
  • TEST_MODE=true # Bypasses verification processes for use with Alexa tester (or other general purpose test tools)

routes

  • GET / - start a new session
  • GET /stats - view the games stats, system response times, etc

correlations-game's People

Contributors

seanmtracey avatar railsagainstignorance avatar jamiebrown201 avatar lily2point0 avatar jdevt avatar snyk-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.