Skip to content

MehraB832/shorelark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐦 Shorelark

Simulation of evolution, powered by neural networks, genetic algorithms & high-school math:

screenshot

Feeling curious? I've described the implementation ab ovo on my blog: Learning to Fly.

Building

Using Nix

# 1/3: Clone the repository
$ git clone https://github.com/Patryk27/shorelark
$ cd shorelark

# 2/3: Build the application
#      (this might take a few minutes)
$ nix build
#
# ^ This command will create a directory called `result`
#   that'll contain the compiled WebAssembly code and a few
#   frontend files.
#
# If `nix build` fails, you might be using an older version
# of Nix that doesn't support flakes - if that's the case,
# please use this command instead:
#
# $ nix-build

# 3/3: Start the frontend application
$ nix shell nixpkgs#php -c php -S localhost:8080 -t result
#
# ^ After launching this, open `http://localhost:8080` in
#   your web browser - you should see the simulation working
#   as the doctor ordered :-)

# > But why are we downloading PHP? This seems insane!
# 
# It's due to CORS:
# https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local
#
# Bottom line: it's not possible to open a local HTML file
# and make it load WebAssembly code - there *has* to be a
# web server used; and it just happens that PHP includes 
# a simple web server out of the box.
#
# If you don't want PHP on your machine - :-) - anything
# from this list will do the work, too:
#
# https://gist.github.com/willurd/5720255

Using Cargo and npm

Requires cargo, npm and wasm-pack (0.11.0):

# 1/3: Clone the repository
$ git clone https://github.com/Patryk27/shorelark
$ cd shorelark

# 2/3: Compile Rust into WebAssembly
#      (this might take a minute)
$ cd libs/simulation-wasm
$ wasm-pack build --release

# 3/3: Start the frontend application
$ cd ../../www
$ npm install
$ npm run start

# ^ After launching this, open `http://localhost:8080` in
#   your web browser - you should see the simulation working
#   as the doctor ordered :-)

Usage

Shorelark contains a simple in-game introduction - just read what the terminal on the left side says and have fun!

License

Copyright (c) 2020 Patryk Wychowaniec pwychowaniec@pm.me.
Licensed under the MIT license.

Releases

No releases published

Packages

No packages published

Languages

  • Rust 71.3%
  • JavaScript 22.0%
  • Nix 4.9%
  • Other 1.8%