Skip to content

Commit

Permalink
ci/cd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sparshg committed Aug 29, 2024
1 parent a3fe072 commit e373f98
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ jobs:
- name: Build the project
run: cargo build --target wasm32-unknown-unknown --release

- name: Run wasm-bindgen
run: wasm-bindgen --out-dir ./out --target web ./target/wasm32-unknown-unknown/release/asteroids_genetic.wasm

- name: Copy static files
run: |
cp ./target/release/wasm32-unknown-unknown/genetic.wasm ./out/genetic.wasm
cp ./target/wasm32-unknown-unknown/release/genetic.wasm ./out/genetic.wasm
cp ./index.html ./out/index.html
- name: Deploy to GitHub Pages
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ macroquad = "0.4.13"
nalgebra = { version = "0.33.0", features = ["serde-serialize"] }
serde = { version = "1.0.189", features = ["derive"] }
serde_json = "1.0.107"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tinyfiledialogs = "3.9.1"

[profile.dev]
Expand Down
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html lang="en">

<head>
<meta charset="utf-8">
<title>Asteroids</title>
<style>
html,
body,
canvas {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background: black;
z-index: 0;
outline: none;
}
</style>
</head>

<body>
<canvas id="glcanvas" tabindex='1'></canvas>
<script src="https://not-fl3.github.io/miniquad-samples/gl.js"></script>
<script>load("genetic.wasm");</script>
</body>

</html>
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use macroquad::{
ui::{hash, root_ui, widgets},
};
use population::{AutoSwitch, Population};
#[cfg(not(target_arch = "wasm32"))]
use tinyfiledialogs::{open_file_dialog, save_file_dialog};
use world::World;

Expand Down Expand Up @@ -185,6 +186,7 @@ async fn main() {
// ui.same_line(242.);
ui.same_line(ui_width - 329.);
if widgets::Button::new("Load Model").ui(ui) {
#[cfg(not(target_arch = "wasm32"))]
if let Some(path) = open_file_dialog("Load Model", "model.json", None) {
let brain = NN::import(&path);
size = 1;
Expand Down Expand Up @@ -216,6 +218,7 @@ async fn main() {
}
ui.same_line(0.);
if widgets::Button::new("Save Model").ui(ui) {
#[cfg(not(target_arch = "wasm32"))]
if let Some(path) = save_file_dialog("Save Model", "model.json") {
pop.worlds[pop.track].export_brain(&path);
}
Expand Down

0 comments on commit e373f98

Please sign in to comment.