switch coordinates to global 'Coord' type
This commit is contained in:
@@ -39,7 +39,7 @@ impl BoardValueMap {
|
||||
];
|
||||
|
||||
for (i, j) in Board::all_positions() {
|
||||
map.set(i, j, POSITION_VALUES[i][j])
|
||||
map.set(i, j, POSITION_VALUES[i as usize][j as usize])
|
||||
}
|
||||
|
||||
Self(map)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
logic::r#move::Move,
|
||||
repr::{Board, Piece, Winner},
|
||||
repr::{Board, Coord, Piece, Winner},
|
||||
};
|
||||
use indicatif::{ProgressIterator, ProgressStyle};
|
||||
use std::{collections::HashMap, hash::BuildHasherDefault};
|
||||
@@ -216,7 +216,7 @@ impl FutureMoves {
|
||||
}
|
||||
|
||||
/// Return the best move which is a child of `self.current_root`
|
||||
pub fn best_move(&self) -> Option<(usize, usize)> {
|
||||
pub fn best_move(&self) -> Option<(Coord, Coord)> {
|
||||
self.current_root
|
||||
.and_then(|x| {
|
||||
self.arena[x]
|
||||
@@ -267,7 +267,7 @@ impl FutureMoves {
|
||||
/// Update the root based on the coordinate of the move
|
||||
/// Returns a boolean, `true` if the operation was successful, false if not
|
||||
#[must_use = "You must check if the root was properly set"]
|
||||
pub fn update_root_coord(&mut self, i: usize, j: usize) -> bool {
|
||||
pub fn update_root_coord(&mut self, i: Coord, j: Coord) -> bool {
|
||||
// check to make sure current_root is some so we dont
|
||||
// have to do that in the iterator
|
||||
if self.current_root.is_none() {
|
||||
@@ -493,7 +493,7 @@ mod tests {
|
||||
|
||||
// dummy (2)
|
||||
futm.arena.push(Move::new(
|
||||
Some((1234, 1234)),
|
||||
Some((123, 123)),
|
||||
Board::new(),
|
||||
Piece::White,
|
||||
Piece::Black,
|
||||
@@ -517,7 +517,7 @@ mod tests {
|
||||
|
||||
assert_ne!(
|
||||
futm.arena[2].coord,
|
||||
Some((1234, 1234)),
|
||||
Some((123, 123)),
|
||||
"dummy value still exists"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use super::board_value::BoardValueMap;
|
||||
use crate::repr::{Board, Piece, Winner};
|
||||
use crate::repr::{Board, Coord, Piece, Winner};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Move {
|
||||
/// Coordinates (i, j) of the move (if it exists)
|
||||
pub coord: Option<(usize, usize)>,
|
||||
pub coord: Option<(Coord, Coord)>,
|
||||
|
||||
/// [`Board`] state after move is made
|
||||
pub board: Board,
|
||||
@@ -41,7 +41,7 @@ lazy_static! {
|
||||
|
||||
impl Move {
|
||||
pub fn new(
|
||||
coord: Option<(usize, usize)>,
|
||||
coord: Option<(Coord, Coord)>,
|
||||
board: Board,
|
||||
color: Piece,
|
||||
agent_color: Piece,
|
||||
|
||||
Reference in New Issue
Block a user