Critters must catch food (green circles) and avoid dangers (red squares). The brain of each critter is a small feedforward neural network. Brains are trained using a genetic algorithm to simulate evolution. Every 20 seconds, the five best critters of the latest generation are sent to the simulation rendered on the web page.
This is a JavaScript port of my critters project written in C.
The build process requires the Google Closure Compiler, which is a JavaScript-to-JavaScript compiler/minifier. The latest version can be downloaded here.
Google Closure Compiler requires Java 8 to run.
The build process also requires GNU make installed on your system.
The only runtime requirement is a web browser.
Download the latest Google Closure Compiler from Download the latest Google Closure Compiler from here (.zip) or here (.tar.gz) and extract the downloaded .zip or .tar.gz file into the closure/ directory. The compiler itself is a .jar file with a name similar to closure-compiler-v20190819.jar (the date may be different).
cd closure
wget https://dl.google.com/closure-compiler/compiler-latest.tar.gz
tar -xzf compiler-latest.tar.gz
cd ..
Change to the repository's top directory and run make:
make
This command invokes the compiler with the correct arguments. The generated files are placed in the target/ directory.
If you are using a web browser other than Google Chrome, running the application is probably as simple as opening the target/index.html file in your browser.
The issue with running this application in Chrome is that it does not allow
running a web worker from a local file. A possible workaround is to start
Chrome with the --allow-file-access-from-files
argument. The run-with-chrome
bash script at the top of the repository does this for you. For this workaround
to work, all Chrome windows have to be closed beforehand.
Alternatively, the application can be served with any HTTP server so the
web worker's code is no longer a local file. For example, if you have Python 3
installed, simply change into the target directory and start the built in
HTTP server, then point your web browser to localhost:8000
.
cd target
python -m http.server
More detail and other possible workarounds can be found in this Stack Overflow question.