Machine-Learning-Flappy-Bird icon indicating copy to clipboard operation
Machine-Learning-Flappy-Bird copied to clipboard

a step-by-step guide

Open Aspirinkb opened this issue 8 years ago • 5 comments

Hi, it is a nice work to learning machine learning and I like it very much. I am new to HTML and JS, can you give a step-by-step guide to install, train and play this game?

Aspirinkb avatar Aug 17 '17 02:08 Aspirinkb

If you run index.html via file:// or C:/, then the program isn't going to work.

Instead, you need to run it via a web server.

A simple solution is to invoke python -m SimpleHttpServer from the directory containing index.html, then point your browser to localhost:8000 (or whatever port Python tells you it's running on).

jcgoodru avatar Nov 18 '17 17:11 jcgoodru

@jcgoodru can u explain why do we need to run it from a web server ? 😊

fahimalizain avatar Dec 06 '17 09:12 fahimalizain

If you open index.html via file:// or C:/, and open the javascript console in your browser, you'll see an error message that looks something like this:

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https

I'm not 100% sure of all the details, but basically if you open a web page via file://, your browser won't allow you to get/send requests to other servers. This is for security reasons (ex: webpages launched via file:// can access your entire filesystem and can execute malicious code, but pages rendered via webservers usually don't have these permissions).

I don't know enough to give a detailed explanation, but here are some relevant links:

https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local https://bitmovin.com/same-origin-policy-cors-and-crossdomain-xml-what-you-need-to-know/

jcgoodru avatar Dec 06 '17 18:12 jcgoodru

Use python -m http.server for Python3.

roachsinai avatar Feb 09 '19 13:02 roachsinai

  1. modify gameplay.js (Line 46) : Phaser.ScaleManager.SHOW_ALL -> Phaser.ScaleManager.NO_SCALE

  2. python -m SimpleHTTPServer from the directory containing index.html

  3. open http://localhost:8000

ouyanx avatar May 16 '19 07:05 ouyanx