From 7acf57496846a447eb183639cf7b38ea252f9f02 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Fri, 9 Jan 2026 13:10:15 +0100 Subject: [PATCH] Add Camelrider and Zebrarider These new rides must always generate their own Magics. They only need very small tables, as they never have more than 6 blocker squares in their masks. --- src/bitboard.cpp | 20 +++++++++++++++++--- src/types.h | 4 +++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index d1a9628..22c880a 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -63,7 +63,7 @@ Magic CustomMagics[MAX_RIDE - CUSTOM_RIDES][SQUARE_NB]; Magic* magics[MAX_RIDE] = {BishopMagics, RookMagicsH, RookMagicsV, CannonMagicsH, CannonMagicsV, LameDabbabaMagics, HorseMagics, ElephantMagics, JanggiElephantMagics, CannonDiagMagics, NightriderMagics, GrasshopperMagicsH, GrasshopperMagicsV, GrasshopperMagicsD, - RookMagicsHT, RookMagicsHB, RookMagicsVL, RookMagicsVR }; + RookMagicsHT, RookMagicsHB, RookMagicsVL, RookMagicsVR, CamelriderMagics, ZebrariderMagics }; int nrOfRides; int riderBaseType[MAX_RIDE]; @@ -85,6 +85,8 @@ namespace { Bitboard JanggiElephantTable[0x1C000]; // To store janggi elephant attacks Bitboard CannonDiagTable[0x33C00]; // To store diagonal cannon attacks Bitboard NightriderTable[0xD200]; // To store nightrider attacks + Bitboard CamelriderTable[0x8D0]; // To store nightrider attacks + Bitboard ZebrariderTable[0x3D0]; // To store nightrider attacks Bitboard GrasshopperTableH[0x11800]; // To store horizontal grasshopper attacks Bitboard GrasshopperTableV[0x4800]; // To store vertical grasshopper attacks Bitboard GrasshopperTableD[0x33C00]; // To store diagonal grasshopper attacks @@ -100,6 +102,8 @@ namespace { Bitboard JanggiElephantTable[0x5C00]; // To store janggi elephant attacks Bitboard CannonDiagTable[0x1480]; // To store diagonal cannon attacks Bitboard NightriderTable[0x500]; // To store nightrider attacks + Bitboard CamelriderTable[0xD0]; // To store camelrider attacks + Bitboard ZebrariderTable[0x90]; // To store zebrarider attacks Bitboard GrasshopperTableH[0xA00]; // To store horizontal grasshopper attacks Bitboard GrasshopperTableV[0xA00]; // To store vertical grasshopper attacks Bitboard GrasshopperTableD[0x1480]; // To store diagonal grasshopper attacks @@ -112,6 +116,8 @@ namespace { const std::map LameDabbabaDirections { {step(2, 0), 0}, {step(0, 2), 0}, {step(-2, 0), 0}, {step(0, -2), 0} }; const std::map HorseDirections { {step(-2, 1), 0}, {step(-2, -1), 0}, {step(-1, 2), 0}, {step(-1, -2), 0}, {step(1, -2), 0}, {step(1, 2), 0}, {step(2, -1), 0}, {step(2, 1), 0} }; + const std::map CamelDirections { {step(-3, 1), 0}, {step(-3, -1), 0}, {step(-1, 3), 0}, {step(-1, -3), 0}, + {step(1, -3), 0}, {step(1, 3), 0}, {step(3, -1), 0}, {step(3, 1), 0} }; const std::map ElephantDirections { {step(2, 2), 0}, {step(-2, 2), 0}, {step(-2, -2), 0}, {step(2, -2), 0} }; const std::map JanggiElephantDirections { {step(3, 2), 0}, {step(2, 3), 0}, {step(-2, 3), 0}, {step(-3, 2), 0}, @@ -159,10 +165,10 @@ namespace { } for (Square s = ss + d; - is_ok(s) && distance(s, s - d) <= 2; + is_ok(s) && distance(s, s - d) <= 3; s += d) { - if(mask && (!is_ok(s + d) || distance(s, s + d) > 2)) break; // forelast square is not blocker + if(mask && (!is_ok(s + d) || distance(s, s + d) > 3)) break; // forelast square is not blocker if (MT != HOPPER || hurdle) { @@ -343,6 +349,10 @@ void Bitboards::init_pieces() { riderTypes |= assign_magic(RIDER_ROOK_V, limit); if (HorseDirections.find(d) != HorseDirections.end()) riderTypes |= RIDER_NIGHTRIDER; + if (CamelDirections.find(d) != CamelDirections.end()) + riderTypes |= RIDER_CAMELRIDER; + if (JannggiElephantDirections.find(d) != JannggiElephantDirections.end()) + riderTypes |= RIDER_ZEBRARIDER; if (RookDirectionsHT.find(d) != RookDirectionsHT.end()) riderTypes |= RIDER_ROOK_HT; if (RookDirectionsVR.find(d) != RookDirectionsVR.end()) @@ -427,6 +437,8 @@ void Bitboards::init() { init_magics(JanggiElephantTable, JanggiElephantMagics, JanggiElephantDirections, JanggiElephantMagicInit); init_magics(CannonDiagTable, CannonDiagMagics, BishopDirections, CannonDiagMagicInit); init_magics(NightriderTable, NightriderMagics, HorseDirections, NightriderMagicInit); + init_magics(CamelriderTable, CamelriderMagics, CamelDirections, NULL); + init_magics(ZebrariderTable, ZebrariderMagics, JanggiElephantDirections, NULL); init_magics(GrasshopperTableH, GrasshopperMagicsH, GrasshopperDirectionsH, GrasshopperMagicHInit); init_magics(GrasshopperTableV, GrasshopperMagicsV, GrasshopperDirectionsV, GrasshopperMagicVInit); init_magics(GrasshopperTableD, GrasshopperMagicsD, GrasshopperDirectionsD, GrasshopperMagicDInit); @@ -442,6 +454,8 @@ void Bitboards::init() { init_magics(JanggiElephantTable, JanggiElephantMagics, JanggiElephantDirections); init_magics(CannonDiagTable, CannonDiagMagics, BishopDirections); init_magics(NightriderTable, NightriderMagics, HorseDirections); + init_magics(CamelriderTable, CamelriderMagics, CamelDirections); + init_magics(ZebrariderTable, ZebrariderMagics, JanggiElephantDirections); init_magics(GrasshopperTableH, GrasshopperMagicsH, GrasshopperDirectionsH); init_magics(GrasshopperTableV, GrasshopperMagicsV, GrasshopperDirectionsV); init_magics(GrasshopperTableD, GrasshopperMagicsD, GrasshopperDirectionsD); diff --git a/src/types.h b/src/types.h index 620e99b..71d7cf5 100644 --- a/src/types.h +++ b/src/types.h @@ -474,13 +474,15 @@ enum RiderType : int { RIDER_ROOK_HB = 1 << 15, RIDER_ROOK_VL = 1 << 16, RIDER_ROOK_VR = 1 << 17, + RIDER_CAMELRIDER = 1 << 18, + RIDER_ZEBRARIDER = 1 << 19, RIDER_GRIFFON = RIDER_ROOK_HT | RIDER_ROOK_HB | RIDER_ROOK_VL | RIDER_ROOK_VR, HOPPING_RIDERS = RIDER_CANNON_H | RIDER_CANNON_V | RIDER_CANNON_DIAG | RIDER_GRASSHOPPER_H | RIDER_GRASSHOPPER_V | RIDER_GRASSHOPPER_D, LAME_LEAPERS = RIDER_LAME_DABBABA | RIDER_HORSE | RIDER_ELEPHANT | RIDER_JANGGI_ELEPHANT, ASYMMETRICAL_RIDERS = RIDER_HORSE | RIDER_JANGGI_ELEPHANT | GRIFFON | RIDER_GRASSHOPPER_H | RIDER_GRASSHOPPER_V | RIDER_GRASSHOPPER_D, - NON_SLIDING_RIDERS = HOPPING_RIDERS | LAME_LEAPERS | RIDER_NIGHTRIDER, + NON_SLIDING_RIDERS = HOPPING_RIDERS | LAME_LEAPERS | RIDER_NIGHTRIDER | RIDER_CAMELRIDER | RIDER_ZEBRARIDER, CUSTOM_RIDES = 20, MAX_RIDE = 32 }; -- 1.7.0.4