summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibChess
AgeCommit message (Collapse)Author
2023-05-09AK: Add the `Input` word to input-only buffered streamsLucas CHOLLET
This concerns both `BufferedSeekable` and `BufferedFile`.
2023-05-07Chess: Slightly improve error propagation during startupBen Wiederhake
2023-05-07Chess: Avoid IODevice and DeprecatedFileBen Wiederhake
2023-05-05LibChess+Chess: Ensure no pawns have moved when invoking 50 move ruleTim Ledbetter
The 50 and 75 move rules are no longer invoked if a pawn has advanced in the last 50 or 75 moves respectively.
2023-05-03LibChess+ChessEngine: Don't crash on error when reading UCI commandsTim Ledbetter
ChessEngine and the chess GUI will no longer crash on error while reading UCI commands. ChessEngine will print a message to the standard output, while the GUI will ignore unknown commands. Both will print the error to the debug log if the UCI_DEBUG flag is enabled. Trailing and preceding whitespace is now stripped from commands before they are parsed. Commands which are just whitespace no longer produce errors.
2023-05-03LibChess: Add optional ponder move to the BestMove commandTim Ledbetter
The BestMove command can now include an optional ponder token, with the move that the engine would like to ponder on.
2023-05-03LibChess: Flesh out InfoCommand implementationTim Ledbetter
UCI info commands can now be received and parsed. All info types from the UCI specification are supported. The info command is not currently used by our engine or GUI, but the GUI can now receive an info command from a 3rd party engine without complaining.
2023-05-03LibChess: Use the correct command type for InfoCommandTim Ledbetter
2023-04-28LibChess: Add the ucinewgame commandTim Ledbetter
This command is sent from the GUI to tell the engine that the next position will be from a different game.
2023-04-25LibCore: Simplify Core::Notifier by only allowing one event typeAndreas Kling
Not a single client of this API actually used the event mask feature to listen for readability AND writability. Let's simplify the API and have only one hook: on_activation.
2023-04-24LibChess: Remove use of DeprecatedString in Move::from_algebraic()Sam Atkins
2023-04-24LibChess: Return ErrorOr<String> from to-algebraic/fen methodsSam Atkins
Also, avoid creating temporary Strings for numbers, and stop appending empty StringViews.
2023-04-24LibChess: Add and use Square::{file,rank}_char() methodsSam Atkins
This saves us having to build and allocate a String, just to then use one character of it.
2023-04-24LibChess: Make `piece_for_char_promotion()` more generally usefulSam Atkins
- Rename to make it clear it's not just for promotion - Understand 'p' for pawns - Take a char parameter instead of StringView since it's always 1 char
2023-04-24LibChess: Include pawns in FEN outputSam Atkins
Previously, the initial position would look like this: rnbqkbnr//8/8/8/8//RNBQKBNR w KQkq - 0 1 Now, we correctly give pawns the P/p character in FEN output: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 Also, we only ever have 1 or 0 characters for a piece, so let's return `Optional<char>` instead of `StringView` from `char_for_piece()`.
2023-04-24LibChess: Move inputs when creating chess CommandsSam Atkins
2023-04-24LibChess: Convert Commands to use String and propagate errorsSam Atkins
2023-04-24LibChess: Return Commands by pointer from `FooCommand::from_string()`Sam Atkins
This removes this slightly silly pattern: `make<FooCommand>(FooCommand::from_string(s))` Also, let's propagate OOM here, even if nobody reacts to it yet.
2023-04-24LibChess: Fix typo that always created DebugCommands as "on"Sam Atkins
2023-04-20LibChess: Allow UCIEndpoint to handle unexpected disconnectionsTim Ledbetter
2023-04-20LibChess: Add the UCI quit commandTim Ledbetter
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-02-06LibChess: Factorize the returned `StringView` for a drawLucas CHOLLET
2023-02-06Chess+LibChess: Avoid using `DeprecatedString` whenever possibleLucas CHOLLET
2023-01-27AK: Remove StringBuilder::build() in favor of to_deprecated_string()Linus Groh
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-08-22ChessEngine: Use reduced Board objects in MCTSTreeLucas CHOLLET
Monte-Carlo methods are known to intensively create nodes and in our case each leaf of the tree stores a board. However, for this use case, we don't need a full board object that also contains game information. This patch adds a `clone_cleared()` method that return a clone without game information and uses it when constructing the tree. It allows the ChessEngine much more possibility before getting out of memory.
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12LibChess: Add convenience constructor for Chess::Squaresin-ack
It didn't feel right to add sv suffixes to 2-character strings, so I added this convenience constructor.
2022-04-03LibChess: Change UCI::Command::Type to enum classLenny Maiorani
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-26Chess: On pgn import avoid losing piece promotion infoSimon Danner
Fixes #13268
2022-03-10Libraries: Use default constructors/destructors in LibChessLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-02Libraries: Fix visibility of Object-derivative constructorsBen Wiederhake
Derivatives of Core::Object should be constructed through ClassName::construct(), to avoid handling ref-counted objects with refcount zero. Fixing the visibility means that misuses like this are more difficult.
2021-11-02Everywhere: Mark overridden methods 'override'Ben Wiederhake
This is good practice, and fixes some IDE warnings.
2021-07-30LibChess: Fix hashing of the chess boardMartin Blicha
The hash function should take the board by reference, not by value. Also, the fact whether black can castle kingside or not was included twice in the hash, unnecesarily.
2021-07-26LibChess: Early check of legal moveMartin Blicha
One of the conditions for legal move is that the target square is not occupied by a piece of the same color as the moving piece. Instead of checking this for each piece separately at the end, we can check this at the beginning and avoid more expensive checks.
2021-06-22LibChess: Compact the Defenitions of various chess related typesPeter Elliott
before: sizeof(Board)=344, sizeof(Move)=36, sizeof(Piece)=4, sizeof(Square)=8 after: sizeof(Board)=108, sizeof(Move)=9, sizeof(Piece)=1, sizeof(Square)=2
2021-06-22LibChess: Only save hash of board state for repetition checkingPeter Elliott
This more than doubles the number of nodes that MCTS can search for a given time limit, and greatly reduces memory usage.
2021-05-20LibChess: Fixed PGN export bug (#7300)Josh Perry
In cases with ambiguous captures involving pawns (where multiple pieces could have made the capture), we were exporting invalid syntax for the move: `1. e4 e5 2. Bb5 c6 3. Bxc6 ddxc6` Move 3 should be `Bxc6 dxc6`, but we were duplicating the d on the pawn move.
2021-05-17Chess: Fix signed/unsigned issuesJean-Baptiste Boric
Make everything signed so that we don't have to deal with silly casting issues thoughout the Chess code. I am unsure if this affects the chess AI negatively, it seems just as "intelligent" before and after this change :^)
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!