GithubHelp home page GithubHelp logo

connectfour's Introduction

connectfour

connectfour app for cloud computing.

Once pushed, Travis-Cl will automatically deploy it to Heroku.

Configure Travis-Cl for Node+Heroku or this

API Docs

GET /index

Request: nil

Response: Array of bots in JSON format

[
	{
		'userid': '123114125545345',
		'bot': {
			'id': 0,
			'code': 'return Math.floor(Math.random()*7);',
			'name': 'Bot0',
			'lang': 'js',
			'score': 800,
			'win': 2,
			'lose': 1
		}
	},
	{
		'userid': '19823712364987',
		'bot': {
			'id': 0,
			'code': 'return randint(0, 6)',
			'name': 'Bot0',
			'lang': 'js',
			'score': 800,
			'win': 0,
			'lose': 0
		}
	}
]

POST /login

Request:

Type: application/json

Options:

{
	'userid': 'userid',
	'name': 'name'
}

Response:

New User (example)

{
	id: "the fbid being sent"
	email: "[email protected],
	bots: [
		{
			code: "return randint(0,6)"
			id: 0
			lang: "js"
			lose: 0
			name: "Bot0"
			score: 800
			win: 0
		}
	]
}

Existing User (example)

{
	id: 123,
	email: "[email protected]"
	bots: [
		{
			code: "return Math.floor(Math.random()*6);"
			id: 1
			lang: "js"
			lose: 0
			name: "Bot1"
			score: 800
			win: 0
		},
		{
			code: "return randint(0,6)"
			id: 2
			lang: "python"
			lose: 10
			name: "Bot2"
			score: 800
			win: 11
		}
	]	
}

GET /leaderboard

Request: nil

Response: Array of bots with its respective userid in JSON format

[
	{
		"userid":"bob",
 		"bot": {
 			"code": "return randint(0,6)",
 			"id":0,
 			"lang":"python",
 			"lose":11,
 			"name":
 			"anotherUser's Bot",
 			"score":1000,
 			"win":11
 		}
 	},
	{
		"userid": "1234567",
		"bot": {
			"code":"return randint(0,6)",
			"id":0,
			"lang":"js",
			"lose":0,
			"name":"Bot0",
			"score":800,
			"win":0
		}
	},
	{
		"userid":"kawi",
		"bot": {
			"code":"return randint(0,6)",
			"id":2,
			"lang":"python",
			"lose":10,
			"name":"Bot2",
			"score":800,
			"win":11
		}
	},
	{
		"userid":"kawi",
		"bot": {
			"code":"return Math.floor(Math.random()*6);",
			"id":1,
			"lang":"js",
			"lose":0,
			"name":"Bot1",
			"score":800,
			"win":0
		}
	}
]

POST /submit_bot

Request:

type: application/json

values:

{
	"bot": "actual code written by the user",
	"lang": "python or js",
	"userid": "user id or facebook id",
	"bot_name": "name of the bot"
}

Response:

Syntax Error (JSON):

{"success": false, "error": "invalid syntax"}

Bad Move (JSON):

{"success": false, "error": "bot cause invalid move"}

Success (JSON):

{
	"success": true,
	"error": null,
	"bot": {
		'code': code,
		'id': 0,
		'lang': lang,
		'name': "Bot0",
		'score': 800,
		'win': 0,
		'lose': 0
	}
}

POST /edit_bot

Request:

type: application/json

values:

{
	"bot": "actual code written by the user",
	"lang": "python or js",
	"bot_id": "id of the bot",
	"userid": "user id or facebook id",
	"bot_name": "name of the bot"
}

Response:

Syntax Error (JSON):

{"success": false, "error": "invalid syntax"}

Bad Move (JSON):

{"success": false, "error": "bot cause invalid move"}

Success (JSON):

{
	"success": true,
	"error": null,
	"bot": {
		'code': code,
		'id': 0,
		'lang': 'lang',
		'name': 'Bot0',
		'score': 800,
		'win': 0,
		'lose': 0
	}
}

POST /play

Request:

type: application/json

value:

{
	"bot1": {
		"userid": "kawi",
		"botid": "1"
	},
	"bot2": {
		"userid": "bob",
		"botid": "0"
	}
}

Response:

{
	"winner": { "userid": "kawi", "botid": 1 },
	"bad_move": null,
	"steps":[
		"_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n",
		"_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,R,_,_,_,_,_,\n",
		"_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,\n_,R,_,_,_,W,_,\n",
		"_,_,_,_,_,_,_,\n_,_,_,_,_,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W,_,\nR,R,R,R,W,W,R,\n",
		"_,_,_,R,_,_,_,\nW,R,_,W,_,_,_,\nW,W,_,W,_,_,_,\nW,R,_,R,W,R,_,\nR,W,_,R,W,W,_,\nR,R,R,R,W,W,R,\n",
		"R,_,_,R,_,_,_,\nW,R,_,W,_,_,_,\nW,W,_,W,_,_,_,\nW,R,_,R,W,R,_,\nR,W,_,R,W,W,_,\nR,R,R,R,W,W,R,\n",
		"R,_,_,R,_,_,_,\nW,R,_,W,_,_,_,\nW,W,_,W,_,W,_,\nW,R,_,R,W,R,_,\nR,W,_,R,W,W,_,\nR,R,R,R,W,W,R,\n",
		"R,_,_,R,_,_,_,\nW,R,_,W,_,_,_,\nW,W,_,W,_,W,_,\nW,R,_,R,W,R,_,\nR,W,R,R,W,W,_,\nR,R,R,R,W,W,R,\n"
	]
}

connectfour's People

Contributors

dino198 avatar kelvinnn avatar neoborn avatar

Watchers

 avatar  avatar  avatar

Forkers

erwinhuang1612

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.