Skip to content

Commit

Permalink
configure github pages deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Oct 12, 2023
1 parent 593d3ab commit 3262c4c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 8 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Deploy
on:
push:
branches:
- "master"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/setup-node@v3
with:
node-version: "20"
- name: build
run: |
cd web
npm install
npm run build
- name: archive web build
uses: actions/upload-artifact@v3
with:
name: github-pages
path: ./web/dist

deploy:
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
with:
artifact_name: github-pages
6 changes: 6 additions & 0 deletions chessbot/src/evaluator/nneteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ impl NnetEval {

impl Evaluator for NnetEval {
fn evaluate(&self, board: &chess::Board) -> anyhow::Result<f32> {
match board.status() {
chess::BoardStatus::Ongoing => {}
chess::BoardStatus::Checkmate => return Ok(-10000.0),
chess::BoardStatus::Stalemate => return Ok(-9000.0),
}

let tensor =
NnetEval::board_to_input(board).context("failed to create tensor for board")?;
let output = self
Expand Down
4 changes: 2 additions & 2 deletions chessbot/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use chess::{ChessMove, MoveGen};


use chessbot::search::{alphabeta::AlphaBeta, MoveSearch};

mod evaluator;
Expand Down
2 changes: 1 addition & 1 deletion chessbot/src/search/alphabeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use chess::ChessMove;
use chess::MoveGen;

use crate::evaluator::Evaluator;
use crate::evaluator::PointsEval;


use super::MoveSearch;
use super::ScoredMove;
Expand Down
2 changes: 1 addition & 1 deletion chessbot/src/search/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chess::{Board, ChessMove, Color, MoveGen};
use chess::{Board};

pub mod alphabeta;
pub mod simpleminmax;
Expand Down
2 changes: 1 addition & 1 deletion chessbot/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chess::{Board, ChessMove, Color, File, Game, MoveGen, Rank, Square};
use chess::{Board, Color, File, Rank, Square};
use colored::Colorize;

pub fn display_board(board: &Board, ascii: bool) -> String {
Expand Down
3 changes: 2 additions & 1 deletion modeltraining/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __getitem__(self, idx):
assert(len(bitvec) == lib.game.tensor_packed_len)
bin = np.frombuffer(bitvec, dtype=np.uint8)
bin = np.unpackbits(bin, axis=0).astype(np.single)[0:lib.game.tensor_len]
score = math.copysign(math.log2(abs(score / 10.0) + 1), score) # the more extreme the win the less we weight it, we just want to bias towards winning.
score = score / 100.0
# score = math.copysign(math.log2(abs(score / 10.0) + 1), score) # the more extreme the win the less we weight it, we just want to bias towards winning.
return {
'binary': bin,
'eval': np.array([score]).astype(np.single)
Expand Down
3 changes: 1 addition & 2 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::str::FromStr;

use chessbot::{
evaluator::{self, Evaluator},
search::simpleminmax::SimpleMinMax,
evaluator::{self},
search::{alphabeta::AlphaBeta, MoveSearch},
};
use wasm_bindgen::prelude::*;
Expand Down

0 comments on commit 3262c4c

Please sign in to comment.