Skip to content

Commit

Permalink
r/b underpromotions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciekce committed Mar 24, 2023
1 parent 49ed37c commit 91567e8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ heavily WIP and currently pretty basic
- [Chess960](https://en.wikipedia.org/wiki/Fischer_random_chess) support

## UCI options
| Name | Type | Default value | Valid values | Description |
|:--------------|:-------:|:-------------:|:------------:|:----------------------------------------------------------------------------------------------------------------|
| Hash | integer | 64 | [1, 131072] | Memory allocated to the transposition table (in MB). Rounded down internally to the next-lowest power of 2. |
| Clear Hash | button | N/A | N/A | Clears the transposition table. |
| Move Overhead | integer | 100 | [30, 50000] | Amount of time Polaris assumes to be lost to overhead when making a move (in ms). |
| Searcher | string | AspPVS | AspPVS | Searcher used internally. Only AspPVS (principal variation search with aspiration windows) currently supported. |
| Name | Type | Default value | Valid values | Description |
|:----------------|:-------:|:-------------:|:---------------:|:----------------------------------------------------------------------------------------------------------------|
| Hash | integer | 64 | [1, 131072] | Memory allocated to the transposition table (in MB). Rounded down internally to the next-lowest power of 2. |
| Clear Hash | button | N/A | N/A | Clears the transposition table. |
| Underpromotions | check | `false` | `false`, `true` | Whether underpromotions to rooks and bishops are generated. |
| Move Overhead | integer | 100 | [30, 50000] | Amount of time Polaris assumes to be lost to overhead when making a move (in ms). |
| Searcher | string | AspPVS | AspPVS | Searcher used internally. Only AspPVS (principal variation search with aspiration windows) currently supported. |

## Builds
`bmi2`: requires BMI2 and assumes fast `pext` and `pdep` (i.e. no Zen 1 and 2)
Expand Down
13 changes: 6 additions & 7 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
#include "rays.h"
#include "eval/material.h"
#include "util/bitfield.h"

#include <iostream>
#include <sstream>
#include <iomanip>
#include "uci.h"
#include "pretty.h"

namespace polaris
{
Expand Down Expand Up @@ -75,8 +70,12 @@ namespace polaris
const auto srcSquare = static_cast<Square>(static_cast<i32>(dstSquare) - offset);

quiet.push({Move::promotion(srcSquare, dstSquare, BasePiece::Knight), 0});
// quiet.push({Move::promotion(srcSquare, dstSquare, BasePiece::Rook), 0});
// quiet.push({Move::promotion(srcSquare, dstSquare, BasePiece::Bishop), 0});

if (uci::g_uciOpts.underpromotions)
{
quiet.push({Move::promotion(srcSquare, dstSquare, BasePiece::Rook), 0});
quiet.push({Move::promotion(srcSquare, dstSquare, BasePiece::Bishop), 0});
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ namespace polaris::uci
constexpr auto Version = PS_STRINGIFY(PS_VERSION);
constexpr auto Author = "Ciekce";

GlobalOptions s_uciOpts{};

class UciHandler
{
public:
Expand Down Expand Up @@ -139,6 +141,8 @@ namespace polaris::uci

void UciHandler::handleUci()
{
static const GlobalOptions defaultOps{};

std::cout << "id name " << Name << ' ' << Version << '\n';
std::cout << "id author " << Author << '\n';

Expand All @@ -147,7 +151,8 @@ namespace polaris::uci
std::cout << "option name Clear Hash type button\n";
//TODO
// std::cout << "option name Contempt type spin default 0 min -10000 max 10000\n";
// std::cout << "option name Underpromotions type check default false\n";
std::cout << "option name Underpromotions type check default "
<< (defaultOps.underpromotions ? "true" : "false") << '\n';
std::cout << "option name Move Overhead type spin default " << limit::DefaultMoveOverhead
<< " min " << limit::MoveOverheadRange.min() << " max " << limit::MoveOverheadRange.max() << '\n';

Expand Down Expand Up @@ -460,7 +465,15 @@ namespace polaris::uci
else std::cerr << "unknown searcher " << valueStr << std::endl;
}
}
if (nameStr == "move overhead")
else if (nameStr == "underpromotions")
{
if (!valueEmpty)
{
if (const auto newUnderpromotions = util::tryParseBool(valueStr))
s_uciOpts.underpromotions = *newUnderpromotions;
}
}
else if (nameStr == "move overhead")
{
if (!valueEmpty)
{
Expand Down Expand Up @@ -614,6 +627,8 @@ namespace polaris::uci
#endif
}

const GlobalOptions &g_uciOpts = s_uciOpts;

i32 run()
{
UciHandler handler{};
Expand Down
7 changes: 7 additions & 0 deletions src/uci.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

namespace polaris::uci
{
struct GlobalOptions
{
bool underpromotions{false};
};

extern const GlobalOptions &g_uciOpts;

i32 run();

[[nodiscard]] std::string moveToString(Move move);
Expand Down

0 comments on commit 91567e8

Please sign in to comment.