add board weights

This commit is contained in:
Simon Gardling 2025-02-22 20:55:17 -05:00
parent 60aaa883c1
commit ed101f8968
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 25 additions and 9 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Othello bot
## Papers:
- [An Evolutionary Learning Approach to Play
Othello Using XCS](https://www.researchgate.net/profile/Swaraj-Kumar/publication/328458543_An_Evolutionary_Learning_Approach_to_Play_Othello_Using_XCS/links/60fbe0450c2bfa282af91ed1/An-Evolutionary-Learning-Approach-to-Play-Othello-Using-XCS.pdf?origin=publication_detail)
- [Reinforcement Learning and its Application to Othello](https://repub.eur.nl/pub/7142/ei2005-47.pdf) - Board weights used

View File

@ -18,19 +18,28 @@ impl BoardValueMap {
.sum()
}
/// Weights from: https://repub.eur.nl/pub/7142/ei2005-47.pdf
pub fn new() -> Self {
let mut map = PosMap::new();
assert_eq!(
Board::BOARD_SIZE,
8,
"BVM only supports Board::BOARD_SIZE of 8"
);
const POSITION_VALUES: [[i64; 8]; 8] = [
[100, -20, 10, 5, 5, 10, -20, 100],
[-20, -50, -2, -2, -2, -2, -50, -20],
[10, -2, -1, -1, -1, -1, -2, 10],
[5, -2, -1, -1, -1, -1, -2, 5],
[5, -2, -1, -1, -1, -1, -2, 5],
[10, -2, -1, -1, -1, -1, -2, 10],
[-20, -50, -2, -2, -2, -2, -50, -20],
[100, -20, 10, 5, 5, 10, -20, 100],
];
for (i, j) in Board::all_positions() {
map.set(i, j, 1);
}
for (i, j) in Board::sides() {
map.set(i, j, 100);
}
for (i, j) in Board::corners() {
map.set(i, j, 1000);
map.set(i, j, POSITION_VALUES[i][j])
}
Self(map)