-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Saphereye/dev/algo-refactor
dev/algo refactor
- Loading branch information
Showing
7 changed files
with
854 additions
and
920 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
[package] | ||
name = "shard" | ||
version = "1.0.0" | ||
version = "2.0.0" | ||
edition = "2021" | ||
authors = ["Saphereye <[email protected]>"] | ||
|
||
[dependencies] | ||
chess = "3.2.0" | ||
clap = { version = "4.5.18", features = ["derive"] } | ||
nom = "7.1.3" | ||
rand = "0.8.5" | ||
rayon = "1.10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
# Shard Chess Engine | ||
![](https://github.com/Saphereye/shard/blob/main/assets/demo.png) | ||
*Shard Vs Shard (Shard Wins)* | ||
|
||
# Roadmap | ||
### Improve Evaluation Function | ||
Enhance the evaluation function to consider more factors: | ||
- [ ] King safety | ||
- [ ] Pawn structure (isolated, doubled, passed pawns) | ||
- [ ] Piece mobility | ||
- [ ] Control of key squares (e.g., center control) | ||
- [ ] Rook on open files | ||
- [ ] Bishop pair advantage | ||
## Introduction | ||
Shard is a chess engine written in Rust. It is supports most UCI commands. | ||
The engine utilizes the Monte Carlo Tree Search algorithm. | ||
|
||
### Enhance Move Ordering | ||
Implement more advanced move ordering techniques: | ||
- [ ] History heuristic: Track the success of moves in the search tree and prioritize moves that have historically caused beta cutoffs. | ||
- [X] Killer move heuristic: Track moves that cause beta cutoffs at the same depth and prioritize them. | ||
- [X] Principal variation search: Use the best move from the previous iteration as the first move in the current iteration. | ||
|
||
### Improve Quiescence Search | ||
Extend the quiescence search to include more types of moves, such as: | ||
- [X] Checks | ||
- [ ] Threats (moves that create immediate threats) | ||
|
||
### Optimize Transposition Table | ||
- [ ] Use Zobrist hashing to efficiently hash board positions and implement a more sophisticated replacement scheme (e.g., always replace, depth- [ based replacement). | ||
|
||
### Implement Advanced Search Techniques | ||
- [X] **Iterative Deepening**: Perform a series of depth- [ limited searches, increasing the depth with each iteration. This helps with move ordering and time management. | ||
- [ ] **Null Move Pruning**: Assume the opponent will pass their turn and see if the current player can still achieve a good position. If so, prune the branch. | ||
- [ ] **Late Move Reductions**: Reduce the search depth for moves that are considered less likely to be good (e.g., moves that are not captures or checks). | ||
- [ ] **Aspiration Windows**: Use a narrow window around the expected score to speed up alpha- [ beta search. If the score falls outside the window, re- [ search with a wider window. | ||
The tree looks like this: | ||
``` | ||
Node t:16396, n:36 (rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1) (None) | ||
Node t:11048, n:8 (rnbqkbnr/pppppppp/8/8/6P1/8/PPPPPP1P/RNBQKBNR b KQkq - 0 1) (g2g4) | ||
Node t:538, n:1 (rnbqkbnr/1ppppppp/8/p7/6P1/8/PPPPPP1P/RNBQKBNR w KQkq - 0 1) (a7a5) | ||
Node t:-477, n:1 (rnbqkbnr/1ppppppp/p7/8/6P1/8/PPPPPP1P/RNBQKBNR w KQkq - 0 1) (a7a6) | ||
Node t:-553, n:1 (rnbqkbnr/p1pppppp/8/1p6/6P1/8/PPPPPP1P/RNBQKBNR w KQkq - 0 1) (b7b5) | ||
... | ||
Node t:7211, n:6 (rnbqkbnr/pppppppp/8/8/8/7P/PPPPPPP1/RNBQKBNR b KQkq - 0 1) (h2h3) | ||
Node t:-137, n:1 (rnbqkbnr/1ppppppp/8/p7/8/7P/PPPPPPP1/RNBQKBNR w KQkq - 0 1) (a7a5) | ||
Node t:-1526, n:1 (rnbqkbnr/1ppppppp/p7/8/8/7P/PPPPPPP1/RNBQKBNR w KQkq - 0 1) (a7a6) | ||
... | ||
... | ||
``` | ||
Each 'Node' represents a position in the game. The 't' value is the total score of the position, and the 'n' value is the number of times the position has been visited. | ||
When a move is made, the engine will set the current position to the position of the move, and the tree will be updated accordingly from there. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.