Skip to content

Commit

Permalink
chore: Store progress, fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillbobyrev committed May 16, 2024
1 parent 5a3e09c commit 61067f7
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 16 deletions.
12 changes: 0 additions & 12 deletions .editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Stockfish",
"sysinfo",
"TCEC",
"Valgrind",
"xrays",
"Zobrist"
]
Expand Down
4 changes: 1 addition & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ it is not hard to learn and can be an easy way to debug some parts of the engine
manually, so it is also extended with several useful commands (for example, `go
perft`).

### [`training/`](/training/)

### [`tests/`](/tests/)

Tests the engine through public interfaces. Most tests should go here, unit
Expand Down Expand Up @@ -82,7 +80,7 @@ arrays. These constants shouldn't change over time.
[Bitboard]: https://www.chessprogramming.org/Bitboards
[Monte-Carlo Tree Search]: https://www.chessprogramming.org/Monte-Carlo_Tree_Search
[search]: https://www.chessprogramming.org/Search
[evaluation]: https://www.chessprogramming.org/Evaluation
[position evaluation]: https://www.chessprogramming.org/Evaluation
[Fuzzers]: https://en.wikipedia.org/wiki/Fuzzing
[communicate with a front-end]: https://www.chessprogramming.org/User_Interface
[Universal Chess Interface]: http://wbec-ridderkerk.nl/html/UCIProtocol.html
Expand Down
Empty file removed src/evaluation/.gitkeep
Empty file.
29 changes: 29 additions & 0 deletions src/evaluation/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::chess::Position;


fn evaluate(position: &Position) -> i32 {
let mut score = 0;

// Piece values
let pawn_value = 1;
let knight_value = 3;
let bishop_value = 3;
let rook_value = 5;
let queen_value = 9;

// Count the number of each piece type
let num_pawns = position.count_pawns();
let num_knights = position.count_knights();
let num_bishops = position.count_bishops();
let num_rooks = position.count_rooks();
let num_queens = position.count_queens();

// Calculate the score based on the number of each piece type
score += pawn_value * num_pawns;
score += knight_value * num_knights;
score += bishop_value * num_bishops;
score += rook_value * num_rooks;
score += queen_value * num_queens;

score
}
57 changes: 56 additions & 1 deletion src/interface/uci.rs
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
fn run() {}
use std::io::{self, BufRead};

fn run() {

Check warning on line 3 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable, false)

function `run` is never used

Check warning on line 3 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable, false)

function `run` is never used

Check warning on line 3 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, nightly, true)

function `run` is never used

Check warning on line 3 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, nightly, true)

function `run` is never used
let stdin = io::stdin();
let mut lines = stdin.lock().lines().map(|line| line.unwrap());

loop {
let input = lines.next().unwrap();
let tokens: Vec<&str> = input.split_whitespace().collect();

match tokens[0] {
"uci" => {
// Handle UCI initialization
println!("id name MyChessEngine");
println!("id author YourName");
println!("uciok");
},
"isready" => {
// Handle engine initialization
println!("readyok");
},
"ucinewgame" => {
// Handle new game setup
},
"position" => {
// Handle position setup
if tokens[1] == "startpos" {
// Handle starting position
} else {
// Handle FEN position
}
if tokens.len() > 2 && tokens[2] == "moves" {
// Handle moves
for i in 3..tokens.len() {
let move_str = tokens[i];

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (macos-latest, stable, true)

unused variable: `move_str`

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (macos-latest, nightly, true)

unused variable: `move_str`

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable, false)

unused variable: `move_str`

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable, false)

unused variable: `move_str`

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, nightly, true)

unused variable: `move_str`

Check warning on line 35 in src/interface/uci.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, nightly, true)

unused variable: `move_str`
// Process the move
}
}
},
"go" => {
// Handle search and move generation
// Implement your chess engine logic here
// Generate and output the best move
println!("bestmove e2e4");
},
"quit" => {
// Handle quitting the engine
break;
},
_ => {
// Handle unknown command
println!("Unknown command: {}", input);
},
}
}
}

0 comments on commit 61067f7

Please sign in to comment.