Skip to content

Commit

Permalink
add outdated message
Browse files Browse the repository at this point in the history
  • Loading branch information
fabolous005 committed Apr 16, 2024
1 parent 3b199f6 commit 25a6a90
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# chesster

a simple and blazingly fast chess engine

programm switched to [Saltfish](https://github.com/fabolous005/saltfish)
16 changes: 15 additions & 1 deletion src/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::position::{Position};
pub struct Line {
move_: Move,
value: i32,
abondened: bool,
line: Option<Box<Vec<Line>>>
}

Expand All @@ -21,6 +22,7 @@ impl Line {
Line {
move_,
value: 0,
abondened: false,
line: None
}
]
Expand All @@ -43,10 +45,22 @@ impl Line {
for move_ in moves {
let new_position: &mut Position = &mut position.clone();
new_position.make_move(&move_);
lines.push(Line { move_, value: 0, line: None })
lines.push(Line { move_, value: 0, abondened: false, line: None })
}
lines
}

pub fn get_line(position: &Position) -> Vec<Line> {
let mut lines = Vec::new();
let moves = position.get_moves();
for move_ in moves {
let new_position: &mut Position = &mut position.clone();
new_position.make_move(&move_);
lines.push(Line { move_, value: 0, abondened: false, line: None })
}
lines
}

}


15 changes: 12 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ fn main() {
println!("{:#?}", best_move);

let result = thread::spawn(move || {
let mut position_before = None;
let mut new_position: Position;
let mut lines;
loop{
let position: Position = receiver_sub.recv().unwrap();
let result: Vec<Line> = Line::get_lines(&position, 0);
sender_main.send(result).unwrap();
new_position = receiver_sub.recv().unwrap();
if position_before.is_some() && position_before != Some(new_position) {
new_position = position_before.unwrap();
}

// TODO: get latest unsolved position
lines = Line::get_line(&new_position);
sender_main.send(lines).unwrap();
position_before = Some(position);
}
});

Expand Down
4 changes: 3 additions & 1 deletion src/pieces/pawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl PawnMoveOptionsBlack {
moves.push(PawnMoveOptionsBlack::CaptureR(Change { x: 1, y: 1 }));
moves.push(PawnMoveOptionsBlack::CaptureL(Change { x: -1, y: 1 }));
moves.push(PawnMoveOptionsBlack::EnPassant(Change { x: 1, y: 1 }));
moves.push(PawnMoveOptionsBlack::EnPassant(Change { x: -1, y: 1 }));
moves
}
}
Expand All @@ -39,7 +40,8 @@ impl PawnMoveOptionsWhite {
moves.push(PawnMoveOptionsWhite::CaptureR(Change { x: 1, y: -1 }));
moves.push(PawnMoveOptionsWhite::CaptureL(Change { x: -1, y: -1 }));
moves.push(PawnMoveOptionsWhite::EnPassant(Change { x: 1, y: -1 }));
moves.push(PawnMoveOptionsWhite::EnPassant(Change { x: -1, y: -1 }));
moves
}

}
}
6 changes: 3 additions & 3 deletions src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ use crate::moves::get_moves_black;



#[derive(Debug, PartialEq, Copy, Clone)]
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum Color {
White,
Black,
}

#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Castling {
king_side: bool,
queen_side: bool
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Position {
pub rows: [[char; 8]; 8],
pub to_move: Color,
Expand Down

0 comments on commit 25a6a90

Please sign in to comment.