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 2868454
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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
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
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

0 comments on commit 2868454

Please sign in to comment.