GithubHelp home page GithubHelp logo

adam-kulju / patricia Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 3.0 2.56 MB

Extremely aggressive chess engine, written in C++

License: MIT License

C++ 88.11% C 11.55% Makefile 0.33%
chess-engine cpp aggression chess sacrifices uci

patricia's Introduction

Patricia Chess Engine

License Release Commits

The most aggressive chess engine ever written, Patricia is a killer bunny who will not hesitate to ram as many pieces as possible down your throat.



Aggression

The metric that Patricia's aggression claims are based off of is Stefan Pohl's EAS tool (found here), which is the most well known and well regarded tool for determining the aggressiveness of chess engines. It looks at a combination of factors, such as sacrifice rate, short win rate, and unnecessary draw rate, and outputs a score that captures how "exciting" an engine tends to play.

The average engine's EAS score generally falls between 50,000 and 100,000. The most aggressive top engine is Stockfish, due to its extreme tactical ability; it has an EAS score of 190,000. The most aggressive engine of any notable strength that Stephen Pohl has ever seen is Velvet 4.1.0, which topped out at a remarkable EAS Score of 280,000.

Patricia, with an EAS score of 425,000 in gauntlet testing, is leaps and bounds above any engine that has ever existed in terms of attacking, sacrificing, and playing stylishly.

It's worth noting that Patricia is still well into superhuman territory, with an estimated CCRL elo of 3100-3150; she'll lose badly to top engines, but will still crush any human.



What Patricia currently does to increase aggressiveness

  • Default contempt of 80 centipawns for draws deemed avoidable
  • Neural network retrained on "aggressive" positions filtered by a variety of criteria
  • Asymmetrical evaluation; Patricia doesn't care if she gets sacrificed against, so all sacrifice bonuses apply to the original side to move only.
  • Bonuses for going down in material compared to original position being searched
  • Bonuses for being better off than what material would suggest
  • Bonuses for sacrifices at root
  • Bonuses for attacking the enemy king
  • Bonus for opposite side castling
  • If the above applies, bonus for open files towards enemy king
  • Material scaling
  • Game length evaluation scaling
  • Lack of search techniques that aggressively prune moves that lose material. Patricia has no SEE pruning, and she orders bad captures right behind good captures instead of right at the end.



Search Features

Patricia has a somewhat simple feature set of search features as of now. This is partly due to the aforementioned reason of not wanting to prune too many sacrifices away, and partly due to focusing more on increasing aggressiveness than strength.

  • Alpha-Beta search with Quiescence Search and Transposition Tables
  • Aspiration Windows
  • Reverse Futility Pruning and Futility Pruning
  • Null Move Pruning
  • Late Move Reductions
  • Late Move Pruning
  • History Heuristic and Killer Move Heuristic
  • Singular Extensions



Evaluation and Filtering

Patricia's evaluation is a neural network with a 768x2->768->1 perspective arch, trained on 2.4 billion positions of my other engine Willow's data. It has been additionally retrained on a filtered dataset of 10 million positions specially selected for being "aggressive positions", in order to increase Patricia's understanding of them and to make her more likely to play into similar positions.

Code for filtering programs are found in the utils/ directory, and are indentified as follows:

  • position_filter_1: Saves positions with general compensation - i.e. being down significantly in material yet still having at least a playable position. (Note: I currently do not recommend using this one.)
  • position_filter_2: Saves positions where one side's king is exposed and under attack by enemy pieces.
  • position_filter_3: Saves positions where one side has a major space advantage.
  • position_filter_4: Saves opposite side castling positions with lots of material on the board and one side attempting a pawn storm.
  • position_filter_5: Saves positions where one side is significantly behind in development.
  • position_filter_6: Saves positions where one side can't castle and has an open king. This is somewhat similar to 2 but doesn't take into account attackers and uses a different method for calculating defensive strength.
  • position_filter_7: Saves positions where many pieces are able to move near, are near, or are pointing at the enemy king. This uses a simple but effective ray calculator instead of a full mobility calculation.
  • position_filter_8: Saves positions where one side has an extremely powerful minor piece that can't be traded off easily. Many such positions result from exchange sacrifices and even if they don't the dominant piece is a long term advantage that often leads to dynamics down the line.

Patricia currently uses positions that were filtered out by scripts 2, 6, and 8, with duplicates removed.

Additionally, the converter.cpp file allows you to transform bullet-format data into text data, so that you can then use the filtering scripts on the resulting file.

All filtering programs are run with the command ./[exe] [input.txt] [output.txt]. You'll have to compile the particular program that you want to run yourself, or you can ask me for a binary for a specific filtering method.



Acknowledgements

  • A huge shoutout to Stefan Pohl. His EAS Tool works wonderfully, makes properly and objectively testing for increase aggression possible, and is the measure by which Patricia development progressed. He was also very invested in Patricia's development and explained many features of the EAS tool to me so that I had a better understanding of what was a sacrifice and what wasn't. He has put a lot of time into quantifying style, and I am happy to have Patricia be a proof-of-concept and culmination of his ideas.

  • Thanks to my friends at SweHosting as usual, for being supportive, for suggesting ideas, and for spreading Patricia propaganda in the Stockfish Discord server :crabgrab:

  • Thanks to all the people interested in an aggressive chess engine. The support I got in my developer log on Talkchess is really nice to see. I'm glad people care about style in chess too, rather than just ELO!



Other

Instructions for downloading/building Patricia can be found in the Releases section. If you know UCI protocol, you can run Patricia directly, otherwise she will work with any major GUI (Arena, BanksiaGUI, etc.)

If you think Patricia is a cool project, please spread the word of it! There are lots of people interested in an aggressive engine, whether it be for sparring or for other purposes, and greater awareness of what should be the undisputed queen of style would make their wish come true.

patricia's People

Contributors

adam-kulju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

patricia's Issues

Segmentation fault when using "go"

Screenshot 2024-04-20 at 14 12 30 Hello, i was trying to use your chess engine to have some inspiration for mine, when i have encounter that error. I am not able to run it, since it just segfaults, i don't know much, so maybe i'm just doing something dump, but for know i'm just not able to run it due to that error. For my little knowledge i think it is failing on the reset_nnue function inside the iterative_deepening. It only works when i'm in debug mode as you can see.

v2.0.1 crash

i just discovered your engine v2.0.1 and was able to compile it on Linux (Xubuntu 22.04) .. but it crashes in CuteChess GUI ("disconnects") .. here are 3 games :

[Event "?"]
[Site "?"]
[Date "2024.04.16"]
[Round "?"]
[White "Nakshatra"]
[Black "Patricia v2.0.1 NN"]
[Result "0-1"]
[FEN "rnbqkb1r/ppp2ppp/5n2/3pp3/8/3PP3/PPPNNPPP/R1BQKB1R b KQkq - 3 4"]
[PlyCount "0"]
[SetUp "1"]
[Termination "abandoned"]
[TimeControl "900+3"]

{White disconnects} 0-1
[Event "?"]
[Site "?"]
[Date "2024.04.16"]
[Round "?"]
[White "Patricia v2.0.1 NN"]
[Black "4ku v4.0"]
[Result "0-1"]
[ECO "C21"]
[Opening "Centre game"]
[PlyCount "26"]
[Termination "abandoned"]
[TimeControl "300+3"]

1. e4 {+0.96/17 26s} e5 {-0.33/24 11s} 2. d4 {+1.08/16 18s} exd4 {0.00/25 13s}
3. Nf3 {+0.21/16 17s} Bc5 {-0.02/26 12s} 4. Bg5 {+0.51/15 9.4s}
f6 {-0.01/26 12s} 5. b4 {+0.67/15 19s} Bxb4+ {+0.57/25 32s}
6. Bd2 {-1.14/17 11s} Bc5 {+0.49/26 9.6s} 7. Bc4 {-1.09/15 10s}
Nc6 {+0.60/25 11s} 8. c3 {-1.20/15 8.6s} d3 {+0.63/25 11s} 9. Nd4 {-0.09/15 26s}
Ne5 {+0.93/25 8.1s} 10. Bxg8 {-0.57/17 13s} Rxg8 {+1.11/27 7.8s}
11. Qh5+ {-0.70/17 7.5s} Ke7 {+0.94/27 20s} 12. Qxe5+ {-0.91/15 10s}
fxe5 {+3.38/27 6.7s} 13. Bg5+ {-4.98/18 7.5s}
Kd6 {+3.38/27 12s, White disconnects} 0-1
[Event "?"]
[Site "?"]
[Date "2024.04.16"]
[Round "?"]
[White "Patricia v2.0.1 NN"]
[Black "4ku v4.0"]
[Result "0-1"]
[FEN "rnbqkb1r/ppp2ppp/5n2/3pp3/8/3PP3/PPPNNPPP/R1BQKB1R b KQkq - 3 4"]
[PlyCount "45"]
[SetUp "1"]
[Termination "abandoned"]
[TimeControl "900+3"]

1... Be7 {+0.58/24 37s} 2. b4 {-0.57/17 32s} Bxb4 {+1.12/27 32s}
3. g3 {-2.61/16 31s} O-O {+1.25/27 48s} 4. Bg2 {-2.85/16 38s} c6 {+1.18/27 60s}
5. a3 {-2.86/16 90s} Bd6 {+1.25/26 68s} 6. O-O {-3.04/15 31s} b5 {+1.24/25 31s}
7. e4 {-2.62/16 23s} Bg4 {+1.23/26 28s} 8. h3 {-1.44/16 26s} Be6 {+1.25/24 21s}
9. f4 {-1.08/17 29s} dxe4 {+1.32/26 92s} 10. f5 {-1.50/18 33s}
exd3 {+1.24/28 17s} 11. fxe6 {-1.08/20 34s} dxe2 {+1.28/28 17s}
12. exf7+ {-1.18/18 27s} Rxf7 {+1.17/27 18s} 13. Qxe2 {-1.26/17 21s}
Nbd7 {+1.25/27 25s} 14. a4 {-1.24/15 36s} bxa4 {+1.40/26 21s}
15. Rxa4 {-1.06/15 31s} Qe7 {+1.29/27 20s} 16. Rc4 {-1.29/15 19s}
Nc5 {+1.21/25 34s} 17. Ba3 {-1.23/15 17s} Rd8 {+0.93/24 13s}
18. Bxc5 {-1.31/18 22s} Bxc5+ {+0.95/27 13s} 19. Kh2 {-1.51/16 17s}
Rff8 {+1.29/26 13s} 20. Rf3 {-1.22/17 24s} Rd6 {+1.44/28 13s}
21. Rf5 {-0.81/18 24s} Qd7 {+1.76/32 14s} 22. Rxf6 {-0.38/20 16s}
Rxd2 {+1.71/33 12s} 23. Rxf8+ {-1.23/22 16s}
Bxf8 {+1.75/31 12s, White disconnects} 0-1

Other Most Aggressive Engine.

I think from testing, though I haven't tested with yours, Little Goliath NN 3.15-3.17 is the most aggressive engine by far ( and has an aggressive boosting option that drops about 4-500 elo) but it's around 3300 and is crazy sacrificial

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.