From dc1fe02d599d6e0a86bcc6500c111455decdd6df Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 5 Apr 2017 21:07:20 +0430 Subject: [PATCH 1/6] move to /flappy-bird --- web/server.js | 13 ++++++++----- web/static/index.html | 3 --- web/static/js/main.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/server.js b/web/server.js index fee7836..1a2e399 100644 --- a/web/server.js +++ b/web/server.js @@ -4,17 +4,18 @@ var express = require('express'), io = require('socket.io')(server) exec = require('child_process').exec compression = require('compression') - path = require('path'); + path = require('path'), + router = express.Router(); server.listen(8088); -app.use(express.static(__dirname + '/static')) -app.use(compression()) -app.use('/assets/', express.static(__dirname + '/../assets/')) +router.use(express.static(__dirname + '/static')) +router.use(compression()) +router.use('/assets/', express.static(__dirname + '/../assets/')) var record = path.resolve(__dirname, '../record.py'); -app.get('/play', function(request, response) { +router.get('/play', function(request, response) { var child = exec('python3 ' + record, { maxBuffer: 1024 * 5000 }, function(err, out, stderr) { if (err || stderr) { console.log(err || stderr) @@ -26,3 +27,5 @@ app.get('/play', function(request, response) { child.stdout.pipe(response); }); + +app.use('/flappy-bird', router); diff --git a/web/static/index.html b/web/static/index.html index ba7dc49..a686b4e 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -3,9 +3,6 @@ Playing Flappy Bird using Evolution Strategies - - - diff --git a/web/static/js/main.js b/web/static/js/main.js index 98df2fd..c1fa50b 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -513,7 +513,7 @@ function newGame() { $('#loading').addClass('active'); - fetch('/play').then(res => res.json()).then(function(states) { + fetch('play').then(res => res.json()).then(function(states) { playing = true; $('#loading').removeClass('active'); -- 2.34.1 From 2d5009e5bbf4fb015e95730d9d161715b1e29b35 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Thu, 6 Apr 2017 23:06:50 +0430 Subject: [PATCH 2/6] fix: mention the maximum frame limit --- web/static/index.html | 2 ++ web/static/style.css | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/web/static/index.html b/web/static/index.html index a686b4e..4e7f315 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -63,6 +63,8 @@ + +

Note: we have limited the game to run only for 10000 frames to avoid infinitely long games, if you want to watch the game indefinitely, get the python version and try it yourself.