remove QueueAgent
This commit is contained in:
parent
78ce4d4973
commit
652ea97f83
29
src/agent.rs
29
src/agent.rs
@ -1,5 +1,4 @@
|
|||||||
use crate::{board::Board, piece::Piece};
|
use crate::{board::Board, piece::Piece};
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
pub trait Agent {
|
pub trait Agent {
|
||||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)>;
|
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)>;
|
||||||
@ -24,31 +23,3 @@ impl Agent for ManualAgent {
|
|||||||
self.color
|
self.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct QueueAgent {
|
|
||||||
moves: VecDeque<(usize, usize)>,
|
|
||||||
color: Piece,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QueueAgent {
|
|
||||||
pub fn new(moves: impl IntoIterator<Item = (usize, usize)>, color: Piece) -> Self {
|
|
||||||
Self {
|
|
||||||
moves: moves.into_iter().collect(),
|
|
||||||
color,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Agent for QueueAgent {
|
|
||||||
fn next_move(&mut self, _: &Board) -> Option<(usize, usize)> {
|
|
||||||
self.moves.pop_front()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> &'static str {
|
|
||||||
"Queue Agent"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn color(&self) -> Piece {
|
|
||||||
self.color
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -10,15 +10,6 @@ mod misc;
|
|||||||
mod piece;
|
mod piece;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// let player1 = QueueAgent::new(
|
|
||||||
// [(0, 0), (1, 0), (1, 2), (3, 2), (3, 0), (3, 4), (0, 1)],
|
|
||||||
// Piece::Black,
|
|
||||||
// );
|
|
||||||
// let player2 = QueueAgent::new(
|
|
||||||
// [(1, 1), (2, 2), (3, 3), (3, 1), (0, 2), (4, 2), (3, 5)],
|
|
||||||
// Piece::White,
|
|
||||||
// );
|
|
||||||
|
|
||||||
let player1 = ComplexAgent::new(Piece::Black);
|
let player1 = ComplexAgent::new(Piece::Black);
|
||||||
let player2 = ComplexAgent::new(Piece::White);
|
let player2 = ComplexAgent::new(Piece::White);
|
||||||
let mut game = Game::new(Box::new(player1), Box::new(player2));
|
let mut game = Game::new(Box::new(player1), Box::new(player2));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user