allow dead code
This commit is contained in:
17
src/agent.rs
17
src/agent.rs
@@ -3,6 +3,7 @@ use rand::prelude::*;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub trait Agent {
|
pub trait Agent {
|
||||||
/// Returns the move of an [`Agent`]
|
/// Returns the move of an [`Agent`]
|
||||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)>;
|
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)>;
|
||||||
@@ -17,6 +18,14 @@ pub struct ManualAgent {
|
|||||||
color: Piece,
|
color: Piece,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ManualAgent {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub const fn new(color: Piece) -> Self {
|
||||||
|
Self { color }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl Agent for ManualAgent {
|
impl Agent for ManualAgent {
|
||||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
@@ -57,18 +66,12 @@ impl Agent for ManualAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ManualAgent {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const fn new(color: Piece) -> Self {
|
|
||||||
Self { color }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An [`Agent`] that just makes a random move that is legal
|
/// An [`Agent`] that just makes a random move that is legal
|
||||||
pub struct RandomAgent {
|
pub struct RandomAgent {
|
||||||
color: Piece,
|
color: Piece,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl Agent for RandomAgent {
|
impl Agent for RandomAgent {
|
||||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
||||||
board.possible_moves(self.color).choose(&mut rand::rng())
|
board.possible_moves(self.color).choose(&mut rand::rng())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ pub struct ComplexAgent {
|
|||||||
future_moves: FutureMoves,
|
future_moves: FutureMoves,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl ComplexAgent {
|
impl ComplexAgent {
|
||||||
pub const fn new(color: Piece) -> Self {
|
pub const fn new(color: Piece) -> Self {
|
||||||
const MAX_DEPTH: usize = 15;
|
const MAX_DEPTH: usize = 15;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ impl std::fmt::Display for Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl Game {
|
impl Game {
|
||||||
pub fn new(player1: Box<dyn Agent>, player2: Box<dyn Agent>) -> Self {
|
pub fn new(player1: Box<dyn Agent>, player2: Box<dyn Agent>) -> Self {
|
||||||
let player1_color = player1.color();
|
let player1_color = player1.color();
|
||||||
|
|||||||
Reference in New Issue
Block a user