-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
╔══════════════════════════════════════════════════════════╗ ║ Name Elo Error Wins Loss Draw Total ║ ╠══════════════════════════════════════════════════════════╣ ║ 1. Mexx -102 83 23 42 0 65 ║ ║ 2. MexxMontyPolicy +102 83 42 23 0 65 ║ ╚══════════════════════════════════════════════════════════╝
- Loading branch information
1 parent
2e87021
commit 4578e25
Showing
7 changed files
with
119 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use goober::SparseVector; | ||
|
||
use super::policy::PolicyNetwork; | ||
use super::simulate::ValueNetwork; | ||
|
||
#[repr(C)] | ||
pub struct Nets(pub ValueNetwork<2916, 256>, pub PolicyNetwork); | ||
|
||
pub const NETS: Nets = | ||
unsafe { std::mem::transmute(*include_bytes!("../../resources/net.network")) }; | ||
|
||
pub fn value_feature_map<F: FnMut(usize)>(position: &ataxx::Position, mut f: F) { | ||
const PER_TUPLE: usize = 3usize.pow(4); | ||
const POWERS: [usize; 4] = [1, 3, 9, 27]; | ||
const MASK: u64 = 0b0001_1000_0011; | ||
|
||
let friends = position.bitboard(position.side_to_move).0; | ||
let enemies = position.bitboard(!position.side_to_move).0; | ||
|
||
for i in 0..6 { | ||
for j in 0..6 { | ||
let tuple = 6 * i + j; | ||
let mut feat = PER_TUPLE * tuple; | ||
|
||
let offset = 7 * i + j; | ||
let mut b = (friends >> offset) & MASK; | ||
let mut o = (enemies >> offset) & MASK; | ||
|
||
while b > 0 { | ||
let mut sq = b.trailing_zeros() as usize; | ||
if sq > 6 { | ||
sq -= 5; | ||
} | ||
|
||
feat += POWERS[sq]; | ||
|
||
b &= b - 1; | ||
} | ||
|
||
while o > 0 { | ||
let mut sq = o.trailing_zeros() as usize; | ||
if sq > 6 { | ||
sq -= 5; | ||
} | ||
|
||
feat += 2 * POWERS[sq]; | ||
|
||
o &= o - 1; | ||
} | ||
|
||
f(feat); | ||
} | ||
} | ||
} | ||
|
||
pub fn get_features(position: &ataxx::Position) -> SparseVector { | ||
let mut feats = SparseVector::with_capacity(36); | ||
|
||
value_feature_map(position, |feat| feats.push(feat)); | ||
|
||
feats | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
pub mod policy; | ||
|
||
mod features; | ||
mod graph; | ||
mod node; | ||
mod params; | ||
mod simulate; | ||
|
||
pub use self::features::*; | ||
pub use self::graph::*; | ||
pub use self::node::*; | ||
pub use self::params::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters