ignore draws
ci/woodpecker/push/tools-wasm-pack-plugin Pipeline was successful Details
ci/woodpecker/push/wasm-o-x-rust Pipeline was successful Details

This commit is contained in:
Gleb Koval 2022-08-08 00:32:21 +00:00
parent a0500d142d
commit 440218b513
Signed by: cyclane
GPG Key ID: 15E168A8B332382C
3 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@ dependencies = [
[[package]]
name = "o-x-rust"
version = "0.0.6"
version = "0.0.7"
dependencies = [
"wasm-bindgen",
]

View File

@ -4,7 +4,7 @@ description = "Noughts and crosses WASM algorithms"
repository = "https://git.koval.net/cyclane/game-algorithms/src/branch/main/wasm/o-x-rust"
license = "GNU GPLv3"
readme = "README.md"
version = "0.0.6"
version = "0.0.7"
edition = "2021"
[lib]

View File

@ -40,15 +40,15 @@ pub fn get_score(me: u8, other: u8, first: bool, board: &[u8]) -> f64 {
score as f64 / outcomes as f64
}
// outcomes*2, winning outcomes (win = 2, draw = 1, loose = 0)
// outcomes, winning outcomes
pub fn sub_get_score(me: u8, other: u8, first: bool, board: &[u8]) -> (i32, i32) {
let winner = find_winner(board);
if winner != 0 {
return if winner == me { (2, 2) } else { (2, 0) };
return if winner == me { (1, 1) } else { (1, 0) };
}
let empty = count_empty(board);
if empty == 0 {
return (2, 1);
return (1, 0);
}
let mut score = 0;
let mut outcomes = 0;