wip
This commit is contained in:
parent
3280e2a6d7
commit
afbc5d3c13
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{BotStrategy, CheckerMove, Color, GameState, PlayerId, PointsRules};
|
use crate::{BotStrategy, CheckerMove, Color, GameState, PlayerId, PointsRules};
|
||||||
|
use store::MoveRules;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DefaultStrategy {
|
pub struct DefaultStrategy {
|
||||||
|
|
@ -50,19 +51,27 @@ impl BotStrategy for DefaultStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn choose_move(&self) -> (CheckerMove, CheckerMove) {
|
fn choose_move(&self) -> (CheckerMove, CheckerMove) {
|
||||||
let (dice1, dice2) = match self.color {
|
let rules = MoveRules::new(&self.color, &self.game.board, self.game.dice);
|
||||||
Color::White => (self.game.dice.values.0 as i8, self.game.dice.values.1 as i8),
|
let possible_moves = rules.get_possible_moves_sequences(true);
|
||||||
Color::Black => (
|
let choosen_move = *possible_moves
|
||||||
0 - self.game.dice.values.0 as i8,
|
.first()
|
||||||
0 - self.game.dice.values.1 as i8,
|
.unwrap_or(&(CheckerMove::default(), CheckerMove::default()));
|
||||||
),
|
println!("default strategy move : {:?}", choosen_move);
|
||||||
};
|
choosen_move
|
||||||
|
|
||||||
let fields = self.game.board.get_color_fields(self.color);
|
// let (dice1, dice2) = match self.color {
|
||||||
let first_field = fields.first().unwrap();
|
// Color::White => (self.game.dice.values.0 as i8, self.game.dice.values.1 as i8),
|
||||||
(
|
// Color::Black => (
|
||||||
CheckerMove::new(first_field.0, (first_field.0 as i8 + dice1) as usize).unwrap(),
|
// 0 - self.game.dice.values.0 as i8,
|
||||||
CheckerMove::new(first_field.0, (first_field.0 as i8 + dice2) as usize).unwrap(),
|
// 0 - self.game.dice.values.1 as i8,
|
||||||
)
|
// ),
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// let fields = self.game.board.get_color_fields(self.color);
|
||||||
|
// let first_field = fields.first().unwrap();
|
||||||
|
// (
|
||||||
|
// CheckerMove::new(first_field.0, (first_field.0 as i8 + dice1) as usize).unwrap(),
|
||||||
|
// CheckerMove::new(first_field.0, (first_field.0 as i8 + dice2) as usize).unwrap(),
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
mod game;
|
mod game;
|
||||||
mod game_rules_moves;
|
mod game_rules_moves;
|
||||||
|
pub use game_rules_moves::MoveRules;
|
||||||
mod game_rules_points;
|
mod game_rules_points;
|
||||||
pub use game::{EndGameReason, GameEvent, GameState, Stage, TurnStage};
|
pub use game::{EndGameReason, GameEvent, GameState, Stage, TurnStage};
|
||||||
pub use game_rules_points::PointsRules;
|
pub use game_rules_points::PointsRules;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue